From dd7a4209752715db544b2fef804da9762c532cdc Mon Sep 17 00:00:00 2001 From: kokoniara <70776766+kingstefan26@users.noreply.github.com> Date: Fri, 7 Oct 2022 14:50:22 +0200 Subject: fix player profile not never loading in chat (#63) * fix player profile not never loading in chat * cut out hychat like a cancer * ApiFetchur now caches whole players not single profiles, added a switch profile button in gui * ugh git * Revert "cut out hychat like a cancer" This reverts commit 2ee11afa * ugh git x2 * I tried, good luck maintaining this * forgot to uncomment hychat fix * now shows which profile is now selected put button on top a lil refactor * fix player profile sometimes not loading Co-authored-by: syeyoung <42869671+cyoung06@users.noreply.github.com> --- build.gradle | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) mode change 100755 => 100644 build.gradle (limited to 'build.gradle') diff --git a/build.gradle b/build.gradle old mode 100755 new mode 100644 index f108ac58..24bc189f --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,22 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + plugins { id "idea" id "java" -- cgit From 292fbd05e13271ca3ad99ebe00ae4302e04848f3 Mon Sep 17 00:00:00 2001 From: Eryk Ruta <70776766+kingstefan26@users.noreply.github.com> Date: Tue, 1 Nov 2022 15:51:30 +0100 Subject: 3rd time is the charm (#70) * Updated some dependencies, used my crusty skytils forgegradle fork + removed the IRRELEVANT hytils fixes. generally made the thing build * made the logs less annoying * temp fix so it doesn't throw an exception * FAT REFACTOR General refactor on Authenticator.java DungeonsGuide.java Main.java removed unnecessary imports where not needed to be removed DGInterface.java (no real reason to exist) in DungeonsGuide.java made the retry stomp a singe-thread executor, so it doesn't leak when offline added an "offline mode" so it doesn't just error when server down TODO: move auth to DungeonsGuide.java and make it retry when network down on launch * New auth implementation that should replace the old one: does all the things the old one did removed progressBar cuz it would make the impl 3x more complicated in the name of a splash screen added a token changed event (so now it supports re-logging with a different account) code is (should) be more readable / extensible TODO: surgically replace Authenticator.java with new impl AND support re-logging * Made the chat processor logger name less obnoxious * implemented my implementation of an implementation of auth can and is very buggy, essentially the loading of the remote classes but the mod works so idk TODO: MAKE STOMP NOT DO STUFF TILL STOMPCONNECTED IS EMITTED * fix for stomp client null bc forge events not going tru on pre-init TODO: make work and test the web loadable classes, then make all the stuff that relies on stomp not throw exceptions when stomp is not connected * move the create auth method into AuthProvider interface, so we don't clutter AuthManager with implementation details * Decouple AuthProviderUtil and DgAuth, move some stuff around and make it more readable * moved AuthUtil to make more sense * de-clutter the tree a little bit * Inline StompClientStatus.java / refactor * inline the useless interface * refactoringgg * fix ahUtils exeption spam * small StompClient refactor * fix GLCursors exeption spam + logger * make sure we are authenticated when downloading resources * new .destination("value") instead of .header("destination", "value") * StompMessageHandler -> StompMessageSubscription * Introduced StompManager * fix dungeon map not showing ppl heads * ehhh * wip (commit cuz im chekig out) * fix player profile not never loading in chat * remove this specific line * fix player profile not never loading in chat * cut out hychat like a cancer * ApiFetchur now caches whole players not single profiles, added a switch profile button in gui * ugh git * Revert "cut out hychat like a cancer" This reverts commit 2ee11afa * ugh git x2 * I tried, good luck maintaining this * forgot to uncomment hychat fix * make my new party ready work and look ok * change the look and add some "somewhere" locations * make stomp connection "null safe" * i hate git * introduce callbacks on parameter change for cleaner code add one example * impl new system, half way done * now shows which profile is now selected put button on top a lil refactor * fix player profile sometimes not loading * add players knowing who is using dg (try to) * announcing that we are a dg user will get reworked in the future * update deps * make it not spam logs * sanity check for premium features so it doesn't 403 * add YoMamaOutdated that checks if you are using outdated dg * hychat?? anyone * try catch in FeatureRegistry * added Ether transmission ability * chat shredder borken, disabled for now * party deserves its own folder * dungeon stuff in dungeon folder * events folders moved * fix score data collection hanging forever if stomp is not connected * fix stomp never connecting * re-add the removed * fix wonky rendering * server side implementation is not ready, canning this for a future release * attempt to fix heads loading on main thread * discord * me when sonar lint * new consumer based stomp subscriptions * replace old with new subscriptions * remove the remains of StompSubscription and replace CloseListener with a forge event * StompSubscription is now a functional interface * remove unnecessary event message chains, feature logic should be in the feature * fix events being set up wrongly * Revert "fix events being set up wrongly" This reverts commit e6ea7efa557a5f5c8a3ea33be998717bc024b8cb. * Revert "remove unnecessary event message chains," This reverts commit 96f508bae85b33cdcef6be19226c00fc52a1439b. * fix stomp client sending payload object instead of the actual payload * fix null pointer on empty party * fix players with cosmetics name being white in tab * added message when not connected to dg changed YoMamaOutdated to use CloudFlare workers added client sided message queue * the mod doesn't init when outdated * mcmod.info * dont busy wait in authmenager * test pepole crusty tests * chill out the authmanager * name the thread pool in auth manager * clear most compiler warnings * make outdated check allow to play without the mod initialized * make first startup VERY noticeable, move config creation to main * major dungeon package refactor * refactor checkpoint * refactor checkpoint #1 * final refactor checkpoint #2 * remove the player if from version check, made the version check not nesssery for playing Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * remove trap room fix that didnt fix anything Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * make secret beacons optional Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * make the checkmarks on map align with the rest of everyone Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * removed debug function Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move the menus to make more sense + make destination text on secrets optional Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * improve dungeonMap performance by ~90% temporarly disabled 9 slot map player location due to bugs fix DungeonContext not getting player from ScoreBoard Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * add epic countdown on dungeon start (still wip) Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * added a option to cache blockstaes Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * added TabListUtil Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * fixed epic countdown Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * (i want to sleep) made all the dungeon room detection async TODO: fix ol the bugs i created by doing that Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * stuff still broken but almost playable, unlike last commit Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * upload build jar to discord Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * cache the deps for the love of god Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * who needs linux and 32bit windows anyway Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * only upload to discord on beta branch Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * added "kick" when a member joins party Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move stuff that sends chat to player into a separate class Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * use our chat queue instead of calling `thePlayer.addChatMessage` to proxy ourselves from 1.8 code Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * Added and implemented MortDetector2000.java Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * extract duplicate + make more readable Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * added dummy support in FeatureDebugTrap Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * gradle now puts version in mcmod.info Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * remove side effects from DgAuth.java Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move debug commands into debug CommandDgDebug.java Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * fix key being wrong Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move epic countdown to dungeon huds, clean up Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * Revert "who needs linux and 32bit windows anyway" This reverts commit 0f3c2d544a70fc799cd3215dad5e997c0c8b6c06. * make FeatureRegistry not static initialise to get rid of "ClassNotDefined" errors Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * null check on Exception since it threw NullPointers Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * finish up progress bar in DungeonsGuide.java Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * warn about null features Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move stuff around in SkyblockStatus, move the stuff that updates status into SkyblockStatus from DungeonListener Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * rename DungeonGodObject.java to DungeonFacade.java Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * add cleanChat clause in FeatureEpicCountdown Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * implement getPreRequisites and isComplete in ActionBreakWithSuperBoom Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * clean up FeatureParameter Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * eliminate possible state inconsistency in DungeonListener Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move percentage from DungeonFacade to DungeonContext Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move `purge` and `partymax` back into CommandDungeonsGuide Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * stop repeating ReceiveChatQueue in ChatTransmitter Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * Clean up DungeonsGuide Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move `sendDebugChat` to `ChatTransmitter.java` Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * change CommandDgDebug into a `else if` from an `switch` because some bigot decided its better Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * duplicate code since it currently doesn't make sense, to be reworked Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * fix typo Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * remove the trycatch so we fail fast Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * fix null pointer when trying to get fontRenderer before minecraft is initialised Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * broken checkpoint 0 Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * broken checkpoint 1 Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * Revert "broken checkpoint 1" This reverts commit 64985e6287c7b5650b509668e42b9803e25c419c. * Revert "broken checkpoint 0" This reverts commit 5f62e1345d9c8e7f66f1e5792004a05027913d92. * Revert "fix null pointer when trying to get fontRenderer before minecraft is initialised" This reverts commit 57d92a78d31c410f699b58c8995c94055d57e2a4. * Revert "remove the trycatch so we fail fast" This reverts commit 12772255ed575e411fb99edf37ec16d0e5f42924. * Revert "fix typo" This reverts commit aa96cc2436d3ead42d53ead78f3334fac5100713. * Revert "duplicate code since it currently doesn't make sense, to be reworked" This reverts commit 6d71b88e3102d23bcfd90d85e8996327776fd52f. * Revert "change CommandDgDebug into a `else if` from an `switch` because some bigot decided its better" This reverts commit ffea84d9b5fd4adbe034a88249bc920eafa7c53a. * Revert "move `sendDebugChat` to `ChatTransmitter.java`" This reverts commit 5b8b2e22fff33768134a01c15c7650100ebb9257. * Revert "Clean up DungeonsGuide" This reverts commit 2069ad3ebc4344eb1e778954dc1d8f6c9303de69. * fix typo Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> (cherry picked from commit aa96cc2436d3ead42d53ead78f3334fac5100713) * duplicate code since it currently doesn't make sense, to be reworked Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> (cherry picked from commit 6d71b88e3102d23bcfd90d85e8996327776fd52f) * change CommandDgDebug into a `else if` from an `switch` because some bigot decided its better Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> (cherry picked from commit ffea84d9b5fd4adbe034a88249bc920eafa7c53a) * move debug chat into ChatTransmitter Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * null pointer in SkyblockStatus bc context was not initialised yet Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move dungeon starting door detection up the tree since it was a duplicate in both children, inline MortDetector2000 Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move dungeon name to DungeonContext Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * clean up Main Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * separate the "loader" and "mod" Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * separate DungeonsGuide and Main even more Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * change singleton implementation of DungeonsGuide Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move classes since their paths are hardcoded into roomdatas Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * create CatacombsDataProvider.java and implement it Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * remove unnecessary `DungeonsGuide.getDungeonsGuide();` (IntelliJ refactor bug) Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * move `help` text in commands Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * a certain someone hates switch statements Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * remove my version check, since we have to wait for out lord and savior to make his own Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * make `Main` and `DungeonsGuide` compatible with supported jar classloading Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * make the beta upload action run on push since it didnt get the secret on pull request and failed anyway, TODO: make the jar name not hardcoded Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> * upload all jar Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> Signed-off-by: kingstefan26 <70776766+kingstefan26@users.noreply.github.com> Co-authored-by: syeyoung <42869671+cyoung06@users.noreply.github.com> --- .github/workflows/beta.yml | 33 + .github/workflows/main.yml | 7 +- build.gradle | 36 +- .../kr/syeyoung/dungeonsguide/Authenticator.java | 302 ----- .../kr/syeyoung/dungeonsguide/DGInterface.java | 28 - .../kr/syeyoung/dungeonsguide/DungeonsGuide.java | 272 ---- .../kr/syeyoung/dungeonsguide/GuiLoadingError.java | 21 +- .../kr/syeyoung/dungeonsguide/IDungeonGuide.java | 10 + .../java/kr/syeyoung/dungeonsguide/Keybinds.java | 53 - src/main/java/kr/syeyoung/dungeonsguide/Main.java | 185 +-- .../kr/syeyoung/dungeonsguide/SkyblockStatus.java | 123 -- .../kr/syeyoung/dungeonsguide/YoMamaOutdated.java | 110 ++ .../syeyoung/dungeonsguide/auth/AuthManager.java | 150 +++ .../kr/syeyoung/dungeonsguide/auth/AuthUtil.java | 70 + .../InvalidDungeonsGuideCredentialsException.java | 8 + .../dungeonsguide/auth/ResourceManager.java | 164 +++ .../auth/authprovider/AuthProvider.java | 16 + .../auth/authprovider/DgAuth/DgAuth.java | 46 + .../auth/authprovider/DgAuth/DgAuthUtil.java | 88 ++ .../dungeonsguide/auth/authprovider/NullAuth.java | 62 + .../dungeonsguide/chat/ChatProcessResult.java | 31 - .../syeyoung/dungeonsguide/chat/ChatProcessor.java | 115 -- .../dungeonsguide/chat/ChatSubscriber.java | 26 - .../syeyoung/dungeonsguide/chat/PartyContext.java | 89 -- .../syeyoung/dungeonsguide/chat/PartyManager.java | 605 --------- .../commands/CommandDungeonsGuide.java | 602 --------- .../dungeonsguide/commands/CommandReparty.java | 110 -- .../kr/syeyoung/dungeonsguide/config/Config.java | 65 - .../config/guiconfig/ConfigPanelCreator.java | 40 - .../config/guiconfig/GuiConfigV2.java | 59 - .../dungeonsguide/config/guiconfig/MCategory.java | 103 -- .../config/guiconfig/MCategoryElement.java | 82 -- .../dungeonsguide/config/guiconfig/MFeature.java | 154 --- .../config/guiconfig/MFeatureEdit.java | 113 -- .../dungeonsguide/config/guiconfig/MNotFound.java | 40 - .../config/guiconfig/MPanelCategory.java | 83 -- .../config/guiconfig/MParameterEdit.java | 220 ---- .../config/guiconfig/NestedCategory.java | 55 - .../config/guiconfig/RootConfigPanel.java | 305 ----- .../guiconfig/location/GuiGuiLocationConfig.java | 166 --- .../config/guiconfig/location/Marker.java | 45 - .../config/guiconfig/location/PanelDelegate.java | 406 ------ .../dungeonsguide/config/types/AColor.java | 63 - .../dungeonsguide/config/types/GUIRectangle.java | 82 -- .../dungeonsguide/config/types/TCAColor.java | 53 - .../dungeonsguide/config/types/TCBoolean.java | 39 - .../dungeonsguide/config/types/TCColor.java | 42 - .../dungeonsguide/config/types/TCFloat.java | 39 - .../dungeonsguide/config/types/TCGUIRectangle.java | 52 - .../dungeonsguide/config/types/TCInteger.java | 39 - .../dungeonsguide/config/types/TCKeybind.java | 39 - .../dungeonsguide/config/types/TCRectangle.java | 53 - .../dungeonsguide/config/types/TCString.java | 39 - .../dungeonsguide/config/types/TCStringList.java | 52 - .../dungeonsguide/config/types/TCTextStyle.java | 55 - .../config/types/TCTextStyleList.java | 55 - .../dungeonsguide/config/types/TypeConverter.java | 29 - .../config/types/TypeConverterRegistry.java | 54 - .../dungeonsguide/cosmetics/ActiveCosmetic.java | 12 - .../dungeonsguide/cosmetics/CosmeticData.java | 14 - .../dungeonsguide/cosmetics/CosmeticsManager.java | 300 ----- .../cosmetics/CustomNetworkPlayerInfo.java | 103 -- .../cosmetics/CustomPacketPlayerListItem.java | 39 - .../dungeonsguide/cosmetics/IChatReplacer.java | 26 - .../chatreplacers/ChatReplacerChatByMe.java | 106 -- .../cosmetics/chatreplacers/ChatReplacerCoop.java | 121 -- .../chatreplacers/ChatReplacerMessage.java | 107 -- .../cosmetics/chatreplacers/ChatReplacerPV.java | 119 -- .../chatreplacers/ChatReplacerSocialOptions.java | 121 -- .../chatreplacers/ChatReplacerViewProfile.java | 128 -- .../dungeon/DungeonActionManager.java | 38 - .../dungeonsguide/dungeon/DungeonContext.java | 206 --- .../dungeonsguide/dungeon/MapProcessor.java | 504 ------- .../dungeon/actions/AbstractAction.java | 57 - .../dungeonsguide/dungeon/actions/Action.java | 40 - .../dungeon/actions/ActionBreakWithSuperBoom.java | 101 -- .../dungeon/actions/ActionChangeState.java | 72 - .../dungeonsguide/dungeon/actions/ActionClick.java | 78 -- .../dungeon/actions/ActionClickSet.java | 91 -- .../dungeon/actions/ActionComplete.java | 41 - .../dungeon/actions/ActionDropItem.java | 71 - .../dungeon/actions/ActionInteract.java | 81 -- .../dungeonsguide/dungeon/actions/ActionKill.java | 89 -- .../dungeonsguide/dungeon/actions/ActionMove.java | 114 -- .../dungeon/actions/ActionMoveNearestAir.java | 113 -- .../dungeonsguide/dungeon/actions/ActionRoot.java | 48 - .../dungeon/actions/tree/ActionRoute.java | 124 -- .../dungeon/actions/tree/ActionTree.java | 83 -- .../dungeon/actions/tree/ActionTreeUtil.java | 83 -- .../dungeon/data/DungeonRoomInfo.java | 6 +- .../dungeonsguide/dungeon/data/OffsetPoint.java | 21 +- .../dungeonsguide/dungeon/data/OffsetPointSet.java | 2 +- .../dungeon/doorfinder/CatacombDataProvider.java | 171 --- .../doorfinder/CatacombMasterDataProvider.java | 125 -- .../dungeon/doorfinder/DungeonDoor.java | 81 -- .../doorfinder/DungeonSpecificDataProvider.java | 39 - .../DungeonSpecificDataProviderRegistry.java | 39 - .../dungeon/doorfinder/EDungeonDoorType.java | 33 - .../dungeon/events/DungeonCryptBrokenEvent.java | 37 - .../dungeon/events/DungeonDeathEvent.java | 38 - .../dungeonsguide/dungeon/events/DungeonEvent.java | 41 - .../dungeon/events/DungeonEventData.java | 25 - .../dungeon/events/DungeonEventHolder.java | 32 - .../dungeon/events/DungeonMapUpdateEvent.java | 33 - .../dungeon/events/DungeonNodataEvent.java | 28 - .../dungeon/events/DungeonPuzzleFailureEvent.java | 33 - .../dungeon/events/DungeonRoomDiscoverEvent.java | 45 - .../events/DungeonSecretCountChangeEvent.java | 39 - .../dungeon/events/DungeonStateChangeEvent.java | 41 - .../dungeon/events/SerializableBlockPos.java | 36 - .../dungeon/mechanics/DungeonBreakableWall.java | 18 +- .../dungeon/mechanics/DungeonDoor.java | 16 +- .../dungeon/mechanics/DungeonDummy.java | 13 +- .../dungeon/mechanics/DungeonFairySoul.java | 56 +- .../dungeon/mechanics/DungeonJournal.java | 17 +- .../dungeon/mechanics/DungeonLever.java | 17 +- .../dungeon/mechanics/DungeonMechanic.java | 40 - .../dungeon/mechanics/DungeonNPC.java | 67 +- .../dungeon/mechanics/DungeonOnewayDoor.java | 22 +- .../dungeon/mechanics/DungeonOnewayLever.java | 17 +- .../dungeon/mechanics/DungeonPressurePlate.java | 52 +- .../dungeon/mechanics/DungeonRoomDoor.java | 50 +- .../dungeon/mechanics/DungeonSecret.java | 106 +- .../dungeon/mechanics/DungeonTomb.java | 64 +- .../dungeon/mechanics/RouteBlocker.java | 25 - .../mechanics/dunegonmechanic/DungeonMechanic.java | 40 + .../mechanics/dunegonmechanic/RouteBlocker.java | 25 + .../mechanics/predicates/PredicateArmorStand.java | 1 - .../dungeon/roomfinder/DungeonRoom.java | 381 ------ .../roomfinder/DungeonRoomInfoRegistry.java | 143 -- .../dungeon/roomfinder/RoomMatcher.java | 155 --- .../eventlistener/DungeonListener.java | 585 --------- .../eventlistener/FeatureListener.java | 512 -------- .../eventlistener/PacketListener.java | 177 --- .../dungeonsguide/events/BlockUpdateEvent.java | 38 - .../dungeonsguide/events/BossroomEnterEvent.java | 24 - .../events/DiscordUserJoinRequestEvent.java | 30 - .../events/DiscordUserUpdateEvent.java | 30 - .../events/DungeonContextInitializationEvent.java | 24 - .../dungeonsguide/events/DungeonEndedEvent.java | 24 - .../dungeonsguide/events/DungeonLeftEvent.java | 24 - .../dungeonsguide/events/DungeonStartedEvent.java | 24 - .../dungeonsguide/events/HypixelJoinedEvent.java | 24 - .../dungeonsguide/events/KeyBindPressedEvent.java | 28 - .../events/PlayerInteractEntityEvent.java | 39 - .../events/PlayerListItemPacketEvent.java | 30 - .../dungeonsguide/events/SkyblockJoinedEvent.java | 24 - .../dungeonsguide/events/SkyblockLeftEvent.java | 24 - .../dungeonsguide/events/StompConnectedEvent.java | 30 - .../syeyoung/dungeonsguide/events/TitleEvent.java | 30 - .../dungeonsguide/events/WindowUpdateEvent.java | 33 - .../dungeonsguide/features/AbstractFeature.java | 109 -- .../dungeonsguide/features/FeatureParameter.java | 51 - .../dungeonsguide/features/FeatureRegistry.java | 217 --- .../dungeonsguide/features/GuiFeature.java | 160 --- .../dungeonsguide/features/SimpleFeature.java | 33 - .../features/impl/advanced/FeatureDebug.java | 65 - .../impl/advanced/FeatureDebuggableMap.java | 92 -- .../impl/advanced/FeatureRoomCoordDisplay.java | 93 -- .../impl/advanced/FeatureRoomDebugInfo.java | 94 -- .../features/impl/boss/FeatureAutoReparty.java | 34 - .../features/impl/boss/FeatureBossHealth.java | 103 -- .../features/impl/boss/FeatureBoxRealLivid.java | 54 - .../features/impl/boss/FeatureChestPrice.java | 174 --- .../features/impl/boss/FeatureCurrentPhase.java | 74 -- .../features/impl/boss/FeatureHideAnimals.java | 69 - .../features/impl/boss/FeatureTerracotaTimer.java | 77 -- .../impl/boss/FeatureThornBearPercentage.java | 78 -- .../impl/boss/FeatureThornSpiritBowTimer.java | 111 -- .../features/impl/boss/FeatureWarningOnPortal.java | 200 --- .../terminal/CorrectThePaneSolutionProvider.java | 53 - .../impl/boss/terminal/FeatureSimonSaysSolver.java | 115 -- .../impl/boss/terminal/FeatureTerminalSolvers.java | 155 --- .../terminal/NavigateMazeSolutionProvider.java | 144 -- .../terminal/SelectAllColorSolutionProivider.java | 60 - .../terminal/SelectInOrderSolutionProvider.java | 72 - .../impl/boss/terminal/TerminalSolution.java | 30 - .../boss/terminal/TerminalSolutionProvider.java | 29 - .../terminal/WhatStartsWithSolutionProvider.java | 51 - .../impl/cosmetics/FeatureNicknameColor.java | 49 - .../impl/cosmetics/FeatureNicknamePrefix.java | 49 - .../features/impl/cosmetics/PrefixSelectorGUI.java | 188 --- .../impl/discord/inviteViewer/ImageTexture.java | 120 -- .../discord/inviteViewer/PartyInviteViewer.java | 320 ----- .../discord/inviteViewer/PartyJoinRequest.java | 59 - .../impl/discord/invteTooltip/MTooltipInvite.java | 128 -- .../invteTooltip/MTooltipInviteElement.java | 109 -- .../impl/discord/onlinealarm/PlayingDGAlarm.java | 171 --- .../features/impl/dungeon/FeatureBoxBats.java | 68 - .../impl/dungeon/FeatureBoxSkelemaster.java | 68 - .../features/impl/dungeon/FeatureBoxStarMobs.java | 68 - .../features/impl/dungeon/FeatureCollectScore.java | 28 - .../dungeon/FeatureDungeonCurrentRoomSecrets.java | 108 -- .../impl/dungeon/FeatureDungeonDeaths.java | 167 --- .../features/impl/dungeon/FeatureDungeonMap.java | 454 ------- .../impl/dungeon/FeatureDungeonMilestone.java | 109 -- .../impl/dungeon/FeatureDungeonRealTime.java | 92 -- .../impl/dungeon/FeatureDungeonRoomName.java | 98 -- .../impl/dungeon/FeatureDungeonSBTime.java | 119 -- .../features/impl/dungeon/FeatureDungeonScore.java | 361 ----- .../impl/dungeon/FeatureDungeonSecrets.java | 144 -- .../features/impl/dungeon/FeatureDungeonTombs.java | 88 -- .../features/impl/dungeon/FeatureHideNameTags.java | 53 - .../features/impl/dungeon/FeaturePlayerESP.java | 111 -- .../dungeon/FeaturePressAnyKeyToCloseChest.java | 89 -- .../impl/dungeon/FeatureWarnLowHealth.java | 106 -- .../impl/dungeon/FeatureWatcherWarning.java | 87 -- .../impl/etc/FeatureAutoAcceptReparty.java | 68 - .../features/impl/etc/FeatureCooldownCounter.java | 106 -- .../features/impl/etc/FeatureCopyMessages.java | 42 - .../impl/etc/FeatureDecreaseExplosionSound.java | 55 - .../features/impl/etc/FeatureDisableMessage.java | 79 -- .../features/impl/etc/FeaturePenguins.java | 182 --- .../features/impl/etc/FeatureRepartyCommand.java | 29 - .../impl/etc/FeatureTooltipDungeonStat.java | 52 - .../features/impl/etc/FeatureTooltipPrice.java | 111 -- .../features/impl/etc/FeatureUpdateAlarm.java | 63 - .../impl/etc/ability/FeatureAbilityCooldown.java | 403 ------ .../features/impl/etc/ability/SkyblockAbility.java | 32 - .../features/impl/etc/ability/UsedAbility.java | 31 - .../dungeonsguide/features/impl/party/APIKey.java | 58 - .../features/impl/party/FeatureGoodParties.java | 121 -- .../features/impl/party/FeaturePartyList.java | 97 -- .../features/impl/party/FeaturePartyReady.java | 181 --- .../party/customgui/FeatureCustomPartyFinder.java | 114 -- .../impl/party/customgui/GuiCustomPartyFinder.java | 78 -- .../impl/party/customgui/PanelPartyFinder.java | 341 ----- .../party/customgui/PanelPartyFinderSettings.java | 294 ----- .../party/customgui/PanelPartyListElement.java | 237 ---- .../impl/party/playerpreview/FakePlayer.java | 101 -- .../FeatureViewPlayerStatsOnJoin.java | 703 ---------- .../impl/party/playerpreview/api/ApiFetcher.java | 387 ------ .../impl/party/playerpreview/api/CachedData.java | 29 - .../playerpreview/api/PlayerSkyblockData.java | 10 - .../impl/party/playerpreview/api/SkinFetcher.java | 90 -- .../api/playerprofile/PlayerProfile.java | 92 -- .../api/playerprofile/PlayerProfileParser.java | 449 ------- .../dataclasses/ClassSpecificData.java | 29 - .../playerprofile/dataclasses/DungeonClass.java | 46 - .../dataclasses/DungeonSpecificData.java | 29 - .../api/playerprofile/dataclasses/DungeonStat.java | 54 - .../api/playerprofile/dataclasses/DungeonType.java | 39 - .../dataclasses/FloorSpecificData.java | 29 - .../api/playerprofile/dataclasses/Pet.java | 31 - .../api/playerprofile/dataclasses/Skill.java | 31 - .../datarenders/DataRendererEditor.java | 357 ----- .../datarenders/DataRendererRegistry.java | 64 - .../playerpreview/datarenders/IDataRenderer.java | 33 - .../impl/DataRenderDungeonFloorStat.java | 105 -- .../impl/DataRenderDungeonHighestFloorStat.java | 107 -- .../datarenders/impl/DataRendererClassLv.java | 88 -- .../datarenders/impl/DataRendererDungeonLv.java | 82 -- .../datarenders/impl/DataRendererFairySouls.java | 50 - .../datarenders/impl/DataRendererLilyWeight.java | 71 - .../datarenders/impl/DataRendererSecrets.java | 53 - .../impl/DataRendererSelectedClassLv.java | 77 -- .../datarenders/impl/DataRendererSetUrOwn.java | 57 - .../datarenders/impl/DataRendererSkillLv.java | 80 -- .../datarenders/impl/DataRendererTalismans.java | 123 -- .../features/impl/secret/FeatureActions.java | 144 -- .../features/impl/secret/FeatureBloodRush.java | 45 - .../impl/secret/FeatureCreateRefreshLine.java | 72 - .../impl/secret/FeatureFreezePathfind.java | 57 - .../impl/secret/FeaturePathfindStrategy.java | 110 -- .../features/impl/secret/FeaturePathfindToAll.java | 45 - .../impl/secret/FeatureSoulRoomWarning.java | 231 ---- .../impl/secret/FeatureTogglePathfind.java | 55 - .../impl/secret/PathfindLineProperties.java | 117 -- .../mechanicbrowser/FeatureMechanicBrowse.java | 179 --- .../mechanicbrowser/MGuiMechanicBrowser.java | 45 - .../mechanicbrowser/MechanicBrowserElement.java | 65 - .../mechanicbrowser/MechanicBrowserTooltip.java | 68 - .../mechanicbrowser/PanelMechanicBrowser.java | 327 ----- .../features/impl/solvers/FeatureSolverBlaze.java | 46 - .../impl/solvers/FeatureSolverBombdefuse.java | 30 - .../features/impl/solvers/FeatureSolverBox.java | 57 - .../impl/solvers/FeatureSolverIcefill.java | 40 - .../features/impl/solvers/FeatureSolverKahoot.java | 35 - .../features/impl/solvers/FeatureSolverRiddle.java | 35 - .../impl/solvers/FeatureSolverSilverfish.java | 40 - .../impl/solvers/FeatureSolverTeleport.java | 39 - .../impl/solvers/FeatureSolverTictactoe.java | 39 - .../features/listener/BossroomEnterListener.java | 23 - .../features/listener/ChatListener.java | 25 - .../features/listener/ChatListenerGlobal.java | 25 - .../listener/DiscordUserJoinRequestListener.java | 26 - .../listener/DiscordUserUpdateListener.java | 25 - .../DungeonContextInitializationListener.java | 23 - .../features/listener/DungeonEndListener.java | 23 - .../features/listener/DungeonQuitListener.java | 23 - .../features/listener/DungeonStartListener.java | 23 - .../listener/EntityLivingRenderListener.java | 27 - .../listener/GuiBackgroundRenderListener.java | 25 - .../features/listener/GuiClickListener.java | 25 - .../features/listener/GuiOpenListener.java | 25 - .../features/listener/GuiPostRenderListener.java | 26 - .../features/listener/GuiPreRenderListener.java | 25 - .../features/listener/GuiUpdateListener.java | 26 - .../features/listener/InteractListener.java | 26 - .../features/listener/KeyInputListener.java | 26 - .../features/listener/KeybindPressedListener.java | 25 - .../features/listener/PlayerRenderListener.java | 26 - .../features/listener/ScreenRenderListener.java | 23 - .../features/listener/SkyblockJoinListener.java | 23 - .../features/listener/SkyblockLeaveListener.java | 23 - .../features/listener/SoundListener.java | 25 - .../features/listener/StompConnectedListener.java | 25 - .../features/listener/TextureStichListener.java | 26 - .../features/listener/TickListener.java | 23 - .../features/listener/TitleListener.java | 25 - .../features/listener/TooltipListener.java | 25 - .../features/listener/WorldRenderListener.java | 23 - .../features/text/PanelTextParameterConfig.java | 284 ---- .../dungeonsguide/features/text/StyledText.java | 29 - .../features/text/StyledTextProvider.java | 30 - .../features/text/StyledTextRenderer.java | 245 ---- .../features/text/TextHUDFeature.java | 191 --- .../dungeonsguide/features/text/TextStyle.java | 36 - .../kr/syeyoung/dungeonsguide/gamesdk/GameSDK.java | 95 -- .../gamesdk/jna/GameSDKTypeMapper.java | 46 - .../dungeonsguide/gamesdk/jna/NativeGameSDK.java | 50 - .../gamesdk/jna/datastruct/DiscordActivity.java | 51 - .../jna/datastruct/DiscordActivityAssets.java | 42 - .../jna/datastruct/DiscordActivityParty.java | 40 - .../jna/datastruct/DiscordActivitySecrets.java | 41 - .../jna/datastruct/DiscordActivityTimestamps.java | 40 - .../jna/datastruct/DiscordCreateParams.java | 72 - .../gamesdk/jna/datastruct/DiscordEntitlement.java | 42 - .../gamesdk/jna/datastruct/DiscordFileStat.java | 42 - .../jna/datastruct/DiscordImageDimensions.java | 40 - .../gamesdk/jna/datastruct/DiscordImageHandle.java | 43 - .../gamesdk/jna/datastruct/DiscordInputMode.java | 41 - .../gamesdk/jna/datastruct/DiscordLobby.java | 47 - .../gamesdk/jna/datastruct/DiscordOAuth2Token.java | 42 - .../gamesdk/jna/datastruct/DiscordPartySize.java | 40 - .../gamesdk/jna/datastruct/DiscordPresence.java | 40 - .../jna/datastruct/DiscordRelationship.java | 41 - .../gamesdk/jna/datastruct/DiscordSku.java | 44 - .../gamesdk/jna/datastruct/DiscordSkuPrice.java | 41 - .../gamesdk/jna/datastruct/DiscordStruct.java | 36 - .../gamesdk/jna/datastruct/DiscordUser.java | 46 - .../jna/datastruct/DiscordUserAchievement.java | 44 - .../enumuration/EDiscordActivityActionType.java | 67 - .../EDiscordActivityJoinRequestReply.java | 68 - .../jna/enumuration/EDiscordActivityType.java | 69 - .../jna/enumuration/EDiscordCreateFlags.java | 67 - .../jna/enumuration/EDiscordEntitlementType.java | 72 - .../gamesdk/jna/enumuration/EDiscordImageType.java | 66 - .../jna/enumuration/EDiscordInputModeType.java | 67 - .../jna/enumuration/EDiscordLobbySearchCast.java | 67 - .../enumuration/EDiscordLobbySearchComparison.java | 71 - .../enumuration/EDiscordLobbySearchDistance.java | 69 - .../gamesdk/jna/enumuration/EDiscordLobbyType.java | 67 - .../gamesdk/jna/enumuration/EDiscordLogLevel.java | 69 - .../jna/enumuration/EDiscordPremiumType.java | 68 - .../jna/enumuration/EDiscordRelationshipType.java | 71 - .../gamesdk/jna/enumuration/EDiscordResult.java | 109 -- .../gamesdk/jna/enumuration/EDiscordSkuType.java | 69 - .../gamesdk/jna/enumuration/EDiscordStatus.java | 69 - .../gamesdk/jna/enumuration/EDiscordUserFlag.java | 70 - .../jna/interfacestruct/GameSDKCallback.java | 30 - .../interfacestruct/IDiscordAchievementEvents.java | 40 - .../IDiscordAchievementManager.java | 58 - .../interfacestruct/IDiscordActivityEvents.java | 51 - .../interfacestruct/IDiscordActivityManager.java | 64 - .../IDiscordApplicationManager.java | 61 - .../gamesdk/jna/interfacestruct/IDiscordCore.java | 92 -- .../jna/interfacestruct/IDiscordImageManager.java | 54 - .../jna/interfacestruct/IDiscordLobbyEvents.java | 65 - .../jna/interfacestruct/IDiscordLobbyManager.java | 149 --- .../IDiscordLobbyMemberTransaction.java | 43 - .../interfacestruct/IDiscordLobbySearchQuery.java | 53 - .../interfacestruct/IDiscordLobbyTransaction.java | 58 - .../jna/interfacestruct/IDiscordNetworkEvents.java | 46 - .../interfacestruct/IDiscordNetworkManager.java | 66 - .../jna/interfacestruct/IDiscordOverlayEvents.java | 39 - .../interfacestruct/IDiscordOverlayManager.java | 57 - .../IDiscordRelationshipEvents.java | 43 - .../IDiscordRelationshipManager.java | 54 - .../interfacestruct/IDiscordStorageManager.java | 82 -- .../jna/interfacestruct/IDiscordStoreEvents.java | 44 - .../jna/interfacestruct/IDiscordStoreManager.java | 74 -- .../jna/interfacestruct/IDiscordUserEvents.java | 39 - .../jna/interfacestruct/IDiscordUserManager.java | 54 - .../jna/interfacestruct/IDiscordVoiceEvents.java | 40 - .../jna/interfacestruct/IDiscordVoiceManager.java | 73 -- .../gamesdk/jna/typedef/DiscordClientID.java | 30 - .../jna/typedef/DiscordNetworkChannelId.java | 30 - .../gamesdk/jna/typedef/DiscordNetworkPeerId.java | 30 - .../gamesdk/jna/typedef/DiscordSnowflake.java | 30 - .../gamesdk/jna/typedef/DiscordTimestamp.java | 30 - .../gamesdk/jna/typedef/DiscordVersion.java | 30 - .../dungeonsguide/gamesdk/jna/typedef/Int32.java | 31 - .../dungeonsguide/gamesdk/jna/typedef/Int64.java | 31 - .../dungeonsguide/gamesdk/jna/typedef/UInt32.java | 31 - .../dungeonsguide/gamesdk/jna/typedef/UInt64.java | 31 - .../dungeonsguide/gamesdk/jna/typedef/UInt8.java | 31 - .../java/kr/syeyoung/dungeonsguide/gui/MGui.java | 261 ---- .../java/kr/syeyoung/dungeonsguide/gui/MPanel.java | 296 ----- .../dungeonsguide/gui/elements/MButton.java | 117 -- .../dungeonsguide/gui/elements/MCollapsable.java | 138 -- .../dungeonsguide/gui/elements/MColor.java | 49 - .../gui/elements/MEditableAColor.java | 107 -- .../gui/elements/MFloatSelectionButton.java | 97 -- .../gui/elements/MIntegerSelectionButton.java | 95 -- .../dungeonsguide/gui/elements/MKeyEditButton.java | 148 --- .../dungeonsguide/gui/elements/MLabel.java | 72 - .../gui/elements/MLabelAndElement.java | 76 -- .../syeyoung/dungeonsguide/gui/elements/MList.java | 93 -- .../dungeonsguide/gui/elements/MModal.java | 92 -- .../gui/elements/MModalConfirmation.java | 87 -- .../dungeonsguide/gui/elements/MModalMessage.java | 77 -- .../gui/elements/MNavigatingPane.java | 214 --- .../gui/elements/MPanelScaledGUI.java | 214 --- .../dungeonsguide/gui/elements/MParameter.java | 91 -- .../gui/elements/MPassiveLabelAndElement.java | 71 - .../dungeonsguide/gui/elements/MPopupMenu.java | 103 -- .../gui/elements/MPortableColorEdit.java | 296 ----- .../dungeonsguide/gui/elements/MRootPanel.java | 60 - .../dungeonsguide/gui/elements/MScrollBar.java | 210 --- .../gui/elements/MScrollablePanel.java | 187 --- .../dungeonsguide/gui/elements/MSpacer.java | 36 - .../gui/elements/MStringSelectionButton.java | 94 -- .../dungeonsguide/gui/elements/MTabbedPane.java | 161 --- .../dungeonsguide/gui/elements/MTextField.java | 422 ------ .../dungeonsguide/gui/elements/MToggleButton.java | 97 -- .../dungeonsguide/gui/elements/MTooltip.java | 108 -- .../dungeonsguide/gui/elements/MTooltipText.java | 44 - .../dungeonsguide/gui/elements/MValue.java | 80 -- .../syeyoung/dungeonsguide/mod/DungeonsGuide.java | 260 ++++ .../kr/syeyoung/dungeonsguide/mod/Keybinds.java | 47 + .../syeyoung/dungeonsguide/mod/SkyblockStatus.java | 155 +++ .../dungeonsguide/mod/chat/ChatProcessResult.java | 31 + .../dungeonsguide/mod/chat/ChatProcessor.java | 118 ++ .../dungeonsguide/mod/chat/ChatSubscriber.java | 26 + .../dungeonsguide/mod/chat/ChatTransmitter.java | 69 + .../dungeonsguide/mod/commands/CommandDgDebug.java | 450 +++++++ .../mod/commands/CommandDungeonsGuide.java | 172 +++ .../dungeonsguide/mod/commands/CommandReparty.java | 104 ++ .../syeyoung/dungeonsguide/mod/config/Config.java | 65 + .../mod/config/guiconfig/ConfigPanelCreator.java | 40 + .../mod/config/guiconfig/GuiConfigV2.java | 59 + .../mod/config/guiconfig/MCategory.java | 103 ++ .../mod/config/guiconfig/MCategoryElement.java | 82 ++ .../mod/config/guiconfig/MFeature.java | 154 +++ .../mod/config/guiconfig/MFeatureEdit.java | 113 ++ .../mod/config/guiconfig/MNotFound.java | 38 + .../mod/config/guiconfig/MPanelCategory.java | 83 ++ .../mod/config/guiconfig/MParameterEdit.java | 219 ++++ .../mod/config/guiconfig/NestedCategory.java | 54 + .../mod/config/guiconfig/RootConfigPanel.java | 311 +++++ .../guiconfig/location/GuiGuiLocationConfig.java | 166 +++ .../mod/config/guiconfig/location/Marker.java | 45 + .../config/guiconfig/location/PanelDelegate.java | 403 ++++++ .../dungeonsguide/mod/config/types/AColor.java | 63 + .../mod/config/types/GUIRectangle.java | 81 ++ .../dungeonsguide/mod/config/types/TCAColor.java | 51 + .../dungeonsguide/mod/config/types/TCBoolean.java | 39 + .../dungeonsguide/mod/config/types/TCColor.java | 41 + .../dungeonsguide/mod/config/types/TCFloat.java | 39 + .../mod/config/types/TCGUIRectangle.java | 50 + .../dungeonsguide/mod/config/types/TCInteger.java | 39 + .../dungeonsguide/mod/config/types/TCKeybind.java | 39 + .../mod/config/types/TCRectangle.java | 51 + .../dungeonsguide/mod/config/types/TCString.java | 39 + .../mod/config/types/TCStringList.java | 51 + .../mod/config/types/TCTextStyle.java | 52 + .../mod/config/types/TCTextStyleList.java | 54 + .../mod/config/types/TypeConverter.java | 29 + .../mod/config/types/TypeConverterRegistry.java | 52 + .../mod/cosmetics/ActiveCosmetic.java | 12 + .../dungeonsguide/mod/cosmetics/CosmeticData.java | 14 + .../mod/cosmetics/CosmeticsManager.java | 288 ++++ .../mod/cosmetics/CustomNetworkPlayerInfo.java | 108 ++ .../mod/cosmetics/CustomPacketPlayerListItem.java | 38 + .../dungeonsguide/mod/cosmetics/IChatReplacer.java | 26 + .../chatreplacers/ChatReplacerChatByMe.java | 106 ++ .../cosmetics/chatreplacers/ChatReplacerCoop.java | 119 ++ .../chatreplacers/ChatReplacerMessage.java | 106 ++ .../cosmetics/chatreplacers/ChatReplacerPV.java | 119 ++ .../chatreplacers/ChatReplacerSocialOptions.java | 117 ++ .../chatreplacers/ChatReplacerViewProfile.java | 130 ++ .../dungeonsguide/mod/discord/gamesdk/GameSDK.java | 87 ++ .../mod/discord/gamesdk/jna/GameSDKTypeMapper.java | 46 + .../mod/discord/gamesdk/jna/NativeGameSDK.java | 50 + .../gamesdk/jna/datastruct/DiscordActivity.java | 50 + .../jna/datastruct/DiscordActivityAssets.java | 42 + .../jna/datastruct/DiscordActivityParty.java | 40 + .../jna/datastruct/DiscordActivitySecrets.java | 41 + .../jna/datastruct/DiscordActivityTimestamps.java | 40 + .../jna/datastruct/DiscordCreateParams.java | 72 + .../gamesdk/jna/datastruct/DiscordEntitlement.java | 42 + .../gamesdk/jna/datastruct/DiscordFileStat.java | 42 + .../jna/datastruct/DiscordImageDimensions.java | 40 + .../gamesdk/jna/datastruct/DiscordImageHandle.java | 43 + .../gamesdk/jna/datastruct/DiscordInputMode.java | 41 + .../gamesdk/jna/datastruct/DiscordLobby.java | 47 + .../gamesdk/jna/datastruct/DiscordOAuth2Token.java | 42 + .../gamesdk/jna/datastruct/DiscordPartySize.java | 40 + .../gamesdk/jna/datastruct/DiscordPresence.java | 40 + .../jna/datastruct/DiscordRelationship.java | 41 + .../discord/gamesdk/jna/datastruct/DiscordSku.java | 44 + .../gamesdk/jna/datastruct/DiscordSkuPrice.java | 41 + .../gamesdk/jna/datastruct/DiscordStruct.java | 35 + .../gamesdk/jna/datastruct/DiscordUser.java | 43 + .../jna/datastruct/DiscordUserAchievement.java | 44 + .../enumuration/EDiscordActivityActionType.java | 67 + .../EDiscordActivityJoinRequestReply.java | 68 + .../jna/enumuration/EDiscordActivityType.java | 69 + .../jna/enumuration/EDiscordCreateFlags.java | 67 + .../jna/enumuration/EDiscordEntitlementType.java | 72 + .../gamesdk/jna/enumuration/EDiscordImageType.java | 66 + .../jna/enumuration/EDiscordInputModeType.java | 67 + .../jna/enumuration/EDiscordLobbySearchCast.java | 67 + .../enumuration/EDiscordLobbySearchComparison.java | 71 + .../enumuration/EDiscordLobbySearchDistance.java | 69 + .../gamesdk/jna/enumuration/EDiscordLobbyType.java | 67 + .../gamesdk/jna/enumuration/EDiscordLogLevel.java | 69 + .../jna/enumuration/EDiscordPremiumType.java | 68 + .../jna/enumuration/EDiscordRelationshipType.java | 71 + .../gamesdk/jna/enumuration/EDiscordResult.java | 109 ++ .../gamesdk/jna/enumuration/EDiscordSkuType.java | 69 + .../gamesdk/jna/enumuration/EDiscordStatus.java | 69 + .../gamesdk/jna/enumuration/EDiscordUserFlag.java | 70 + .../jna/interfacestruct/GameSDKCallback.java | 30 + .../interfacestruct/IDiscordAchievementEvents.java | 39 + .../IDiscordAchievementManager.java | 57 + .../interfacestruct/IDiscordActivityEvents.java | 50 + .../interfacestruct/IDiscordActivityManager.java | 63 + .../IDiscordApplicationManager.java | 60 + .../gamesdk/jna/interfacestruct/IDiscordCore.java | 91 ++ .../jna/interfacestruct/IDiscordImageManager.java | 52 + .../jna/interfacestruct/IDiscordLobbyEvents.java | 64 + .../jna/interfacestruct/IDiscordLobbyManager.java | 148 +++ .../IDiscordLobbyMemberTransaction.java | 42 + .../interfacestruct/IDiscordLobbySearchQuery.java | 52 + .../interfacestruct/IDiscordLobbyTransaction.java | 57 + .../jna/interfacestruct/IDiscordNetworkEvents.java | 45 + .../interfacestruct/IDiscordNetworkManager.java | 65 + .../jna/interfacestruct/IDiscordOverlayEvents.java | 38 + .../interfacestruct/IDiscordOverlayManager.java | 56 + .../IDiscordRelationshipEvents.java | 42 + .../IDiscordRelationshipManager.java | 53 + .../interfacestruct/IDiscordStorageManager.java | 81 ++ .../jna/interfacestruct/IDiscordStoreEvents.java | 43 + .../jna/interfacestruct/IDiscordStoreManager.java | 73 ++ .../jna/interfacestruct/IDiscordUserEvents.java | 38 + .../jna/interfacestruct/IDiscordUserManager.java | 53 + .../jna/interfacestruct/IDiscordVoiceEvents.java | 39 + .../jna/interfacestruct/IDiscordVoiceManager.java | 72 + .../gamesdk/jna/typedef/DiscordClientID.java | 28 + .../jna/typedef/DiscordNetworkChannelId.java | 28 + .../gamesdk/jna/typedef/DiscordNetworkPeerId.java | 28 + .../gamesdk/jna/typedef/DiscordSnowflake.java | 28 + .../gamesdk/jna/typedef/DiscordTimestamp.java | 28 + .../gamesdk/jna/typedef/DiscordVersion.java | 28 + .../mod/discord/gamesdk/jna/typedef/Int32.java | 31 + .../mod/discord/gamesdk/jna/typedef/Int64.java | 31 + .../mod/discord/gamesdk/jna/typedef/UInt32.java | 31 + .../mod/discord/gamesdk/jna/typedef/UInt64.java | 31 + .../mod/discord/gamesdk/jna/typedef/UInt8.java | 31 + .../mod/discord/rpc/JDiscordActivity.java | 72 + .../mod/discord/rpc/JDiscordRelation.java | 42 + .../mod/discord/rpc/JDiscordUser.java | 40 + .../mod/discord/rpc/RichPresenceManager.java | 251 ++++ .../mod/dungeon/DungeonActionContext.java | 35 + .../dungeonsguide/mod/dungeon/DungeonContext.java | 218 ++++ .../dungeonsguide/mod/dungeon/DungeonFacade.java | 35 + .../dungeonsguide/mod/dungeon/MapProcessor.java | 535 ++++++++ .../mod/dungeon/actions/AbstractAction.java | 61 + .../dungeon/actions/ActionBreakWithSuperBoom.java | 103 ++ .../mod/dungeon/actions/ActionChangeState.java | 75 ++ .../mod/dungeon/actions/ActionClick.java | 82 ++ .../mod/dungeon/actions/ActionClickSet.java | 90 ++ .../mod/dungeon/actions/ActionComplete.java | 41 + .../mod/dungeon/actions/ActionDropItem.java | 82 ++ .../mod/dungeon/actions/ActionInteract.java | 89 ++ .../mod/dungeon/actions/ActionKill.java | 90 ++ .../mod/dungeon/actions/ActionMove.java | 122 ++ .../mod/dungeon/actions/ActionMoveNearestAir.java | 92 ++ .../mod/dungeon/actions/ActionRoot.java | 47 + .../mod/dungeon/actions/tree/ActionRoute.java | 136 ++ .../actions/tree/ActionRouteProperties.java | 16 + .../mod/dungeon/actions/tree/ActionTree.java | 94 ++ .../mod/dungeon/actions/tree/ActionTreeUtil.java | 83 ++ .../mod/dungeon/doorfinder/DungeonDoor.java | 87 ++ .../doorfinder/DungeonSpecificDataProvider.java | 39 + .../DungeonSpecificDataProviderRegistry.java | 42 + .../mod/dungeon/doorfinder/EDungeonDoorType.java | 38 + .../catacombs/CatacombsDataProvider.java | 75 ++ .../catacombs/impl/MasterModeDataProvider.java | 64 + .../catacombs/impl/NormalModeDataProvider.java | 101 ++ .../mod/dungeon/events/DungeonEvent.java | 41 + .../mod/dungeon/events/DungeonEventData.java | 25 + .../mod/dungeon/events/DungeonEventHolder.java | 32 + .../mod/dungeon/events/SerializableBlockPos.java | 38 + .../events/impl/DungeonCryptBrokenEvent.java | 35 + .../mod/dungeon/events/impl/DungeonDeathEvent.java | 36 + .../dungeon/events/impl/DungeonMapUpdateEvent.java | 34 + .../dungeon/events/impl/DungeonNodataEvent.java | 29 + .../events/impl/DungeonPuzzleFailureEvent.java | 34 + .../events/impl/DungeonRoomDiscoverEvent.java | 46 + .../events/impl/DungeonSecretCountChangeEvent.java | 37 + .../events/impl/DungeonStateChangeEvent.java | 40 + .../mod/dungeon/map/DungeonMapData.java | 121 ++ .../mod/dungeon/pathfinding/AStarCornerCut.java | 189 +++ .../mod/dungeon/pathfinding/AStarFineGrid.java | 182 +++ .../mod/dungeon/pathfinding/CachedWorld.java | 85 ++ .../mod/dungeon/pathfinding/JPSPathfinder.java | 306 +++++ .../pathfinding/NodeProcessorDungeonRoom.java | 144 ++ .../mod/dungeon/pathfinding/ThetaStar.java | 209 +++ .../mod/dungeon/roomedit/EditingContext.java | 83 ++ .../mod/dungeon/roomedit/Parameter.java | 39 + .../mod/dungeon/roomedit/gui/GuiDungeonAddSet.java | 136 ++ .../roomedit/gui/GuiDungeonParameterEdit.java | 173 +++ .../dungeon/roomedit/gui/GuiDungeonRoomEdit.java | 68 + .../dungeon/roomedit/gui/GuiDungeonValueEdit.java | 127 ++ .../mechanicedit/ValueEditBreakableWall.java | 143 ++ .../roomedit/mechanicedit/ValueEditDoor.java | 157 +++ .../roomedit/mechanicedit/ValueEditDummy.java | 121 ++ .../roomedit/mechanicedit/ValueEditFairySoul.java | 118 ++ .../roomedit/mechanicedit/ValueEditJournal.java | 122 ++ .../roomedit/mechanicedit/ValueEditLever.java | 133 ++ .../roomedit/mechanicedit/ValueEditNPC.java | 121 ++ .../roomedit/mechanicedit/ValueEditOnewayDoor.java | 143 ++ .../mechanicedit/ValueEditOnewayLever.java | 137 ++ .../mechanicedit/ValueEditPressurePlate.java | 136 ++ .../roomedit/mechanicedit/ValueEditSecret.java | 129 ++ .../roomedit/mechanicedit/ValueEditTomb.java | 118 ++ .../dungeon/roomedit/panes/ActionDisplayPane.java | 82 ++ .../roomedit/panes/ActionTreeDisplayPane.java | 216 +++ .../mod/dungeon/roomedit/panes/DynamicEditor.java | 29 + .../dungeon/roomedit/panes/GeneralEditPane.java | 286 ++++ .../roomedit/panes/ProcessorParameterEditPane.java | 144 ++ .../roomedit/panes/RoomDataDisplayPane.java | 126 ++ .../roomedit/panes/RoomMatchDisplayPane.java | 152 +++ .../dungeon/roomedit/panes/RoommatchingPane.java | 84 ++ .../mod/dungeon/roomedit/panes/SecretEditPane.java | 156 +++ .../mod/dungeon/roomedit/valueedit/ValueEdit.java | 27 + .../roomedit/valueedit/ValueEditAColor.java | 339 +++++ .../roomedit/valueedit/ValueEditBoolean.java | 101 ++ .../dungeon/roomedit/valueedit/ValueEditColor.java | 287 ++++ .../roomedit/valueedit/ValueEditCreator.java | 29 + .../dungeon/roomedit/valueedit/ValueEditFloat.java | 99 ++ .../roomedit/valueedit/ValueEditInteger.java | 99 ++ .../dungeon/roomedit/valueedit/ValueEditNull.java | 38 + .../roomedit/valueedit/ValueEditOffsetPoint.java | 163 +++ .../valueedit/ValueEditOffsetPointSet.java | 250 ++++ .../roomedit/valueedit/ValueEditRegistry.java | 70 + .../roomedit/valueedit/ValueEditString.java | 99 ++ .../mod/dungeon/roomfinder/DungeonRoom.java | 381 ++++++ .../roomfinder/DungeonRoomInfoRegistry.java | 163 +++ .../mod/dungeon/roomfinder/RoomMatcher.java | 145 +++ .../roomprocessor/GeneralRoomProcessor.java | 448 +++++++ .../dungeon/roomprocessor/ProcessorFactory.java | 65 + .../mod/dungeon/roomprocessor/RoomProcessor.java | 49 + .../roomprocessor/RoomProcessorBlazeSolver.java | 201 +++ .../roomprocessor/RoomProcessorButtonSolver.java | 132 ++ .../roomprocessor/RoomProcessorCreeperSolver.java | 148 +++ .../roomprocessor/RoomProcessorGenerator.java | 25 + .../roomprocessor/RoomProcessorIcePath.java | 234 ++++ .../roomprocessor/RoomProcessorRedRoom.java | 121 ++ .../dungeon/roomprocessor/RoomProcessorRiddle.java | 121 ++ .../RoomProcessorTeleportMazeSolver.java | 145 +++ .../RoomProcessorTicTacToeSolver.java | 214 +++ .../dungeon/roomprocessor/RoomProcessorTrivia.java | 165 +++ .../bombdefuse/RoomProcessorBombDefuseSolver.java | 441 +++++++ .../bombdefuse/chambers/BDChamber.java | 83 ++ .../chambers/BombDefuseChamberGenerator.java | 30 + .../bombdefuse/chambers/ChamberProcessor.java | 27 + .../chambers/DummyDefuseChamberProcessor.java | 32 + .../chambers/GeneralDefuseChamberProcessor.java | 137 ++ .../chambers/arrow/ArrowLeftProcessor.java | 138 ++ .../chambers/arrow/ArrowProcessorMatcher.java | 52 + .../chambers/arrow/ArrowRightProcessor.java | 126 ++ .../chambers/bugged/ImpossibleMatcher.java | 47 + .../chambers/color/ColorLeftProcessor.java | 230 ++++ .../chambers/color/ColorProcessorMatcher.java | 49 + .../chambers/color/ColorRightProcessor.java | 175 +++ .../chambers/creeper/CreeperLeftProcessor.java | 95 ++ .../chambers/creeper/CreeperProcessorMatcher.java | 52 + .../chambers/creeper/CreeperRightProcessor.java | 73 ++ .../goldenpath/GoldenPathLeftProcessor.java | 141 ++ .../goldenpath/GoldenPathProcessorMatcher.java | 47 + .../goldenpath/GoldenPathRightProcessor.java | 97 ++ .../chambers/maze/MazeLeftProcessor.java | 80 ++ .../chambers/maze/MazeProcessorMatcher.java | 47 + .../chambers/maze/MazeRightProcessor.java | 73 ++ .../chambers/number/NumberLeftProcessor.java | 125 ++ .../chambers/number/NumberProcessorMatcher.java | 53 + .../chambers/number/NumberRightProcessor.java | 114 ++ .../bossfight/BossfightProcessor.java | 33 + .../bossfight/BossfightProcessorBonzo.java | 85 ++ .../bossfight/BossfightProcessorLivid.java | 90 ++ .../bossfight/BossfightProcessorNecron.java | 77 ++ .../bossfight/BossfightProcessorProf.java | 144 ++ .../bossfight/BossfightProcessorSadan.java | 144 ++ .../bossfight/BossfightProcessorScarf.java | 134 ++ .../bossfight/BossfightProcessorThorn.java | 103 ++ .../bossfight/GeneralBossfightProcessor.java | 155 +++ .../roomprocessor/bossfight/HealthData.java | 33 + .../boxpuzzle/BoxPuzzleSolvingThread.java | 182 +++ .../boxpuzzle/RoomProcessorBoxSolver.java | 392 ++++++ .../icefill/RoomProcessorIcePath2.java | 151 +++ .../roomprocessor/waterpuzzle/LeverState.java | 33 + .../waterpuzzle/LeverStateContradict.java | 25 + .../waterpuzzle/RoomProcessorWaterPuzzle.java | 124 ++ .../dungeon/roomprocessor/waterpuzzle/Route.java | 60 + .../roomprocessor/waterpuzzle/SwitchData.java | 46 + .../roomprocessor/waterpuzzle/WaterBoard.java | 424 ++++++ .../roomprocessor/waterpuzzle/WaterNode.java | 36 + .../waterpuzzle/nodes/WaterNodeAir.java | 59 + .../waterpuzzle/nodes/WaterNodeEnd.java | 60 + .../waterpuzzle/nodes/WaterNodeStart.java | 66 + .../waterpuzzle/nodes/WaterNodeToggleable.java | 71 + .../waterpuzzle/nodes/WaterNodeWall.java | 62 + .../mod/events/impl/AuthChangedEvent.java | 6 + .../mod/events/impl/BlockUpdateEvent.java | 37 + .../mod/events/impl/BossroomEnterEvent.java | 24 + .../events/impl/DiscordUserJoinRequestEvent.java | 33 + .../mod/events/impl/DiscordUserUpdateEvent.java | 32 + .../impl/DungeonContextInitializationEvent.java | 24 + .../mod/events/impl/DungeonEndedEvent.java | 24 + .../mod/events/impl/DungeonLeftEvent.java | 24 + .../mod/events/impl/DungeonStartedEvent.java | 24 + .../mod/events/impl/HypixelJoinedEvent.java | 24 + .../mod/events/impl/KeyBindPressedEvent.java | 31 + .../mod/events/impl/PlayerInteractEntityEvent.java | 39 + .../mod/events/impl/PlayerListItemPacketEvent.java | 32 + .../mod/events/impl/SkyblockJoinedEvent.java | 24 + .../mod/events/impl/SkyblockLeftEvent.java | 24 + .../mod/events/impl/StompConnectedEvent.java | 32 + .../dungeonsguide/mod/events/impl/TitleEvent.java | 32 + .../mod/events/impl/WindowUpdateEvent.java | 34 + .../mod/events/listener/DungeonListener.java | 513 ++++++++ .../mod/events/listener/FeatureListener.java | 512 ++++++++ .../mod/events/listener/PacketListener.java | 191 +++ .../mod/features/AbstractFeature.java | 114 ++ .../mod/features/FeatureParameter.java | 72 + .../mod/features/FeatureRegistry.java | 337 +++++ .../dungeonsguide/mod/features/GuiFeature.java | 160 +++ .../dungeonsguide/mod/features/SimpleFeature.java | 33 + .../mod/features/impl/advanced/FeatureDebug.java | 31 + .../features/impl/advanced/FeatureDebugTrap.java | 80 ++ .../impl/advanced/FeatureDebuggableMap.java | 88 ++ .../impl/advanced/FeatureRoomCoordDisplay.java | 94 ++ .../impl/advanced/FeatureRoomDebugInfo.java | 95 ++ .../features/impl/advanced/FeatureTestPepole.java | 460 +++++++ .../mod/features/impl/boss/FeatureAutoReparty.java | 34 + .../mod/features/impl/boss/FeatureBossHealth.java | 104 ++ .../features/impl/boss/FeatureBoxRealLivid.java | 54 + .../mod/features/impl/boss/FeatureChestPrice.java | 174 +++ .../features/impl/boss/FeatureCurrentPhase.java | 74 ++ .../mod/features/impl/boss/FeatureHideAnimals.java | 76 ++ .../features/impl/boss/FeatureTerracotaTimer.java | 77 ++ .../impl/boss/FeatureThornBearPercentage.java | 78 ++ .../impl/boss/FeatureThornSpiritBowTimer.java | 110 ++ .../features/impl/boss/FeatureWarningOnPortal.java | 200 +++ .../terminal/CorrectThePaneSolutionProvider.java | 53 + .../impl/boss/terminal/FeatureSimonSaysSolver.java | 113 ++ .../impl/boss/terminal/FeatureTerminalSolvers.java | 153 +++ .../terminal/NavigateMazeSolutionProvider.java | 144 ++ .../terminal/SelectAllColorSolutionProivider.java | 60 + .../terminal/SelectInOrderSolutionProvider.java | 72 + .../impl/boss/terminal/TerminalSolution.java | 30 + .../boss/terminal/TerminalSolutionProvider.java | 29 + .../terminal/WhatStartsWithSolutionProvider.java | 50 + .../impl/cosmetics/FeatureNicknameColor.java | 49 + .../impl/cosmetics/FeatureNicknamePrefix.java | 49 + .../features/impl/cosmetics/PrefixSelectorGUI.java | 188 +++ .../impl/discord/inviteViewer/ImageTexture.java | 118 ++ .../discord/inviteViewer/PartyInviteViewer.java | 314 +++++ .../discord/inviteViewer/PartyJoinRequest.java | 59 + .../impl/discord/invteTooltip/MTooltipInvite.java | 127 ++ .../invteTooltip/MTooltipInviteElement.java | 109 ++ .../impl/discord/onlinealarm/PlayingDGAlarm.java | 170 +++ .../mod/features/impl/dungeon/FeatureBoxBats.java | 68 + .../impl/dungeon/FeatureBoxSkelemaster.java | 68 + .../features/impl/dungeon/FeatureBoxStarMobs.java | 68 + .../features/impl/dungeon/FeatureCollectScore.java | 77 ++ .../dungeon/FeatureDungeonCurrentRoomSecrets.java | 108 ++ .../impl/dungeon/FeatureDungeonDeaths.java | 168 +++ .../features/impl/dungeon/FeatureDungeonMap.java | 508 ++++++++ .../impl/dungeon/FeatureDungeonMilestone.java | 110 ++ .../impl/dungeon/FeatureDungeonRealTime.java | 91 ++ .../impl/dungeon/FeatureDungeonRoomName.java | 95 ++ .../impl/dungeon/FeatureDungeonSBTime.java | 119 ++ .../features/impl/dungeon/FeatureDungeonScore.java | 351 +++++ .../impl/dungeon/FeatureDungeonSecrets.java | 145 +++ .../features/impl/dungeon/FeatureDungeonTombs.java | 88 ++ .../features/impl/dungeon/FeatureHideNameTags.java | 53 + .../features/impl/dungeon/FeaturePlayerESP.java | 111 ++ .../dungeon/FeaturePressAnyKeyToCloseChest.java | 89 ++ .../impl/dungeon/FeatureWarnLowHealth.java | 106 ++ .../impl/dungeon/FeatureWatcherWarning.java | 87 ++ .../impl/etc/FeatureAutoAcceptReparty.java | 68 + .../features/impl/etc/FeatureCooldownCounter.java | 96 ++ .../mod/features/impl/etc/FeatureCopyMessages.java | 42 + .../impl/etc/FeatureDecreaseExplosionSound.java | 52 + .../features/impl/etc/FeatureDisableMessage.java | 77 ++ .../features/impl/etc/FeatureEpicCountdown.java | 156 +++ .../mod/features/impl/etc/FeaturePenguins.java | 168 +++ .../features/impl/etc/FeatureRepartyCommand.java | 29 + .../impl/etc/FeatureTooltipDungeonStat.java | 52 + .../mod/features/impl/etc/FeatureTooltipPrice.java | 111 ++ .../mod/features/impl/etc/FeatureUpdateAlarm.java | 56 + .../impl/etc/ability/FeatureAbilityCooldown.java | 402 ++++++ .../features/impl/etc/ability/SkyblockAbility.java | 32 + .../mod/features/impl/etc/ability/UsedAbility.java | 31 + .../mod/features/impl/party/APIKey.java | 56 + .../features/impl/party/FeatureGoodParties.java | 121 ++ .../mod/features/impl/party/FeaturePartyList.java | 97 ++ .../mod/features/impl/party/FeaturePartyReady.java | 180 +++ .../party/customgui/FeatureCustomPartyFinder.java | 110 ++ .../impl/party/customgui/GuiCustomPartyFinder.java | 75 ++ .../impl/party/customgui/PanelPartyFinder.java | 341 +++++ .../party/customgui/PanelPartyFinderSettings.java | 293 +++++ .../party/customgui/PanelPartyListElement.java | 236 ++++ .../impl/party/playerpreview/FakePlayer.java | 101 ++ .../FeatureViewPlayerStatsOnJoin.java | 706 ++++++++++ .../impl/party/playerpreview/api/ApiFetcher.java | 387 ++++++ .../impl/party/playerpreview/api/CachedData.java | 29 + .../playerpreview/api/PlayerSkyblockData.java | 10 + .../impl/party/playerpreview/api/SkinFetcher.java | 90 ++ .../api/playerprofile/PlayerProfile.java | 92 ++ .../api/playerprofile/PlayerProfileParser.java | 449 +++++++ .../dataclasses/ClassSpecificData.java | 29 + .../playerprofile/dataclasses/DungeonClass.java | 46 + .../dataclasses/DungeonSpecificData.java | 29 + .../api/playerprofile/dataclasses/DungeonStat.java | 54 + .../api/playerprofile/dataclasses/DungeonType.java | 39 + .../dataclasses/FloorSpecificData.java | 29 + .../api/playerprofile/dataclasses/Pet.java | 31 + .../api/playerprofile/dataclasses/Skill.java | 31 + .../datarenders/DataRendererEditor.java | 357 +++++ .../datarenders/DataRendererRegistry.java | 64 + .../playerpreview/datarenders/IDataRenderer.java | 33 + .../impl/DataRenderDungeonFloorStat.java | 105 ++ .../impl/DataRenderDungeonHighestFloorStat.java | 107 ++ .../datarenders/impl/DataRendererClassLv.java | 88 ++ .../datarenders/impl/DataRendererDungeonLv.java | 82 ++ .../datarenders/impl/DataRendererFairySouls.java | 50 + .../datarenders/impl/DataRendererLilyWeight.java | 71 + .../datarenders/impl/DataRendererSecrets.java | 53 + .../impl/DataRendererSelectedClassLv.java | 77 ++ .../datarenders/impl/DataRendererSetUrOwn.java | 57 + .../datarenders/impl/DataRendererSkillLv.java | 80 ++ .../datarenders/impl/DataRendererTalismans.java | 123 ++ .../mod/features/impl/secret/FeatureActions.java | 143 ++ .../mod/features/impl/secret/FeatureBloodRush.java | 45 + .../impl/secret/FeatureCreateRefreshLine.java | 69 + .../impl/secret/FeatureFreezePathfind.java | 45 + .../impl/secret/FeaturePathfindStrategy.java | 106 ++ .../features/impl/secret/FeaturePathfindToAll.java | 45 + .../impl/secret/FeatureSoulRoomWarning.java | 232 ++++ .../impl/secret/FeatureTogglePathfind.java | 45 + .../impl/secret/PathfindLineProperties.java | 115 ++ .../mechanicbrowser/FeatureMechanicBrowse.java | 164 +++ .../mechanicbrowser/MGuiMechanicBrowser.java | 45 + .../mechanicbrowser/MechanicBrowserElement.java | 61 + .../mechanicbrowser/MechanicBrowserTooltip.java | 68 + .../mechanicbrowser/PanelMechanicBrowser.java | 343 +++++ .../features/impl/solvers/FeatureSolverBlaze.java | 51 + .../impl/solvers/FeatureSolverBombdefuse.java | 30 + .../features/impl/solvers/FeatureSolverBox.java | 57 + .../impl/solvers/FeatureSolverIcefill.java | 40 + .../features/impl/solvers/FeatureSolverKahoot.java | 35 + .../features/impl/solvers/FeatureSolverRiddle.java | 35 + .../impl/solvers/FeatureSolverSilverfish.java | 44 + .../impl/solvers/FeatureSolverTeleport.java | 39 + .../impl/solvers/FeatureSolverTictactoe.java | 39 + .../features/listener/BossroomEnterListener.java | 23 + .../mod/features/listener/ChatListener.java | 25 + .../mod/features/listener/ChatListenerGlobal.java | 25 + .../listener/DiscordUserJoinRequestListener.java | 25 + .../listener/DiscordUserUpdateListener.java | 25 + .../DungeonContextInitializationListener.java | 23 + .../mod/features/listener/DungeonEndListener.java | 23 + .../mod/features/listener/DungeonQuitListener.java | 23 + .../features/listener/DungeonStartListener.java | 23 + .../listener/EntityLivingRenderListener.java | 26 + .../listener/GuiBackgroundRenderListener.java | 25 + .../mod/features/listener/GuiClickListener.java | 25 + .../mod/features/listener/GuiOpenListener.java | 25 + .../features/listener/GuiPostRenderListener.java | 25 + .../features/listener/GuiPreRenderListener.java | 25 + .../mod/features/listener/GuiUpdateListener.java | 25 + .../mod/features/listener/InteractListener.java | 25 + .../mod/features/listener/KeyInputListener.java | 25 + .../features/listener/KeybindPressedListener.java | 25 + .../features/listener/PlayerRenderListener.java | 26 + .../features/listener/ScreenRenderListener.java | 23 + .../features/listener/SkyblockJoinListener.java | 23 + .../features/listener/SkyblockLeaveListener.java | 23 + .../mod/features/listener/SoundListener.java | 25 + .../features/listener/StompConnectedListener.java | 25 + .../features/listener/TextureStichListener.java | 25 + .../mod/features/listener/TickListener.java | 23 + .../mod/features/listener/TitleListener.java | 25 + .../mod/features/listener/TooltipListener.java | 25 + .../mod/features/listener/WorldRenderListener.java | 23 + .../features/text/PanelTextParameterConfig.java | 283 ++++ .../mod/features/text/StyledText.java | 29 + .../mod/features/text/StyledTextProvider.java | 30 + .../mod/features/text/StyledTextRenderer.java | 244 ++++ .../mod/features/text/TextHUDFeature.java | 191 +++ .../dungeonsguide/mod/features/text/TextStyle.java | 34 + .../kr/syeyoung/dungeonsguide/mod/gui/MGui.java | 247 ++++ .../kr/syeyoung/dungeonsguide/mod/gui/MPanel.java | 296 +++++ .../dungeonsguide/mod/gui/elements/MButton.java | 117 ++ .../mod/gui/elements/MCollapsable.java | 137 ++ .../dungeonsguide/mod/gui/elements/MColor.java | 48 + .../mod/gui/elements/MEditableAColor.java | 106 ++ .../mod/gui/elements/MFloatSelectionButton.java | 97 ++ .../mod/gui/elements/MIntegerSelectionButton.java | 95 ++ .../mod/gui/elements/MKeyEditButton.java | 147 +++ .../dungeonsguide/mod/gui/elements/MLabel.java | 72 + .../mod/gui/elements/MLabelAndElement.java | 75 ++ .../dungeonsguide/mod/gui/elements/MList.java | 93 ++ .../dungeonsguide/mod/gui/elements/MModal.java | 92 ++ .../mod/gui/elements/MModalConfirmation.java | 87 ++ .../mod/gui/elements/MModalMessage.java | 77 ++ .../mod/gui/elements/MNavigatingPane.java | 213 +++ .../mod/gui/elements/MPanelScaledGUI.java | 213 +++ .../dungeonsguide/mod/gui/elements/MParameter.java | 90 ++ .../mod/gui/elements/MPassiveLabelAndElement.java | 71 + .../dungeonsguide/mod/gui/elements/MPopupMenu.java | 97 ++ .../mod/gui/elements/MPortableColorEdit.java | 292 +++++ .../dungeonsguide/mod/gui/elements/MRootPanel.java | 60 + .../dungeonsguide/mod/gui/elements/MScrollBar.java | 209 +++ .../mod/gui/elements/MScrollablePanel.java | 185 +++ .../dungeonsguide/mod/gui/elements/MSpacer.java | 36 + .../mod/gui/elements/MStringSelectionButton.java | 94 ++ .../mod/gui/elements/MTabbedPane.java | 160 +++ .../dungeonsguide/mod/gui/elements/MTextField.java | 418 ++++++ .../mod/gui/elements/MToggleButton.java | 96 ++ .../dungeonsguide/mod/gui/elements/MTooltip.java | 107 ++ .../mod/gui/elements/MTooltipText.java | 44 + .../dungeonsguide/mod/gui/elements/MValue.java | 79 ++ .../dungeonsguide/mod/party/PartyContext.java | 102 ++ .../dungeonsguide/mod/party/PartyManager.java | 626 +++++++++ .../dungeonsguide/mod/resources/DGTexturePack.java | 71 + .../mod/stomp/FailedWebSocketConnection.java | 7 + .../dungeonsguide/mod/stomp/StompClient.java | 192 +++ .../dungeonsguide/mod/stomp/StompDiedEvent.java | 15 + .../dungeonsguide/mod/stomp/StompHeader.java | 24 + .../dungeonsguide/mod/stomp/StompManager.java | 73 ++ .../dungeonsguide/mod/stomp/StompPayload.java | 96 ++ .../dungeonsguide/mod/stomp/StompSubscription.java | 6 + .../syeyoung/dungeonsguide/mod/utils/AhUtils.java | 98 ++ .../dungeonsguide/mod/utils/ArrayUtils.java | 40 + .../dungeonsguide/mod/utils/BlockCache.java | 50 + .../dungeonsguide/mod/utils/GlStateUtils.java | 68 + .../syeyoung/dungeonsguide/mod/utils/MapUtils.java | 176 +++ .../dungeonsguide/mod/utils/RenderUtils.java | 1372 +++++++++++++++++++ .../dungeonsguide/mod/utils/ScoreBoardUtils.java | 58 + .../dungeonsguide/mod/utils/ShortUtils.java | 47 + .../dungeonsguide/mod/utils/SkyblockUtils.java | 52 + .../dungeonsguide/mod/utils/TabListUtil.java | 75 ++ .../dungeonsguide/mod/utils/TextUtils.java | 121 ++ .../dungeonsguide/mod/utils/TimeScoreUtil.java | 82 ++ .../dungeonsguide/mod/utils/TitleRender.java | 139 ++ .../dungeonsguide/mod/utils/VectorUtils.java | 51 + .../syeyoung/dungeonsguide/mod/utils/XPUtils.java | 222 ++++ .../mod/utils/cursor/CursorReader.java | 95 ++ .../dungeonsguide/mod/utils/cursor/EnumCursor.java | 54 + .../dungeonsguide/mod/utils/cursor/Foundation.java | 33 + .../dungeonsguide/mod/utils/cursor/GLCursors.java | 231 ++++ .../dungeonsguide/mod/utils/cursor/User32.java | 67 + .../dungeonsguide/mod/utils/cursor/X11.java | 37 + .../mod/wsresource/StaticResource.java | 30 + .../mod/wsresource/StaticResourceCache.java | 77 ++ .../dungeonsguide/pathfinding/AStarCornerCut.java | 189 --- .../dungeonsguide/pathfinding/AStarFineGrid.java | 182 --- .../dungeonsguide/pathfinding/CachedWorld.java | 97 -- .../dungeonsguide/pathfinding/JPSPathfinder.java | 311 ----- .../pathfinding/NodeProcessorDungeonRoom.java | 142 -- .../dungeonsguide/pathfinding/ThetaStar.java | 211 --- .../dungeonsguide/resources/DGTexturePack.java | 72 - .../dungeonsguide/roomedit/EditingContext.java | 87 -- .../syeyoung/dungeonsguide/roomedit/Parameter.java | 40 - .../roomedit/gui/GuiDungeonAddSet.java | 143 -- .../roomedit/gui/GuiDungeonParameterEdit.java | 179 --- .../roomedit/gui/GuiDungeonRoomEdit.java | 75 -- .../roomedit/gui/GuiDungeonValueEdit.java | 133 -- .../mechanicedit/ValueEditBreakableWall.java | 143 -- .../roomedit/mechanicedit/ValueEditDoor.java | 157 --- .../roomedit/mechanicedit/ValueEditDummy.java | 122 -- .../roomedit/mechanicedit/ValueEditFairySoul.java | 119 -- .../roomedit/mechanicedit/ValueEditJournal.java | 123 -- .../roomedit/mechanicedit/ValueEditLever.java | 133 -- .../roomedit/mechanicedit/ValueEditNPC.java | 123 -- .../roomedit/mechanicedit/ValueEditOnewayDoor.java | 143 -- .../mechanicedit/ValueEditOnewayLever.java | 137 -- .../mechanicedit/ValueEditPressurePlate.java | 136 -- .../roomedit/mechanicedit/ValueEditSecret.java | 129 -- .../roomedit/mechanicedit/ValueEditTomb.java | 118 -- .../roomedit/panes/ActionDisplayPane.java | 82 -- .../roomedit/panes/ActionTreeDisplayPane.java | 217 --- .../roomedit/panes/DynamicEditor.java | 29 - .../roomedit/panes/GeneralEditPane.java | 285 ---- .../roomedit/panes/ProcessorParameterEditPane.java | 144 -- .../roomedit/panes/RoomDataDisplayPane.java | 127 -- .../roomedit/panes/RoomMatchDisplayPane.java | 152 --- .../roomedit/panes/RoommatchingPane.java | 84 -- .../roomedit/panes/SecretEditPane.java | 156 --- .../roomedit/valueedit/ValueEdit.java | 27 - .../roomedit/valueedit/ValueEditAColor.java | 339 ----- .../roomedit/valueedit/ValueEditBoolean.java | 101 -- .../roomedit/valueedit/ValueEditColor.java | 287 ---- .../roomedit/valueedit/ValueEditCreator.java | 29 - .../roomedit/valueedit/ValueEditFloat.java | 99 -- .../roomedit/valueedit/ValueEditInteger.java | 99 -- .../roomedit/valueedit/ValueEditNull.java | 38 - .../roomedit/valueedit/ValueEditOffsetPoint.java | 163 --- .../valueedit/ValueEditOffsetPointSet.java | 250 ---- .../roomedit/valueedit/ValueEditRegistry.java | 70 - .../roomedit/valueedit/ValueEditString.java | 99 -- .../roomprocessor/GeneralRoomProcessor.java | 448 ------- .../roomprocessor/ProcessorFactory.java | 65 - .../dungeonsguide/roomprocessor/RoomProcessor.java | 49 - .../roomprocessor/RoomProcessorBlazeSolver.java | 216 --- .../roomprocessor/RoomProcessorButtonSolver.java | 133 -- .../roomprocessor/RoomProcessorCreeperSolver.java | 153 --- .../roomprocessor/RoomProcessorGenerator.java | 25 - .../roomprocessor/RoomProcessorIcePath.java | 236 ---- .../roomprocessor/RoomProcessorRedRoom.java | 125 -- .../roomprocessor/RoomProcessorRiddle.java | 123 -- .../RoomProcessorTeleportMazeSolver.java | 145 --- .../RoomProcessorTicTacToeSolver.java | 216 --- .../roomprocessor/RoomProcessorTrivia.java | 167 --- .../bombdefuse/RoomProcessorBombDefuseSolver.java | 441 ------- .../bombdefuse/chambers/BDChamber.java | 83 -- .../chambers/BombDefuseChamberGenerator.java | 30 - .../bombdefuse/chambers/ChamberProcessor.java | 27 - .../chambers/DummyDefuseChamberProcessor.java | 33 - .../chambers/GeneralDefuseChamberProcessor.java | 139 -- .../chambers/arrow/ArrowLeftProcessor.java | 138 -- .../chambers/arrow/ArrowProcessorMatcher.java | 52 - .../chambers/arrow/ArrowRightProcessor.java | 127 -- .../chambers/bugged/ImpossibleMatcher.java | 47 - .../chambers/color/ColorLeftProcessor.java | 233 ---- .../chambers/color/ColorProcessorMatcher.java | 49 - .../chambers/color/ColorRightProcessor.java | 177 --- .../chambers/creeper/CreeperLeftProcessor.java | 102 -- .../chambers/creeper/CreeperProcessorMatcher.java | 52 - .../chambers/creeper/CreeperRightProcessor.java | 76 -- .../goldenpath/GoldenPathLeftProcessor.java | 143 -- .../goldenpath/GoldenPathProcessorMatcher.java | 49 - .../goldenpath/GoldenPathRightProcessor.java | 100 -- .../chambers/maze/MazeLeftProcessor.java | 89 -- .../chambers/maze/MazeProcessorMatcher.java | 49 - .../chambers/maze/MazeRightProcessor.java | 79 -- .../chambers/number/NumberLeftProcessor.java | 132 -- .../chambers/number/NumberProcessorMatcher.java | 53 - .../chambers/number/NumberRightProcessor.java | 117 -- .../bossfight/BossfightProcessor.java | 33 - .../bossfight/BossfightProcessorBonzo.java | 86 -- .../bossfight/BossfightProcessorLivid.java | 90 -- .../bossfight/BossfightProcessorNecron.java | 80 -- .../bossfight/BossfightProcessorProf.java | 144 -- .../bossfight/BossfightProcessorSadan.java | 144 -- .../bossfight/BossfightProcessorScarf.java | 134 -- .../bossfight/BossfightProcessorThorn.java | 104 -- .../bossfight/GeneralBossfightProcessor.java | 155 --- .../roomprocessor/bossfight/HealthData.java | 33 - .../boxpuzzle/BoxPuzzleSolvingThread.java | 184 --- .../boxpuzzle/RoomProcessorBoxSolver.java | 392 ------ .../icefill/RoomProcessorIcePath2.java | 160 --- .../roomprocessor/waterpuzzle/LeverState.java | 33 - .../waterpuzzle/LeverStateContradict.java | 25 - .../waterpuzzle/RoomProcessorWaterPuzzle.java | 124 -- .../roomprocessor/waterpuzzle/Route.java | 60 - .../roomprocessor/waterpuzzle/SwitchData.java | 46 - .../roomprocessor/waterpuzzle/WaterBoard.java | 423 ------ .../roomprocessor/waterpuzzle/WaterNode.java | 36 - .../waterpuzzle/nodes/WaterNodeAir.java | 59 - .../waterpuzzle/nodes/WaterNodeEnd.java | 60 - .../waterpuzzle/nodes/WaterNodeStart.java | 66 - .../waterpuzzle/nodes/WaterNodeToggleable.java | 71 - .../waterpuzzle/nodes/WaterNodeWall.java | 62 - .../dungeonsguide/rpc/JDiscordActivity.java | 72 - .../dungeonsguide/rpc/JDiscordRelation.java | 42 - .../syeyoung/dungeonsguide/rpc/JDiscordUser.java | 40 - .../dungeonsguide/rpc/RichPresenceManager.java | 251 ---- .../dungeonsguide/stomp/CloseListener.java | 23 - .../syeyoung/dungeonsguide/stomp/StompClient.java | 194 --- .../dungeonsguide/stomp/StompClientStatus.java | 23 - .../syeyoung/dungeonsguide/stomp/StompHeader.java | 27 - .../dungeonsguide/stomp/StompInterface.java | 26 - .../dungeonsguide/stomp/StompMessageHandler.java | 23 - .../syeyoung/dungeonsguide/stomp/StompPayload.java | 86 -- .../dungeonsguide/stomp/StompSubscription.java | 41 - .../syeyoung/dungeonsguide/url/DGConnection.java | 18 +- .../dungeonsguide/url/DGStreamHandler.java | 4 +- .../dungeonsguide/url/DGStreamHandlerFactory.java | 4 +- .../kr/syeyoung/dungeonsguide/utils/AhUtils.java | 87 -- .../syeyoung/dungeonsguide/utils/ArrayUtils.java | 40 - .../syeyoung/dungeonsguide/utils/GlStateUtils.java | 69 - .../kr/syeyoung/dungeonsguide/utils/MapUtils.java | 177 --- .../syeyoung/dungeonsguide/utils/RenderUtils.java | 1377 -------------------- .../syeyoung/dungeonsguide/utils/ShortUtils.java | 47 - .../dungeonsguide/utils/SkyblockUtils.java | 54 - .../kr/syeyoung/dungeonsguide/utils/TextUtils.java | 122 -- .../dungeonsguide/utils/TimeScoreUtil.java | 87 -- .../syeyoung/dungeonsguide/utils/VectorUtils.java | 53 - .../kr/syeyoung/dungeonsguide/utils/XPUtils.java | 222 ---- .../dungeonsguide/utils/cursor/CursorReader.java | 99 -- .../dungeonsguide/utils/cursor/EnumCursor.java | 54 - .../dungeonsguide/utils/cursor/Foundation.java | 34 - .../dungeonsguide/utils/cursor/GLCursors.java | 224 ---- .../dungeonsguide/utils/cursor/User32.java | 68 - .../syeyoung/dungeonsguide/utils/cursor/X11.java | 37 - .../dungeonsguide/wsresource/StaticResource.java | 30 - .../wsresource/StaticResourceCache.java | 83 -- .../resources/assets/dg/textures/dglogox128.png | Bin 0 -> 3024 bytes .../resources/assets/dg/textures/dglogox32.png | Bin 0 -> 648 bytes .../assets/skyblock_dungeons_guide/sounds.json | 10 + .../skyblock_dungeons_guide/sounds/readysetgo.ogg | Bin 0 -> 161265 bytes src/main/resources/mcmod.info | 6 +- 1120 files changed, 55834 insertions(+), 54249 deletions(-) create mode 100644 .github/workflows/beta.yml delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/DGInterface.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/IDungeonGuide.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/YoMamaOutdated.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/auth/AuthManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/auth/AuthUtil.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/auth/InvalidDungeonsGuideCredentialsException.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/auth/ResourceManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/AuthProvider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/DgAuth/DgAuth.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/DgAuth/DgAuthUtil.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/NullAuth.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/chat/ChatProcessResult.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/chat/ChatProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/chat/ChatSubscriber.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/chat/PartyContext.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/chat/PartyManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/Config.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfigV2.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategory.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategoryElement.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeatureEdit.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MNotFound.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MPanelCategory.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/NestedCategory.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/RootConfigPanel.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/GuiGuiLocationConfig.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/Marker.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/PanelDelegate.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/AColor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCAColor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCColor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCFloat.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCStringList.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyle.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyleList.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/ActiveCosmetic.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticData.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonActionManager.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionComplete.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombMasterDataProvider.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProvider.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/EDungeonDoorType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonCryptBrokenEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonDeathEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventData.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventHolder.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonMapUpdateEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonNodataEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonPuzzleFailureEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonRoomDiscoverEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonSecretCountChangeEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonStateChangeEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/SerializableBlockPos.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/RouteBlocker.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/dunegonmechanic/DungeonMechanic.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/dunegonmechanic/RouteBlocker.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/BlockUpdateEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/BossroomEnterEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/DiscordUserJoinRequestEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/DiscordUserUpdateEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/DungeonContextInitializationEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/DungeonEndedEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/DungeonLeftEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/DungeonStartedEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/HypixelJoinedEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/KeyBindPressedEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/PlayerInteractEntityEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/PlayerListItemPacketEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/SkyblockJoinedEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/SkyblockLeftEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/StompConnectedEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/TitleEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/events/WindowUpdateEvent.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/FeatureParameter.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/SimpleFeature.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomDebugInfo.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureCurrentPhase.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureHideAnimals.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureTerracotaTimer.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornSpiritBowTimer.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureSimonSaysSolver.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureTerminalSolvers.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/NavigateMazeSolutionProvider.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectAllColorSolutionProivider.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectInOrderSolutionProvider.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolution.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolutionProvider.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknameColor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknamePrefix.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/PrefixSelectorGUI.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/ImageTexture.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/PartyInviteViewer.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/PartyJoinRequest.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/invteTooltip/MTooltipInvite.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/invteTooltip/MTooltipInviteElement.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/onlinealarm/PlayingDGAlarm.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxBats.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureCollectScore.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRoomName.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureHideNameTags.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePlayerESP.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWatcherWarning.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCopyMessages.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDecreaseExplosionSound.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDisableMessage.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeaturePenguins.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureRepartyCommand.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureTooltipDungeonStat.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureTooltipPrice.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureUpdateAlarm.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/SkyblockAbility.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/UsedAbility.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/APIKey.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureGoodParties.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeaturePartyList.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeaturePartyReady.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/FeatureCustomPartyFinder.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/GuiCustomPartyFinder.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinder.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FakePlayer.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/ApiFetcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/CachedData.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/PlayerSkyblockData.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/SkinFetcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/PlayerProfile.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/PlayerProfileParser.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/ClassSpecificData.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonClass.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonSpecificData.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonStat.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/FloorSpecificData.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/Pet.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/Skill.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/DataRendererEditor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/DataRendererRegistry.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/IDataRenderer.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonFloorStat.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonHighestFloorStat.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererClassLv.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererDungeonLv.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererFairySouls.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererLilyWeight.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSecrets.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSelectedClassLv.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSetUrOwn.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSkillLv.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererTalismans.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureBloodRush.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureCreateRefreshLine.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindStrategy.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindToAll.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureTogglePathfind.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/PathfindLineProperties.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBlaze.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBombdefuse.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBox.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverIcefill.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverKahoot.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverRiddle.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverSilverfish.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverTeleport.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverTictactoe.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/BossroomEnterListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/ChatListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/ChatListenerGlobal.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/DiscordUserJoinRequestListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/DiscordUserUpdateListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonContextInitializationListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonEndListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonQuitListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonStartListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/EntityLivingRenderListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiBackgroundRenderListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiClickListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiOpenListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPostRenderListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPreRenderListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiUpdateListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/InteractListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeyInputListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeybindPressedListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/PlayerRenderListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/ScreenRenderListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/SkyblockJoinListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/SkyblockLeaveListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/SoundListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/StompConnectedListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/TextureStichListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/TickListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/TitleListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/WorldRenderListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/GameSDK.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/GameSDKTypeMapper.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/NativeGameSDK.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivity.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityAssets.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityParty.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivitySecrets.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityTimestamps.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordCreateParams.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordEntitlement.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordFileStat.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordImageDimensions.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordImageHandle.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordInputMode.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordLobby.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordOAuth2Token.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordPartySize.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordPresence.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordRelationship.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordSku.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordSkuPrice.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordStruct.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordUser.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordUserAchievement.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityActionType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityJoinRequestReply.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordCreateFlags.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordEntitlementType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordImageType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordInputModeType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchCast.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchComparison.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchDistance.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbyType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLogLevel.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordPremiumType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordRelationshipType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordResult.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordSkuType.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordStatus.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordUserFlag.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/GameSDKCallback.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordAchievementEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordAchievementManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordActivityEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordActivityManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordApplicationManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordCore.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordImageManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyMemberTransaction.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbySearchQuery.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyTransaction.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordNetworkEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordNetworkManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordOverlayEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordOverlayManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordRelationshipEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordRelationshipManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStorageManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStoreEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStoreManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordUserEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordUserManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordVoiceEvents.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordVoiceManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordClientID.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordNetworkChannelId.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordNetworkPeerId.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordSnowflake.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordTimestamp.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordVersion.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/Int32.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/Int64.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt32.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt64.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt8.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MColor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MEditableAColor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MFloatSelectionButton.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MIntegerSelectionButton.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MKeyEditButton.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabel.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabelAndElement.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModal.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalConfirmation.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalMessage.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MParameter.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPopupMenu.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPortableColorEdit.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MSpacer.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MStringSelectionButton.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltipText.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MValue.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/Keybinds.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/SkyblockStatus.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatProcessResult.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatSubscriber.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatTransmitter.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDungeonsGuide.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandReparty.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/Config.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/ConfigPanelCreator.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/GuiConfigV2.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MCategory.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MCategoryElement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MFeature.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MFeatureEdit.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MNotFound.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MPanelCategory.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MParameterEdit.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/NestedCategory.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/RootConfigPanel.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/GuiGuiLocationConfig.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/Marker.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/PanelDelegate.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/AColor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/GUIRectangle.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCAColor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCBoolean.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCColor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCFloat.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCGUIRectangle.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCInteger.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCKeybind.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRectangle.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCString.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCStringList.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCTextStyle.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCTextStyleList.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TypeConverter.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TypeConverterRegistry.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/ActiveCosmetic.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CosmeticData.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CosmeticsManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomPacketPlayerListItem.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/IChatReplacer.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerChatByMe.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerCoop.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerMessage.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerPV.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerSocialOptions.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerViewProfile.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/GameSDK.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/GameSDKTypeMapper.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/NativeGameSDK.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivity.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityAssets.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityParty.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivitySecrets.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityTimestamps.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordCreateParams.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordEntitlement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordFileStat.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordImageDimensions.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordImageHandle.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordInputMode.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordLobby.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordOAuth2Token.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordPartySize.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordPresence.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordRelationship.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordSku.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordSkuPrice.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordStruct.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordUser.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordUserAchievement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityActionType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityJoinRequestReply.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordCreateFlags.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordEntitlementType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordImageType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordInputModeType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchCast.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchComparison.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchDistance.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbyType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLogLevel.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordPremiumType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordRelationshipType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordResult.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordSkuType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordStatus.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordUserFlag.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/GameSDKCallback.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordAchievementEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordAchievementManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordActivityEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordActivityManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordApplicationManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordCore.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordImageManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyMemberTransaction.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbySearchQuery.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyTransaction.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordNetworkEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordNetworkManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordOverlayEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordOverlayManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordRelationshipEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordRelationshipManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStorageManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStoreEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStoreManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordUserEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordUserManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordVoiceEvents.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordVoiceManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordClientID.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordNetworkChannelId.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordNetworkPeerId.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordSnowflake.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordTimestamp.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordVersion.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/Int32.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/Int64.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt32.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt64.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt8.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordActivity.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordRelation.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordUser.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/RichPresenceManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonActionContext.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonContext.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonFacade.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/MapProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/AbstractAction.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionBreakWithSuperBoom.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionChangeState.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionClick.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionClickSet.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionComplete.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionDropItem.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionInteract.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionKill.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionMove.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionMoveNearestAir.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionRoot.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionRoute.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionRouteProperties.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionTree.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionTreeUtil.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonDoor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonSpecificDataProvider.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/EDungeonDoorType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/CatacombsDataProvider.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/impl/MasterModeDataProvider.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/impl/NormalModeDataProvider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEventData.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEventHolder.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/SerializableBlockPos.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonCryptBrokenEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonDeathEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonMapUpdateEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonNodataEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonPuzzleFailureEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonRoomDiscoverEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonSecretCountChangeEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonStateChangeEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/map/DungeonMapData.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/AStarCornerCut.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/AStarFineGrid.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/CachedWorld.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/JPSPathfinder.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/NodeProcessorDungeonRoom.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/ThetaStar.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/EditingContext.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/Parameter.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonAddSet.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonParameterEdit.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonRoomEdit.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonValueEdit.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditBreakableWall.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditDoor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditDummy.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditFairySoul.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditJournal.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditLever.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditNPC.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditOnewayDoor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditOnewayLever.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditPressurePlate.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditSecret.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditTomb.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ActionDisplayPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ActionTreeDisplayPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/DynamicEditor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/GeneralEditPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ProcessorParameterEditPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoomDataDisplayPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoomMatchDisplayPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoommatchingPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/SecretEditPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEdit.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditAColor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditBoolean.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditColor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditCreator.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditFloat.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditInteger.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditNull.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditOffsetPoint.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditOffsetPointSet.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditRegistry.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditString.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/DungeonRoom.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/DungeonRoomInfoRegistry.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/RoomMatcher.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/GeneralRoomProcessor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/ProcessorFactory.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorBlazeSolver.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorButtonSolver.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorCreeperSolver.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorGenerator.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorIcePath.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorRedRoom.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorRiddle.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTeleportMazeSolver.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTicTacToeSolver.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTrivia.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/BDChamber.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/ChamberProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorLeftProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorBonzo.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorLivid.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorNecron.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorProf.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorSadan.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorScarf.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorThorn.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/GeneralBossfightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/HealthData.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/boxpuzzle/BoxPuzzleSolvingThread.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/icefill/RoomProcessorIcePath2.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/LeverState.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/LeverStateContradict.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/Route.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/SwitchData.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/WaterBoard.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/WaterNode.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/AuthChangedEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/BlockUpdateEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/BossroomEnterEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DiscordUserJoinRequestEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DiscordUserUpdateEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonContextInitializationEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonEndedEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonLeftEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonStartedEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/HypixelJoinedEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/KeyBindPressedEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/PlayerInteractEntityEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/PlayerListItemPacketEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/SkyblockJoinedEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/SkyblockLeftEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/StompConnectedEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/TitleEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/WindowUpdateEvent.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/DungeonListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FeatureListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureParameter.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/GuiFeature.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/SimpleFeature.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebug.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebugTrap.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebuggableMap.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomCoordDisplay.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomDebugInfo.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureTestPepole.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureAutoReparty.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBossHealth.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBoxRealLivid.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureChestPrice.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureCurrentPhase.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureHideAnimals.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureTerracotaTimer.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornBearPercentage.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornSpiritBowTimer.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureWarningOnPortal.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/FeatureSimonSaysSolver.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/FeatureTerminalSolvers.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/NavigateMazeSolutionProvider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/SelectAllColorSolutionProivider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/SelectInOrderSolutionProvider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/TerminalSolution.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/TerminalSolutionProvider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/FeatureNicknameColor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/FeatureNicknamePrefix.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/PrefixSelectorGUI.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/ImageTexture.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyJoinRequest.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/invteTooltip/MTooltipInvite.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/invteTooltip/MTooltipInviteElement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxBats.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxSkelemaster.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxStarMobs.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureCollectScore.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonDeaths.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMap.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMilestone.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRealTime.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRoomName.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSBTime.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonScore.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSecrets.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonTombs.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureHideNameTags.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeaturePlayerESP.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWatcherWarning.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureAutoAcceptReparty.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCooldownCounter.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCopyMessages.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureDecreaseExplosionSound.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureDisableMessage.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureEpicCountdown.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeaturePenguins.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureRepartyCommand.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureTooltipDungeonStat.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureTooltipPrice.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureUpdateAlarm.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/FeatureAbilityCooldown.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/SkyblockAbility.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/UsedAbility.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/APIKey.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyList.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyReady.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/FeatureCustomPartyFinder.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/GuiCustomPartyFinder.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinder.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FakePlayer.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/CachedData.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/PlayerSkyblockData.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/SkinFetcher.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/PlayerProfile.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/PlayerProfileParser.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/ClassSpecificData.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonClass.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonSpecificData.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonStat.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonType.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/FloorSpecificData.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/Pet.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/Skill.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/DataRendererEditor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/DataRendererRegistry.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/IDataRenderer.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonFloorStat.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonHighestFloorStat.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererClassLv.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererDungeonLv.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererFairySouls.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererLilyWeight.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSecrets.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSelectedClassLv.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSetUrOwn.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSkillLv.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererTalismans.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureActions.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureBloodRush.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureCreateRefreshLine.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureFreezePathfind.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeaturePathfindStrategy.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeaturePathfindToAll.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureSoulRoomWarning.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureTogglePathfind.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/PathfindLineProperties.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBlaze.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBombdefuse.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBox.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverIcefill.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverKahoot.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverRiddle.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverSilverfish.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverTeleport.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverTictactoe.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/BossroomEnterListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ChatListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ChatListenerGlobal.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DiscordUserJoinRequestListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DiscordUserUpdateListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonContextInitializationListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonEndListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonQuitListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonStartListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/EntityLivingRenderListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiBackgroundRenderListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiClickListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiOpenListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiPostRenderListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiPreRenderListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiUpdateListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/InteractListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/KeyInputListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/KeybindPressedListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/PlayerRenderListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ScreenRenderListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SkyblockJoinListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SkyblockLeaveListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SoundListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/StompConnectedListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TextureStichListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TickListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TitleListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TooltipListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/WorldRenderListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/PanelTextParameterConfig.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledText.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextProvider.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextRenderer.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextStyle.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/MGui.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/MPanel.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MButton.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MCollapsable.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MColor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MEditableAColor.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MFloatSelectionButton.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MIntegerSelectionButton.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MKeyEditButton.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MLabel.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MLabelAndElement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MList.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModal.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModalConfirmation.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModalMessage.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MNavigatingPane.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPanelScaledGUI.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MParameter.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPassiveLabelAndElement.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPopupMenu.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPortableColorEdit.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MRootPanel.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MScrollBar.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MScrollablePanel.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MSpacer.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MStringSelectionButton.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTabbedPane.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTextField.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MToggleButton.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTooltip.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTooltipText.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MValue.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/party/PartyContext.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/party/PartyManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/resources/DGTexturePack.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/FailedWebSocketConnection.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompDiedEvent.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompHeader.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompManager.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompPayload.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompSubscription.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/AhUtils.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ArrayUtils.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/BlockCache.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/GlStateUtils.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/MapUtils.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/RenderUtils.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ScoreBoardUtils.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ShortUtils.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TabListUtil.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TextUtils.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TimeScoreUtil.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TitleRender.java create mode 100755 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/VectorUtils.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/XPUtils.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/CursorReader.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/EnumCursor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/Foundation.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/GLCursors.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/User32.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/X11.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/wsresource/StaticResource.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/mod/wsresource/StaticResourceCache.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/pathfinding/AStarCornerCut.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/pathfinding/AStarFineGrid.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/pathfinding/CachedWorld.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/pathfinding/NodeProcessorDungeonRoom.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/pathfinding/ThetaStar.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/resources/DGTexturePack.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDoor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDummy.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditJournal.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditNPC.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/DynamicEditor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoommatchingPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/SecretEditPane.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorButtonSolver.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorGenerator.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRedRoom.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/ChamberProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorLeftProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorBonzo.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorLivid.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorNecron.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorProf.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorSadan.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorScarf.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorThorn.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/HealthData.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/BoxPuzzleSolvingThread.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverState.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverStateContradict.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/SwitchData.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordActivity.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordRelation.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordUser.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/rpc/RichPresenceManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/stomp/CloseListener.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/stomp/StompClient.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/stomp/StompClientStatus.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/stomp/StompHeader.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/stomp/StompInterface.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/stomp/StompMessageHandler.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/stomp/StompSubscription.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/AhUtils.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/utils/MapUtils.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/utils/SkyblockUtils.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/TimeScoreUtil.java delete mode 100755 src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/XPUtils.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/CursorReader.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/X11.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/wsresource/StaticResource.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/wsresource/StaticResourceCache.java create mode 100644 src/main/resources/assets/dg/textures/dglogox128.png create mode 100644 src/main/resources/assets/dg/textures/dglogox32.png create mode 100644 src/main/resources/assets/skyblock_dungeons_guide/sounds.json create mode 100644 src/main/resources/assets/skyblock_dungeons_guide/sounds/readysetgo.ogg (limited to 'build.gradle') diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml new file mode 100644 index 00000000..5cbbe58f --- /dev/null +++ b/.github/workflows/beta.yml @@ -0,0 +1,33 @@ +name: Beta Build + +on: + push: + branches: + - 'breaking-changes-just-working-im-not-putting-all-of-these-into-3.0-but-for-the-sake-of-beta-release-this-thing-exists' + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 16 + uses: actions/setup-java@v3 + with: + java-version: '16' + distribution: 'adopt' + cache: 'gradle' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Download hychat as a dependency + run: mkdir jars && wget https://cdn.discordapp.com/attachments/782825804983566356/791708191519932426/Hychat-1.12.1-BETA.jar -O jars/Hychat-1.12.1-BETA.jar + - name: Build with Gradle + run: ./gradlew build + - uses: actions/upload-artifact@v2 + if: github.event_name == 'workflow_dispatch' + with: + name: Compiled-files + path: build/libs/*.jar + - name: Upload to beta webhook + env: + BETA_WEBHOOK: ${{ secrets.BETA_WEBHOOK }} + run: path=$(find ./build/ -type d -name "libs" -exec find "{}" -type f -name "dungeonsguide-*-all.jar" \;) curl -F "file1=@$path" "$BETA_WEBHOOK" \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 62f386c2..db0dc81b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,10 +3,10 @@ name: Build on: push: branches: - - '*' + - 'master' pull_request: branches: - - '*' + - 'master' workflow_dispatch: jobs: build: @@ -20,6 +20,7 @@ jobs: with: java-version: '16' distribution: 'adopt' + cache: 'gradle' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Download hychat as a dependency @@ -30,4 +31,4 @@ jobs: if: github.event_name == 'workflow_dispatch' with: name: Compiled-files - path: build/libs/*.jar + path: build/libs/*.jar \ No newline at end of file diff --git a/build.gradle b/build.gradle index 24bc189f..7252969e 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ tasks.wrapper { // the full version (with sources and documentation) of Gradle (ALL) distributionType = Wrapper.DistributionType.ALL } -version = "3.0.0" +version = "3.8.0" group = "kr.syeyoung.dungeonsguide" archivesBaseName = "dungeonsguide" @@ -78,17 +78,18 @@ dependencies { forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") - implementation "org.jetbrains:annotations-java5:19.0.0" - implementation "org.java-websocket:Java-WebSocket:1.5.1" - implementation "org.json:json:20171018" - implementation "com.twelvemonkeys.imageio:imageio-bmp:3.7.0" + implementation 'org.jetbrains:annotations-java5:23.0.0' + implementation 'org.java-websocket:Java-WebSocket:1.5.3' + implementation "org.json:json:20220924" + implementation 'com.twelvemonkeys.imageio:imageio-bmp:3.8.3' + + compileOnly 'org.projectlombok:lombok:1.18.24' + annotationProcessor 'org.projectlombok:lombok:1.18.24' - compileOnly "org.projectlombok:lombok:1.18.20" compileOnly files("jars/Hychat-1.12.1-BETA.jar") - annotationProcessor "org.projectlombok:lombok:1.18.16" - testCompileOnly "org.projectlombok:lombok:1.18.20" - testAnnotationProcessor "org.projectlombok:lombok:1.18.20" + testCompileOnly "org.projectlombok:lombok:1.18.24" + testAnnotationProcessor "org.projectlombok:lombok:1.18.24" modRuntimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.0") } @@ -116,9 +117,9 @@ tasks.shadowJar { relocate "org.java_websocket", "kr.syeyoung.org.java_websocket" dependencies { - include(dependency("org.java-websocket:Java-WebSocket:1.5.1")) + include(dependency("org.java-websocket:Java-WebSocket:1.5.3")) include(dependency("org.slf4j:slf4j-api:1.7.25")) - include(dependency("org.json:json:20171018")) + include(dependency("org.json:json:20220924")) include(dependency("com.twelvemonkeys..*:.*")) } } @@ -131,3 +132,16 @@ tasks.named("remapJar") { tasks.assemble.dependsOn tasks.remapJar + +processResources { + inputs.property 'version', project.version + + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + duplicatesStrategy = 'include' + include 'mcmod.info' + + // replace version and mcversion + expand 'version': project.version + } +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java deleted file mode 100755 index 5b15fde6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.exceptions.AuthenticationException; -import com.mojang.authlib.minecraft.MinecraftSessionService; -import net.minecraft.client.Minecraft; -import net.minecraft.util.Session; -import net.minecraftforge.fml.common.ProgressManager; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.IOUtils; - -import javax.crypto.*; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import javax.net.ssl.*; -import java.io.*; -import java.math.BigInteger; -import java.net.*; -import java.security.*; -import java.security.cert.CertificateException; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.X509EncodedKeySpec; -import java.util.HashMap; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -public class Authenticator { - private KeyPair rsaKey; - private String token; - private final ProgressManager.ProgressBar progressBar; - - public String getToken() { - return token; - } - - private KeyPair getKeyPair() { - KeyPairGenerator a = null; - try { - a = KeyPairGenerator.getInstance("RSA"); - } catch (NoSuchAlgorithmException b) { } - a.initialize(1024); - this.rsaKey = a.generateKeyPair(); - return this.rsaKey; - } - - private PublicKey dgPublicKey; - private PublicKey getDGPublicKey() throws NoSuchAlgorithmException, InvalidKeySpecException { - if (dgPublicKey != null) return dgPublicKey; - X509EncodedKeySpec spec = new X509EncodedKeySpec(Base64.decodeBase64("MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxO89qtwG67jNucQ9Y44c" + - "IUs/B+5BeJPs7G+RG2gfs4/2+tzF/c1FLDc33M7yKw8aKk99vsBUY9Oo8gxxiEPB" + - "JitP/qfon2THp94oM77ZTpHlmFoqbZMcKGZVI8yfvEL4laTM8Hw+qh5poQwtpEbK" + - "Xo47AkxygxJasUnykER2+aSTZ6kWU2D4xiNtFA6lzqN+/oA+NaYfPS0amAvyVlHR" + - "n/8IuGkxb5RrlqVssQstFnxsJuv88qdGSEqlcKq2tLeg9hb8eCnl2OFzvXmgbVER" + - "0JaV+4Z02fVG1IlR3Xo1mSit7yIU6++3usRCjx2yfXpnGGJUW5pe6YETjNew3ax+" + - "FAZ4GePWCdmS7FvBnbbABKo5pE06ZTfDUTCjQlAJQiUgoF6ntMJvQAXPu48Vr8q/" + - "mTcuZWVnI6CDgyE7nNq3WNoq3397sBzxRohMxuqzl3T19zkfPKF05iV2Ju1HQMW5" + - "I119bYrmVD240aGESZc20Sx/9g1BFpNzQbM5PGUlWJ0dhLjl2ge4ip2hHciY3OEY" + - "p2Qy2k+xEdenpKdL+WMRimCQoO9gWe2Tp4NmP5dppDXZgPjXqjZpnGs0Uxs+fXqW" + - "cwlg3MbX3rFl9so/fhVf4p9oXZK3ve7z5D6XSSDRYECvsKIa08WAxJ/U6n204E/4" + - "xUF+3ZgFPdzZGn2PU7SsnOsCAwEAAQ==")); - return dgPublicKey = KeyFactory.getInstance("RSA").generatePublic(spec); - } - - public Authenticator(ProgressManager.ProgressBar progressBar) { - this.progressBar = progressBar; - progressBar.step("Generating KeyPair"); - getKeyPair(); - } - - public String authenticateAndDownload(String version) throws IOException, AuthenticationException, NoSuchAlgorithmException, CertificateException, KeyStoreException, KeyManagementException, InvalidKeySpecException, SignatureException { - Session session = Minecraft.getMinecraft().getSession(); - String sessionToken = session.getToken(); - - progressBar.step("Authenticating (1/2)"); - String tempToken = requestAuth(session.getProfile()); - MinecraftSessionService yggdrasilMinecraftSessionService = Minecraft.getMinecraft().getSessionService(); - JsonObject d = getJwtPayload(tempToken); - String hash = calculateServerHash(Base64.decodeBase64(d.get("sharedSecret").getAsString()), - Base64.decodeBase64(d.get("publicKey").getAsString())); - yggdrasilMinecraftSessionService.joinServer(session.getProfile(), sessionToken, hash); - progressBar.step("Authenticating (2/2)"); - this.token = verifyAuth(tempToken, this.rsaKey.getPublic()); - try { - progressBar.step("Downloading Jar"); - if (version != null) - downloadSafe(this.token, "https://dungeons.guide/resource/version?v=" + version, true); - progressBar.step("Downloading Rooms"); - downloadSafe(this.token, "https://dungeons.guide/resource/roomdata", false); - } catch (Throwable t) { - t.printStackTrace(); - } - return this.token; - } - - public JsonObject getJwtPayload(String jwt) { - String midPart = jwt.split("\\.")[1].replace("+", "-").replace("/", "_"); - String base64Decode = new String(Base64.decodeBase64(midPart)); // padding - return (JsonObject) new JsonParser().parse(base64Decode); - } - - - - private String requestAuth(GameProfile profile) throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, KeyManagementException { - HttpsURLConnection connection = (HttpsURLConnection) new URL("https://dungeons.guide/auth/requestAuth").openConnection(); - connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestMethod("POST"); - connection.setDoInput(true); - connection.setDoOutput(true); - - connection.getOutputStream().write(("{\"uuid\":\""+profile.getId().toString()+"\",\"nickname\":\""+profile.getName()+"\"}").getBytes()); - String payload = String.join("\n", IOUtils.readLines(connection.getErrorStream() == null ? connection.getInputStream() : connection.getErrorStream())); - if (connection.getResponseCode() >= 400) - System.out.println("https://dungeons.guide/auth/requestAuth :: Received "+connection.getResponseCode()+" along with\n"+payload); - - JsonObject json = (JsonObject) new JsonParser().parse(payload); - - if (!"ok".equals(json.get("status").getAsString())) { - return null; - } - return json.get("data").getAsString(); - } - private String verifyAuth(String tempToken, PublicKey clientKey) throws IOException { - HttpsURLConnection urlConnection = (HttpsURLConnection) new URL("https://dungeons.guide/auth/authenticate").openConnection(); - urlConnection.setRequestMethod("POST"); - urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); - urlConnection.setRequestProperty("Content-Type", "application/json"); - urlConnection.setDoInput(true); - urlConnection.setDoOutput(true); - - urlConnection.getOutputStream().write(("{\"jwt\":\""+tempToken+"\",\"publicKey\":\""+Base64.encodeBase64URLSafeString(clientKey.getEncoded())+"\"}").getBytes()); - String payload = String.join("\n", IOUtils.readLines(urlConnection.getErrorStream() == null ? urlConnection.getInputStream() : urlConnection.getErrorStream())); - if (urlConnection.getResponseCode() >= 400) - System.out.println("https://dungeons.guide/auth/authenticate :: Received "+urlConnection.getResponseCode()+" along with\n"+payload); - - JsonObject jsonObject = (JsonObject) new JsonParser().parse(payload); - if (!"ok".equals(jsonObject.get("status").getAsString())) { - return null; - } - return jsonObject.get("data").getAsString(); - } - - private final HashMap loadedResources = new HashMap(); - - public HashMap getResources() { - return loadedResources; - } - - private void downloadSafe(String dgToken, String url, boolean isValidateSignature) throws IOException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, CertificateException, KeyStoreException, KeyManagementException, SignatureException, InvalidKeySpecException { - HttpsURLConnection dgConnection = (HttpsURLConnection) new URL(url).openConnection(); - dgConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); - dgConnection.setRequestProperty("Content-Type", "application/json"); - dgConnection.setRequestMethod("GET"); - dgConnection.setRequestProperty("Authorization", dgToken); - dgConnection.setDoInput(true); - dgConnection.setDoOutput(true); - - InputStream inputStream = dgConnection.getInputStream(); - byte[] lengthBytes = new byte[4]; - inputStream.read(lengthBytes); - int length = ((lengthBytes[0] & 0xFF) << 24) | - ((lengthBytes[1] & 0xFF) << 16) | - ((lengthBytes[2] & 0xFF) << 8) | - ((lengthBytes[3] & 0xFF)); - while (inputStream.available() < length) ; - byte[] keyPayload = new byte[length]; - inputStream.read(keyPayload); - - Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); - cipher.init(Cipher.DECRYPT_MODE, this.rsaKey.getPrivate()); - byte[] h = cipher.doFinal(keyPayload); - - cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - SecretKeySpec keySpec = new SecretKeySpec(h, "AES"); - IvParameterSpec ivSpec = new IvParameterSpec(h); - cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); - CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); - - cipherInputStream.read(lengthBytes); - length = ((lengthBytes[0] & 0xFF) << 24) | - ((lengthBytes[1] & 0xFF) << 16) | - ((lengthBytes[2] & 0xFF) << 8) | - ((lengthBytes[3] & 0xFF)); - - int totalLen = length; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - byte[] buff = new byte[256]; - while (totalLen > 0) { - int len = cipherInputStream.read(buff, 0, Math.min(buff.length, totalLen)); - totalLen -= len; - bos.write(buff, 0, len); - } - byte[] body = bos.toByteArray(); - - byte[] signed = null; - if (isValidateSignature) { - progressBar.step("Validating Signature"); - cipherInputStream.read(lengthBytes,0 , 4); - length = ((lengthBytes[0] & 0xFF) << 24) | - ((lengthBytes[1] & 0xFF) << 16) | - ((lengthBytes[2] & 0xFF) << 8) | - ((lengthBytes[3] & 0xFF)); - - totalLen = length; - bos = new ByteArrayOutputStream(); - while (totalLen > 0) { - int len = cipherInputStream.read(buff, 0, Math.min(buff.length, totalLen)); - totalLen -= len; - bos.write(buff, 0, len); - } - signed = bos.toByteArray(); - - Signature sign = Signature.getInstance("SHA512withRSA"); - sign.initVerify(getDGPublicKey()); - sign.update(body); - boolean truth = sign.verify(signed); - if (!truth) throw new SignatureException("DG SIGNATURE FORGED"); - } - - ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(body)); - ZipEntry zipEntry; - while ((zipEntry=zipInputStream.getNextEntry()) != null) { - byte[] buffer = new byte[256]; - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - int p = 0; - while((p = zipInputStream.read(buffer)) > 0) { - byteArrayOutputStream.write(buffer, 0, p); - } - this.loadedResources.put(zipEntry.getName(), byteArrayOutputStream.toByteArray()); - } - dgConnection.disconnect(); - } - - public JsonElement getJsonSecured(String u) throws IOException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, CertificateException, KeyStoreException, KeyManagementException { - HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL(u).openConnection(); - httpsURLConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); - httpsURLConnection.setRequestProperty("Content-Type", "application/json"); - httpsURLConnection.setRequestMethod("GET"); - httpsURLConnection.setRequestProperty("Authorization", this.token); - httpsURLConnection.setDoInput(true); - httpsURLConnection.setDoOutput(true); - - InputStream inputStream = httpsURLConnection.getInputStream(); - byte[] lengthPayload = new byte[4]; - inputStream.read(lengthPayload); - int length = ((lengthPayload[0] & 0xFF) << 24) | - ((lengthPayload[1] & 0xFF) << 16) | - ((lengthPayload[2] & 0xFF) << 8) | - ((lengthPayload[3] & 0xFF)); - while (inputStream.available() < length) ; - byte[] keyPayload = new byte[length]; - inputStream.read(keyPayload); - - Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); - cipher.init(Cipher.DECRYPT_MODE, this.rsaKey.getPrivate()); - byte[] AESKey = cipher.doFinal(keyPayload); - - cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - SecretKeySpec secretKeySpec = new SecretKeySpec(AESKey, "AES"); - IvParameterSpec ivParameterSpec = new IvParameterSpec(AESKey); - cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); - CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); - cipherInputStream.read(lengthPayload); - length = ((lengthPayload[0] & 0xFF) << 24) | - ((lengthPayload[1] & 0xFF) << 16) | - ((lengthPayload[2] & 0xFF) << 8) | - ((lengthPayload[3] & 0xFF)); - JsonElement l = new JsonParser().parse(new InputStreamReader(cipherInputStream)); - httpsURLConnection.disconnect(); - return l; - } - - public String calculateServerHash(byte[] a, byte[] b) throws NoSuchAlgorithmException { - MessageDigest c = MessageDigest.getInstance("SHA-1"); - c.update("".getBytes()); - c.update(a); - c.update(b); - byte[] d = c.digest(); - return new BigInteger(d).toString(16); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DGInterface.java b/src/main/java/kr/syeyoung/dungeonsguide/DGInterface.java deleted file mode 100755 index 0529f0a6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/DGInterface.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public interface DGInterface { - void init(FMLInitializationEvent event); - - void pre(FMLPreInitializationEvent event); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java deleted file mode 100755 index f1c8b3a9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide; - -import com.google.common.collect.Sets; -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.chat.ChatProcessor; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.commands.*; -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; -import kr.syeyoung.dungeonsguide.eventlistener.DungeonListener; -import kr.syeyoung.dungeonsguide.eventlistener.FeatureListener; -import kr.syeyoung.dungeonsguide.eventlistener.PacketListener; -import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.resources.DGTexturePack; -import kr.syeyoung.dungeonsguide.rpc.RichPresenceManager; -import kr.syeyoung.dungeonsguide.stomp.CloseListener; -import kr.syeyoung.dungeonsguide.stomp.StompClient; -import kr.syeyoung.dungeonsguide.stomp.StompInterface; -import kr.syeyoung.dungeonsguide.utils.AhUtils; -import kr.syeyoung.dungeonsguide.utils.TimeScoreUtil; -import kr.syeyoung.dungeonsguide.utils.cursor.GLCursors; -import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiErrorScreen; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.IReloadableResourceManager; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.client.resources.IResourcePack; -import net.minecraft.launchwrapper.LaunchClassLoader; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.ProgressManager; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.relauncher.ReflectionHelper; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import java.io.*; -import java.net.URI; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -public class DungeonsGuide implements DGInterface, CloseListener { - - private SkyblockStatus skyblockStatus; - - private static DungeonsGuide dungeonsGuide; - - - @Getter - private final Authenticator authenticator; - - @Getter - private StompInterface stompConnection; - @Getter - private CosmeticsManager cosmeticsManager; - - public DungeonsGuide(Authenticator authenticator) { - this.authenticator = authenticator; - } - - public static void sendDebugChat(IChatComponent iChatComponent) { - if (FeatureRegistry.DEBUG.isEnabled()) - Minecraft.getMinecraft().thePlayer.addChatMessage(iChatComponent); - } - @Getter - CommandReparty commandReparty; - - - private final String stompURL = "wss://dungeons.guide/ws"; -// private String stompURL = "ws://localhost/ws"; - public void init(FMLInitializationEvent event) { - ProgressManager.ProgressBar progressbar = ProgressManager.push("DungeonsGuide", 4); - - - try { - Set invalid = ReflectionHelper.getPrivateValue(LaunchClassLoader.class, (LaunchClassLoader) Main.class.getClassLoader(), "invalidClasses"); - ((LaunchClassLoader) Main.class.getClassLoader()).clearNegativeEntries(Sets.newHashSet("org.slf4j.LoggerFactory")); - invalid.clear(); - } catch (Throwable t) { - t.printStackTrace(); - } - - progressbar.step("Registering Events & Commands"); - dungeonsGuide = this; - skyblockStatus = new SkyblockStatus(); - - CommandDungeonsGuide commandDungeonsGuide; - MinecraftForge.EVENT_BUS.register(new DungeonListener()); - ClientCommandHandler.instance.registerCommand(commandDungeonsGuide = new CommandDungeonsGuide()); - MinecraftForge.EVENT_BUS.register(commandDungeonsGuide); - - commandReparty = new CommandReparty(); - MinecraftForge.EVENT_BUS.register(commandReparty); - - MinecraftForge.EVENT_BUS.register(new FeatureListener()); - MinecraftForge.EVENT_BUS.register(new PacketListener()); - MinecraftForge.EVENT_BUS.register(new Keybinds()); - -// MinecraftForge.EVENT_BUS.register(PartyManager.INSTANCE); - MinecraftForge.EVENT_BUS.register(ChatProcessor.INSTANCE); - MinecraftForge.EVENT_BUS.register(PartyManager.INSTANCE); - MinecraftForge.EVENT_BUS.register(StaticResourceCache.INSTANCE); - - AhUtils.registerTimer(); - - progressbar.step("Loading Roomdatas"); - try { - DungeonRoomInfoRegistry.loadAll(configDir); - } catch (BadPaddingException | InvalidKeyException | NoSuchPaddingException | IllegalBlockSizeException | IOException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) { - e.printStackTrace(); - } - progressbar.step("Opening connection"); - - cosmeticsManager = new CosmeticsManager(); - MinecraftForge.EVENT_BUS.register(cosmeticsManager); - - try { - connectStomp(); - } catch (Exception e) { - throw new RuntimeException(e); - } - - - progressbar.step("Loading Config"); - try { - Config.loadConfig( null ); - } catch (IOException e) { - e.printStackTrace(); - } - - if (FeatureRegistry.ETC_REPARTY.isEnabled()) - ClientCommandHandler.instance.registerCommand(commandReparty); - if (FeatureRegistry.DISCORD_DONOTUSE.isEnabled()) - System.setProperty("dg.safe", "true"); - MinecraftForge.EVENT_BUS.register(RichPresenceManager.INSTANCE); - TimeScoreUtil.init(); - - ProgressManager.pop(progressbar); - - ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(resourceManager -> GLCursors.setupCursors()); - } - @Getter - private boolean firstTimeUsingDG = false; - public void pre(FMLPreInitializationEvent event) { - t.start(); - configDir = new File(event.getModConfigurationDirectory(),"dungeonsguide"); - File configFile = new File(configDir, "config.json"); - if (!configFile.exists()) { - configDir.mkdirs(); - firstTimeUsingDG = true; - } - Config.f = configFile; - Minecraft.getMinecraft().getFramebuffer().enableStencil(); - - try { - List resourcePackList = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(),"defaultResourcePacks", "aA", "field_110449_ao"); - resourcePackList.add(new DGTexturePack(authenticator)); - Minecraft.getMinecraft().refreshResources(); - } catch (Throwable t){ - t.printStackTrace(); - } - } - - @Getter - private File configDir; - - - public SkyblockStatus getSkyblockStatus() { - return skyblockStatus; - } - - public static DungeonsGuide getDungeonsGuide() { - return dungeonsGuide; - } - ScheduledExecutorService ex = Executors.newScheduledThreadPool(2); - @Override - public void onClose(int code, String reason, boolean remote) { - System.out.println("Stomp Connection closed, trying to reconnect - "+reason+ " - "+code); - connectStomp(); - } - - public void connectStomp() { - ex.schedule(() -> { - try { - stompConnection = new StompClient(new URI(stompURL), authenticator.getToken(), DungeonsGuide.this); - MinecraftForge.EVENT_BUS.post(new StompConnectedEvent(stompConnection)); - } catch (Exception e) { - e.printStackTrace(); - } - }, 5L, TimeUnit.SECONDS); - } - - private Thread t = new Thread(new Runnable() { - @Override - public void run() { - while (true) { - JsonObject obj = DungeonsGuide.getDungeonsGuide().getAuthenticator().getJwtPayload(DungeonsGuide.getDungeonsGuide().getAuthenticator().getToken()); - if (!obj.get("uuid").getAsString().equals(Minecraft.getMinecraft().getSession().getPlayerID())) { - if (Minecraft.getMinecraft().currentScreen instanceof GuiErrorScreen) return; - - final String[] a = new String[]{ - "User has changed current Minecraft session.", - "Please restart mc to revalidate Dungeons Guide", - "Hopefully this screen will be fixed in later release" - }; - final GuiScreen b = new GuiErrorScreen(null, null) { - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - for (int i = 0; i < a.length; ++i) { - drawCenteredString(fontRendererObj, a[i], width / 2, height / 3 + 12 * i, 0xFFFFFFFF); - } - } - - @Override - public void initGui() { - super.initGui(); - this.buttonList.clear(); - this.buttonList.add(new GuiButton(0, width / 2 - 50, height - 50, 100, 20, "close")); - } - - @Override - protected void actionPerformed(GuiButton button) { - FMLCommonHandler.instance().exitJava(-1, true); - } - }; - Minecraft.getMinecraft().displayGuiScreen(b); - return; - } - try { - Thread.sleep(100L); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - }); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/GuiLoadingError.java b/src/main/java/kr/syeyoung/dungeonsguide/GuiLoadingError.java index 4adb2624..68ce5262 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/GuiLoadingError.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/GuiLoadingError.java @@ -18,23 +18,26 @@ package kr.syeyoung.dungeonsguide; -import kr.syeyoung.dungeonsguide.gui.MPanel; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import org.lwjgl.opengl.GL11; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.PrintStream; public class GuiLoadingError extends GuiScreen { - private String stacktrace; - private Throwable throwable; - private GuiScreen originalGUI; - public GuiLoadingError(Throwable t, String stacktrace, GuiScreen originalGUI) { - this.throwable = t; - this.stacktrace = stacktrace; + static Throwable cause; + private final String stacktrace; + private final GuiScreen originalGUI; + public GuiLoadingError(GuiScreen originalGUI) { + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + PrintStream printStream = new PrintStream(byteArrayOutputStream); + cause.printStackTrace(printStream); + this.stacktrace = byteArrayOutputStream.toString(); + this.originalGUI = originalGUI; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/IDungeonGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/IDungeonGuide.java new file mode 100644 index 00000000..a568d827 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/IDungeonGuide.java @@ -0,0 +1,10 @@ +package kr.syeyoung.dungeonsguide; + +/** + * This exists, so we can reload the mod/ download a more recent version + */ +public interface IDungeonGuide { + void init(); + void preinit(); + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java deleted file mode 100755 index 1235d29e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide; - -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.InputEvent; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -public class Keybinds -{ - - @SubscribeEvent - public void onTogglePathfindStatus(InputEvent.KeyInputEvent keyInputEvent) { - if (Keyboard.getEventKeyState()) { - int key = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey(); - KeyBindPressedEvent keyBindPressedEvent = new KeyBindPressedEvent(key); - MinecraftForge.EVENT_BUS.post(keyBindPressedEvent); - } - } - @SubscribeEvent - public void onMousePressed(InputEvent.MouseInputEvent mouseInputEvent) { - if (Mouse.getEventButtonState()) { - int key = Mouse.getEventButton() - 100; - KeyBindPressedEvent keyBindPressedEvent = new KeyBindPressedEvent(key); - MinecraftForge.EVENT_BUS.post(keyBindPressedEvent); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Main.java b/src/main/java/kr/syeyoung/dungeonsguide/Main.java index 29ac0599..5cfc0622 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/Main.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/Main.java @@ -18,11 +18,13 @@ package kr.syeyoung.dungeonsguide; -import com.mojang.authlib.exceptions.AuthenticationException; +import kr.syeyoung.dungeonsguide.auth.AuthManager; +import kr.syeyoung.dungeonsguide.auth.InvalidDungeonsGuideCredentialsException; +import kr.syeyoung.dungeonsguide.auth.ResourceManager; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; import kr.syeyoung.dungeonsguide.url.DGStreamHandlerFactory; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import kr.syeyoung.dungeonsguide.utils.cursor.GLCursors; -import net.minecraft.client.gui.*; +import lombok.Getter; +import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.launchwrapper.LaunchClassLoader; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.common.MinecraftForge; @@ -33,110 +35,135 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; -import java.io.*; -import java.lang.reflect.InvocationTargetException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; -import java.security.*; -import java.security.cert.CertificateException; -import java.security.spec.InvalidKeySpecException; @Mod(modid = Main.MOD_ID, version = Main.VERSION) -public class Main -{ +public class Main { + public static final String MOD_ID = "skyblock_dungeons_guide"; - public static final String VERSION = "1.0"; + public static final String VERSION = "3.8.0"; + Logger logger = LogManager.getLogger("DG-main"); - private static Main main; - private DGInterface dgInterface; + IDungeonGuide dgInstance; private boolean isLoaded = false; - private Throwable cause; - private String stacktrace; - private boolean showedError = false; - + public static final String SERVER_URL = "https://dungeons.guide"; + public static final String SOME_FUNNY_KEY_THING = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxO89qtwG67jNucQ9Y44c" + + "IUs/B+5BeJPs7G+RG2gfs4/2+tzF/c1FLDc33M7yKw8aKk99vsBUY9Oo8gxxiEPB" + + "JitP/qfon2THp94oM77ZTpHlmFoqbZMcKGZVI8yfvEL4laTM8Hw+qh5poQwtpEbK" + + "Xo47AkxygxJasUnykER2+aSTZ6kWU2D4xiNtFA6lzqN+/oA+NaYfPS0amAvyVlHR" + + "n/8IuGkxb5RrlqVssQstFnxsJuv88qdGSEqlcKq2tLeg9hb8eCnl2OFzvXmgbVER" + + "0JaV+4Z02fVG1IlR3Xo1mSit7yIU6++3usRCjx2yfXpnGGJUW5pe6YETjNew3ax+" + + "FAZ4GePWCdmS7FvBnbbABKo5pE06ZTfDUTCjQlAJQiUgoF6ntMJvQAXPu48Vr8q/" + + "mTcuZWVnI6CDgyE7nNq3WNoq3397sBzxRohMxuqzl3T19zkfPKF05iV2Ju1HQMW5" + + "I119bYrmVD240aGESZc20Sx/9g1BFpNzQbM5PGUlWJ0dhLjl2ge4ip2hHciY3OEY" + + "p2Qy2k+xEdenpKdL+WMRimCQoO9gWe2Tp4NmP5dppDXZgPjXqjZpnGs0Uxs+fXqW" + + "cwlg3MbX3rFl9so/fhVf4p9oXZK3ve7z5D6XSSDRYECvsKIa08WAxJ/U6n204E/4" + + "xUF+3ZgFPdzZGn2PU7SsnOsCAwEAAQ=="; @EventHandler - public void initEvent(FMLInitializationEvent initializationEvent) - { + public void initEvent(final FMLInitializationEvent initializationEvent) { MinecraftForge.EVENT_BUS.register(this); - if (dgInterface != null) { - main = this; - try { - dgInterface.init(initializationEvent); - } catch (Exception e) { - cause = e; - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - PrintStream printStream = new PrintStream(byteArrayOutputStream); - e.printStackTrace(printStream); - stacktrace = new String(byteArrayOutputStream.toByteArray()); - - e.printStackTrace(); - } + try { + logger.info("init-ing DungeonsGuide"); + dgInstance.init(); + } catch (Exception e) { + handleException(e, null); } } + + + private boolean showedError = false; @SubscribeEvent(priority = EventPriority.HIGHEST) public void onGuiOpen(GuiOpenEvent guiOpenEvent) { if (!showedError && !isLoaded && guiOpenEvent.gui instanceof GuiMainMenu) { - guiOpenEvent.gui = new GuiLoadingError(cause, stacktrace, guiOpenEvent.gui); + guiOpenEvent.gui = new GuiLoadingError(guiOpenEvent.gui); showedError = true; } + } + + @Getter + static File configDir; + @EventHandler - public void preInit(FMLPreInitializationEvent preInitializationEvent) { - ProgressManager.ProgressBar progressBar = ProgressManager.push("DungeonsGuide", this.getClass().getResourceAsStream("/kr/syeyoung/dungeonsguide/e.class") == null ? 7 : 6); - Authenticator authenticator = new Authenticator(progressBar); - String token = null; + public void preInit(final FMLPreInitializationEvent preInitializationEvent) { + MinecraftForge.EVENT_BUS.register(new YoMamaOutdated()); + + ProgressManager.ProgressBar progressBar = null; + try { - token = authenticator.authenticateAndDownload(this.getClass().getResourceAsStream("/kr/syeyoung/dungeonsguide/DungeonsGuide.class") == null ? System.getProperty("dg.version") == null ? "nlatest" : System.getProperty("dg.version") : null); - if (token != null) { - main = this; - URL.setURLStreamHandlerFactory(new DGStreamHandlerFactory(authenticator)); - LaunchClassLoader classLoader = (LaunchClassLoader) Main.class.getClassLoader(); - classLoader.addURL(new URL("z:///")); - - try { - progressBar.step("Initializing"); - this.dgInterface = new DungeonsGuide(authenticator); - this.dgInterface.pre(preInitializationEvent); - while (progressBar.getStep() < progressBar.getSteps()) - progressBar.step("random-"+progressBar.getStep()); - ProgressManager.pop(progressBar); - isLoaded = true; - } catch (Throwable e) { - cause = e; - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - PrintStream printStream = new PrintStream(byteArrayOutputStream); - e.printStackTrace(printStream); - stacktrace = new String(byteArrayOutputStream.toByteArray()); - - while (progressBar.getStep() < progressBar.getSteps()) - progressBar.step("random-"+progressBar.getStep()); - ProgressManager.pop(progressBar); - - e.printStackTrace(); + try (InputStream premiumControlClass = this.getClass().getResourceAsStream("/kr/syeyoung/dungeonsguide/e.class")) { + progressBar = ProgressManager.push("DungeonsGuide", premiumControlClass == null ? 7 : 6); + } + + AuthManager.getInstance().setBaseserverurl(SERVER_URL); + AuthManager.getInstance().init(); + + + configDir = new File(preInitializationEvent.getModConfigurationDirectory(), "dungeonsguide"); + + + String version = null; + try (InputStream resourceAsStream = this.getClass().getResourceAsStream("/kr/syeyoung/dungeonsguide/DungeonsGuide.class")) { + if (resourceAsStream == null) { + if (System.getProperty("dg.version") == null) { + version = "nlatest"; + } else { + version = System.getProperty("dg.version"); + } } + }catch (Exception e){ + e.printStackTrace(); } - } catch (IOException | AuthenticationException | NoSuchAlgorithmException | CertificateException | KeyStoreException | KeyManagementException | InvalidKeySpecException | SignatureException e) { - cause = e; - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - PrintStream printStream = new PrintStream(byteArrayOutputStream); - e.printStackTrace(printStream); - stacktrace = new String(byteArrayOutputStream.toByteArray()); - - while (progressBar.getStep() < progressBar.getSteps()) - progressBar.step("random-"+progressBar.getStep()); - ProgressManager.pop(progressBar); - - e.printStackTrace(); + ResourceManager.getInstance().setBaseUrl(Main.SERVER_URL); + ResourceManager.getInstance().setBASE64_X509ENCODEDKEYSPEC(Main.SOME_FUNNY_KEY_THING); + + if(!AuthManager.getInstance().isPlebUser() && version != null){ + ResourceManager.getInstance().downloadAssets(version); + } + + URL.setURLStreamHandlerFactory(new DGStreamHandlerFactory()); + LaunchClassLoader classLoader = (LaunchClassLoader) Main.class.getClassLoader(); + classLoader.addURL(new URL("z:///")); + + progressBar.step("Initializing"); + + dgInstance = new DungeonsGuide(); + dgInstance.preinit(); + + finishUpProgressBar(progressBar); + isLoaded = true; + + } catch (IOException | InvalidDungeonsGuideCredentialsException e) { + handleException(e, progressBar); } } - public static Main a() { - return main; + + public void handleException(@NotNull final Throwable e, ProgressManager.ProgressBar progressBar) { + GuiLoadingError.cause = e; + + finishUpProgressBar(progressBar); + + e.printStackTrace(); + } + + public static void finishUpProgressBar(final ProgressManager.ProgressBar progressBar) { + if(progressBar == null) return; + while (progressBar.getStep() < progressBar.getSteps()) + progressBar.step("random-" + progressBar.getStep()); + ProgressManager.pop(progressBar); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java b/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java deleted file mode 100755 index 7e2286b3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide; - -import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.commands.*; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.scoreboard.*; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.common.MinecraftForge; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import java.io.File; -import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.Collection; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class SkyblockStatus { - @Getter - private boolean isOnSkyblock; - private boolean isOnDungeon; - - public boolean isOnDungeon() { - return forceIsOnDungeon || isOnDungeon; - } - - @Getter @Setter - private boolean forceIsOnDungeon; - - @Getter - @Setter - private DungeonContext context; - - @Getter - @Setter - private int percentage; - - @Getter @Setter - private String dungeonName; - - public boolean isOnHypixel() { - Minecraft mc = Minecraft.getMinecraft(); - if (mc == null || mc.thePlayer == null) return false; - if (!mc.isSingleplayer() && mc.thePlayer.getClientBrand() != null) { - return mc.thePlayer.getClientBrand().startsWith("Hypixel BungeeCord"); - } - return false; - } - - private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK"); - - public void updateStatus() { - if (!isOnHypixel()) { - isOnDungeon = false; - isOnSkyblock = false; - return; - } - - Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); - ScoreObjective scoreObjective = scoreboard.getObjectiveInDisplaySlot(1); - if (scoreObjective == null) return; - - String objectiveName = TextUtils.stripColor(scoreObjective.getDisplayName()); - boolean skyblockFound = false; - for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { - if (objectiveName.startsWith(skyblock)) { - skyblockFound = true; - isOnSkyblock = true; - break; - } - } - - if (!skyblockFound) { - isOnSkyblock = false; - isOnDungeon = false; - return; - } - - Collection scores = scoreboard.getSortedScores(scoreObjective); - boolean foundDungeon = false; - for (Score sc:scores) { - ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); - String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); - if (strippedLine.contains("Cleared: ")) { - foundDungeon = true; - percentage = Integer.parseInt(strippedLine.substring(9).split(" ")[0]); - } - if (ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()).startsWith(" ยง7โฃ")) { - dungeonName = strippedLine.trim(); - } - } - - isOnDungeon = foundDungeon; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/YoMamaOutdated.java b/src/main/java/kr/syeyoung/dungeonsguide/YoMamaOutdated.java new file mode 100644 index 00000000..ca9b34f4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/YoMamaOutdated.java @@ -0,0 +1,110 @@ +package kr.syeyoung.dungeonsguide; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.*; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; + +import java.io.IOException; + +public class YoMamaOutdated { + + Logger logger = LogManager.getLogger("YoMamaOutdated"); + + public boolean isUsingOutdatedDg = true; + String outdatedMessage; + + public YoMamaOutdated() { + MinecraftForge.EVENT_BUS.register(this); + this.check(); + } + + void check() { + + isUsingOutdatedDg = false; + +// try (CloseableHttpClient httpclient = HttpClients.createDefault()) { +// HttpGet httpget = new HttpGet( "https://dungeonsguide.kingstefan26.workers.dev/outdated"); +// Header[] haeders = {new BasicHeader("User-Agent", "DungeonsGuide/" + Main.VERSION)}; +// httpget.setHeaders(haeders); +// HttpResponse httpresponse = httpclient.execute(httpget); +// +// if (httpresponse.getStatusLine().getStatusCode() != 200) { +// outdatedMessage = IOUtils.toString(httpresponse.getEntity().getContent(), StandardCharsets.UTF_8); +// }else { +// isUsingOutdatedDg = false; +// } +// +// } catch (Exception ignored) { +// } + + } + + private boolean showedError = false; + + @SubscribeEvent + public void onGuiOpen(GuiOpenEvent event) { + if (!showedError && isUsingOutdatedDg) { + showedError = true; + + GuiScreen ogGui = event.gui; + + event.gui = new GuiScreen() { + @Override + public void initGui() { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + this.buttonList.add(new GuiButton(0, sr.getScaledWidth()/2-100,sr.getScaledHeight()-70 ,"Close Minecraft")); + this.buttonList.add(new GuiButton(1, sr.getScaledWidth()/2-100,sr.getScaledHeight()-40 ,"Ignore")); + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + super.actionPerformed(button); + if (button.id == 0) { + FMLCommonHandler.instance().exitJava(-1,true); + } else if (button.id == 1) { + Minecraft.getMinecraft().displayGuiScreen(ogGui); + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawBackground(1); + + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + String text = "This DungeonsGuide installation seems to be invalid"; + fontRenderer.drawString(text, (sr.getScaledWidth()-fontRenderer.getStringWidth(text))/2,40,0xFFFF0000); + String text1 = "Message from our server:"; + fontRenderer.drawString(text1, (sr.getScaledWidth()-fontRenderer.getStringWidth(text1))/2, (int) (40+fontRenderer.FONT_HEIGHT*1.5),0xFFFF0000); + + int tenth = sr.getScaledWidth() / 10; + + Gui.drawRect(tenth, 70,sr.getScaledWidth()-tenth, sr.getScaledHeight()-80, 0xFF5B5B5B); + clip(sr, tenth, 70,sr.getScaledWidth()-2*tenth, sr.getScaledHeight()-150); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + + fontRenderer.drawString(outdatedMessage, tenth+2,fontRenderer.FONT_HEIGHT + 72, 0xFFFFFFFF); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + super.drawScreen(mouseX, mouseY, partialTicks); + } + + public void clip(ScaledResolution resolution, int x, int y, int width, int height) { + if (width < 0 || height < 0) return; + + int scale = resolution.getScaleFactor(); + GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); + } + }; + } + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/auth/AuthManager.java b/src/main/java/kr/syeyoung/dungeonsguide/auth/AuthManager.java new file mode 100644 index 00000000..5588a4a2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/auth/AuthManager.java @@ -0,0 +1,150 @@ +package kr.syeyoung.dungeonsguide.auth; + +import com.google.common.base.Throwables; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.google.gson.JsonObject; +import com.mojang.authlib.exceptions.AuthenticationException; +import kr.syeyoung.dungeonsguide.auth.authprovider.AuthProvider; +import kr.syeyoung.dungeonsguide.auth.authprovider.DgAuth.DgAuth; +import kr.syeyoung.dungeonsguide.auth.authprovider.DgAuth.DgAuthUtil; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.events.impl.AuthChangedEvent; +import kr.syeyoung.dungeonsguide.mod.stomp.StompManager; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; +import java.util.Objects; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; + + +public class AuthManager { + Logger logger = LogManager.getLogger("AuthManger"); + + private static AuthManager instance; + + public static AuthManager getInstance() { + if(instance == null) instance = new AuthManager(); + return instance; + } + + + @Setter + private String baseserverurl = "https://dungeons.guide"; + + private AuthProvider currentProvider; + + public String getToken() { + if (currentProvider != null && currentProvider.getToken() != null) { + return currentProvider.getToken(); + } + return null; + } + + public KeyPair getKeyPair(){ + if (currentProvider != null && currentProvider.getToken() != null) { + return currentProvider.getRsaKey(); + } + return null; + } + + + boolean initlock = false; + + public void init() { + if (initlock) { + logger.info("Cannot init AuthManger twice"); + return; + } + + reauth(); + + initlock = true; + + + MinecraftForge.EVENT_BUS.register(this); + + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("DgAuth Pool").build(); + final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, namedThreadFactory); + scheduler.scheduleAtFixedRate(() -> { + if (getToken() != null) { + JsonObject obj = DgAuthUtil.getJwtPayload(getToken()); + if (!obj.get("uuid").getAsString().replace("-", "").equals(Minecraft.getMinecraft().getSession().getPlayerID())) { + shouldReAuth = true; + } + } + }, 10,2000, TimeUnit.MILLISECONDS); + } + + boolean shouldReAuth = true; + int tickCounter; + + @SubscribeEvent + public void onTickClientTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + + if (tickCounter % 200 == 0) { + tickCounter = 0; + reauth(); + } + tickCounter++; + + } + + public boolean isPlebUser(){ + return Objects.equals(getInstance().getPlanType(), "OPENSOURCE"); + } + + public String getPlanType(){ + if(getToken() == null) return null; + + + JsonObject jwt = DgAuthUtil.getJwtPayload(getToken()); + + if(!jwt.has("plan")) return null; + + return jwt.get("plan").getAsString(); + + } + + void reauth() { + if (!shouldReAuth) return; + + shouldReAuth = false; + + currentProvider = null; + try { + currentProvider = new DgAuth(baseserverurl).createAuthProvider(); + if (currentProvider.getToken() == null) { + shouldReAuth = true; + currentProvider = null; + ChatTransmitter.addToQueue("ยงeDungeons Guide ยง7:: ยงrยงcDG auth failed, trying again in ten seconds", true); + logger.info("DG auth failed, trying again in a second"); + } else { + // RE-AUTHed SUCCESSFULLY HOORAY + // for some reason the forge events don't work in pre init, so I call the callback directly + StompManager.getInstance().init(); + MinecraftForge.EVENT_BUS.post(new AuthChangedEvent()); + } + } catch (NoSuchAlgorithmException | AuthenticationException | IOException e) { + + shouldReAuth = true; + currentProvider = null; + ChatTransmitter.addToQueue("ยงeDungeons Guide ยง7:: ยงrยงcDG auth failed, trying again in ten seconds", true); + logger.error("Re-auth failed with message {}, trying again in a ten seconds", String.valueOf(Throwables.getRootCause(e))); + } + + } + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/auth/AuthUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/auth/AuthUtil.java new file mode 100644 index 00000000..d96b054d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/auth/AuthUtil.java @@ -0,0 +1,70 @@ +package kr.syeyoung.dungeonsguide.auth; + +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import javax.net.ssl.HttpsURLConnection; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.security.*; + +public class AuthUtil { + private AuthUtil() {} + + public static KeyPair getKeyPair() throws NoSuchAlgorithmException { + KeyPairGenerator a = null; + a = KeyPairGenerator.getInstance("RSA"); + a.initialize(1024); + return a.generateKeyPair(); + } + + + public static JsonElement getJsonSecured(String u) throws IOException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException{ + + int length = 0; + CipherInputStream cipherInputStream = null; + + HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL(u).openConnection(); + httpsURLConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + httpsURLConnection.setRequestProperty("Content-Type", "application/json"); + httpsURLConnection.setRequestMethod("GET"); + httpsURLConnection.setRequestProperty("Authorization", AuthManager.getInstance().getToken()); + httpsURLConnection.setDoInput(true); + httpsURLConnection.setDoOutput(true); + + InputStream inputStream = httpsURLConnection.getInputStream(); + byte[] lengthPayload = new byte[4]; + inputStream.read(lengthPayload); + length = ((lengthPayload[0] & 0xFF) << 24) | + ((lengthPayload[1] & 0xFF) << 16) | + ((lengthPayload[2] & 0xFF) << 8) | + ((lengthPayload[3] & 0xFF)); + while (inputStream.available() < length) ; + byte[] keyPayload = new byte[length]; + inputStream.read(keyPayload); + + Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + cipher.init(Cipher.DECRYPT_MODE, AuthManager.getInstance().getKeyPair().getPrivate()); + byte[] AESKey = cipher.doFinal(keyPayload); + + cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + SecretKeySpec secretKeySpec = new SecretKeySpec(AESKey, "AES"); + IvParameterSpec ivParameterSpec = new IvParameterSpec(AESKey); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); + cipherInputStream = new CipherInputStream(inputStream, cipher); + cipherInputStream.read(lengthPayload); + length = ((lengthPayload[0] & 0xFF) << 24) | + ((lengthPayload[1] & 0xFF) << 16) | + ((lengthPayload[2] & 0xFF) << 8) | + ((lengthPayload[3] & 0xFF)); + + httpsURLConnection.disconnect(); + + return new JsonParser().parse(new InputStreamReader(cipherInputStream)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/auth/InvalidDungeonsGuideCredentialsException.java b/src/main/java/kr/syeyoung/dungeonsguide/auth/InvalidDungeonsGuideCredentialsException.java new file mode 100644 index 00000000..98caa049 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/auth/InvalidDungeonsGuideCredentialsException.java @@ -0,0 +1,8 @@ +package kr.syeyoung.dungeonsguide.auth; + +public class InvalidDungeonsGuideCredentialsException extends Throwable { + + public InvalidDungeonsGuideCredentialsException(String message) { + super(message); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/auth/ResourceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/auth/ResourceManager.java new file mode 100644 index 00000000..56d46aea --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/auth/ResourceManager.java @@ -0,0 +1,164 @@ +package kr.syeyoung.dungeonsguide.auth; + +import lombok.Setter; +import net.minecraftforge.common.MinecraftForge; +import org.apache.commons.codec.binary.Base64; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import javax.net.ssl.HttpsURLConnection; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.security.*; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.X509EncodedKeySpec; +import java.util.HashMap; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +public class ResourceManager { + + Logger logger = LogManager.getLogger("ResourceManager"); + + @Setter + private String baseUrl; + @Setter + private String BASE64_X509ENCODEDKEYSPEC; + private final HashMap loadedResources = new HashMap<>(); + + + private static ResourceManager instance; + public static ResourceManager getInstance() { + if(instance == null) { + instance = new ResourceManager(); + MinecraftForge.EVENT_BUS.register(instance); + } + return instance; + } + + private ResourceManager() { + } + + public Map getResources() { + return loadedResources; + } + + + public void downloadAssets(String version) throws InvalidDungeonsGuideCredentialsException { + if(AuthManager.getInstance().getToken() == null) throw new InvalidDungeonsGuideCredentialsException("Not Authenticated while downloading assets"); + try { + // version not being null indicates that the user is "premium" + // so we download the special version + if (version != null) + downloadSafe( baseUrl + "/resource/version?v=" + version, true); + + if(!AuthManager.getInstance().isPlebUser()){ + downloadSafe(baseUrl + "/resource/roomdata", false); + } else { + logger.error("The current User is a pleb not downloading user data"); + } + + } catch (Exception t) { + t.printStackTrace(); + } + + } + + private void downloadSafe(String url, boolean isValidateSignature) throws IOException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, SignatureException, InvalidKeySpecException { + HttpsURLConnection dgConnection = (HttpsURLConnection) new URL(url).openConnection(); + dgConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + dgConnection.setRequestProperty("Content-Type", "application/json"); + dgConnection.setRequestMethod("GET"); + dgConnection.setRequestProperty("Authorization", AuthManager.getInstance().getToken()); + dgConnection.setDoInput(true); + dgConnection.setDoOutput(true); + + InputStream inputStream = dgConnection.getInputStream(); + byte[] lengthBytes = new byte[4]; + inputStream.read(lengthBytes); + int length = ((lengthBytes[0] & 0xFF) << 24) | + ((lengthBytes[1] & 0xFF) << 16) | + ((lengthBytes[2] & 0xFF) << 8) | + ((lengthBytes[3] & 0xFF)); + while (inputStream.available() < length) ; + byte[] keyPayload = new byte[length]; + inputStream.read(keyPayload); + + Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + cipher.init(Cipher.DECRYPT_MODE, AuthManager.getInstance().getKeyPair().getPrivate()); + byte[] h = cipher.doFinal(keyPayload); + + cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + SecretKeySpec keySpec = new SecretKeySpec(h, "AES"); + IvParameterSpec ivSpec = new IvParameterSpec(h); + cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); + CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); + + cipherInputStream.read(lengthBytes); + length = ((lengthBytes[0] & 0xFF) << 24) | + ((lengthBytes[1] & 0xFF) << 16) | + ((lengthBytes[2] & 0xFF) << 8) | + ((lengthBytes[3] & 0xFF)); + + int totalLen = length; + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + byte[] buff = new byte[256]; + while (totalLen > 0) { + int len = cipherInputStream.read(buff, 0, Math.min(buff.length, totalLen)); + totalLen -= len; + bos.write(buff, 0, len); + } + byte[] body = bos.toByteArray(); + + byte[] signed; + if (isValidateSignature) { + cipherInputStream.read(lengthBytes,0 , 4); + length = ((lengthBytes[0] & 0xFF) << 24) | + ((lengthBytes[1] & 0xFF) << 16) | + ((lengthBytes[2] & 0xFF) << 8) | + ((lengthBytes[3] & 0xFF)); + + totalLen = length; + bos = new ByteArrayOutputStream(); + while (totalLen > 0) { + int len = cipherInputStream.read(buff, 0, Math.min(buff.length, totalLen)); + totalLen -= len; + bos.write(buff, 0, len); + } + signed = bos.toByteArray(); + + Signature sign = Signature.getInstance("SHA512withRSA"); + sign.initVerify(getPublicKey(BASE64_X509ENCODEDKEYSPEC)); + sign.update(body); + boolean truth = sign.verify(signed); + if (!truth) throw new SignatureException("DG SIGNATURE FORGED"); + } + + ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(body)); + ZipEntry zipEntry; + while ((zipEntry=zipInputStream.getNextEntry()) != null) { + byte[] buffer = new byte[256]; + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + int p; + while((p = zipInputStream.read(buffer)) > 0) { + byteArrayOutputStream.write(buffer, 0, p); + } + this.loadedResources.put(zipEntry.getName(), byteArrayOutputStream.toByteArray()); + } + } + + + public static PublicKey getPublicKey(String base64X509EncodedKeySpec) throws NoSuchAlgorithmException, InvalidKeySpecException { + X509EncodedKeySpec spec = new X509EncodedKeySpec(Base64.decodeBase64(base64X509EncodedKeySpec)); + + return KeyFactory.getInstance("RSA").generatePublic(spec); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/AuthProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/AuthProvider.java new file mode 100644 index 00000000..ba42574e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/AuthProvider.java @@ -0,0 +1,16 @@ +package kr.syeyoung.dungeonsguide.auth.authprovider; + +import com.mojang.authlib.exceptions.AuthenticationException; + +import java.io.IOException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; + +public interface AuthProvider { + String getToken(); + + KeyPair getRsaKey(); + + + AuthProvider createAuthProvider() throws NoSuchAlgorithmException, AuthenticationException, IOException; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/DgAuth/DgAuth.java b/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/DgAuth/DgAuth.java new file mode 100644 index 00000000..0e7a05f6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/DgAuth/DgAuth.java @@ -0,0 +1,46 @@ +package kr.syeyoung.dungeonsguide.auth.authprovider.DgAuth; + +import com.mojang.authlib.exceptions.AuthenticationException; +import kr.syeyoung.dungeonsguide.auth.AuthUtil; +import kr.syeyoung.dungeonsguide.auth.authprovider.AuthProvider; + +import java.io.IOException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; + +public class DgAuth implements AuthProvider { + + private final String authServerUrl; + + public DgAuth(String authServerUrl){ + this.authServerUrl = authServerUrl; + } + + private String token; + private KeyPair rsaKey; + + @Override + public String getToken() { + return token; + } + + @Override + public KeyPair getRsaKey() { + return rsaKey; + } + + + @Override + public AuthProvider createAuthProvider() throws NoSuchAlgorithmException, AuthenticationException, IOException { + this.rsaKey = AuthUtil.getKeyPair(); + + String tempToken = DgAuthUtil.requestAuth(this.authServerUrl); + + DgAuthUtil.checkSessionAuthenticity(tempToken); + + this.token = DgAuthUtil.verifyAuth(tempToken, rsaKey.getPublic(), authServerUrl); + + return this; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/DgAuth/DgAuthUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/DgAuth/DgAuthUtil.java new file mode 100644 index 00000000..b01fba50 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/DgAuth/DgAuthUtil.java @@ -0,0 +1,88 @@ +package kr.syeyoung.dungeonsguide.auth.authprovider.DgAuth; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.exceptions.AuthenticationException; +import com.mojang.authlib.minecraft.MinecraftSessionService; +import net.minecraft.client.Minecraft; +import net.minecraft.util.Session; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.IOUtils; + +import javax.net.ssl.HttpsURLConnection; +import java.io.IOException; +import java.math.BigInteger; +import java.net.URL; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.PublicKey; + +public class DgAuthUtil { + private DgAuthUtil(){} + + public static String requestAuth(String baseurl) throws IOException { + GameProfile profile = Minecraft.getMinecraft().getSession().getProfile(); + + HttpsURLConnection connection = (HttpsURLConnection) new URL(baseurl + "/auth/requestAuth").openConnection(); + connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setRequestMethod("POST"); + connection.setDoInput(true); + connection.setDoOutput(true); + + connection.getOutputStream().write(("{\"uuid\":\""+profile.getId().toString()+"\",\"nickname\":\""+profile.getName()+"\"}").getBytes()); + String payload = String.join("\n", IOUtils.readLines(connection.getErrorStream() == null ? connection.getInputStream() : connection.getErrorStream())); + + JsonObject json = (JsonObject) new JsonParser().parse(payload); + + if (!"ok".equals(json.get("status").getAsString())) { + return null; + } + return json.get("data").getAsString(); + } + + public static void checkSessionAuthenticity(String tempToken) throws NoSuchAlgorithmException, AuthenticationException { + JsonObject d = getJwtPayload(tempToken); + byte[] sharedSecret = Base64.decodeBase64(d.get("sharedSecret").getAsString()); + byte[] publicKey =Base64.decodeBase64(d.get("publicKey").getAsString()); + String hash = calculateServerHash(sharedSecret, publicKey); + + Session session = Minecraft.getMinecraft().getSession(); + MinecraftSessionService yggdrasilMinecraftSessionService = Minecraft.getMinecraft().getSessionService(); + yggdrasilMinecraftSessionService.joinServer(session.getProfile(), session.getToken(), hash); + } + + public static String verifyAuth(String tempToken, PublicKey clientKey, String baseurl) throws IOException { + HttpsURLConnection urlConnection = (HttpsURLConnection) new URL(baseurl + "/auth/authenticate").openConnection(); + urlConnection.setRequestMethod("POST"); + urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + urlConnection.setRequestProperty("Content-Type", "application/json"); + urlConnection.setDoInput(true); + urlConnection.setDoOutput(true); + + urlConnection.getOutputStream().write(("{\"jwt\":\""+tempToken+"\",\"publicKey\":\""+Base64.encodeBase64URLSafeString(clientKey.getEncoded())+"\"}").getBytes()); + String payload = String.join("\n", IOUtils.readLines(urlConnection.getErrorStream() == null ? urlConnection.getInputStream() : urlConnection.getErrorStream())); + + JsonObject jsonObject = (JsonObject) new JsonParser().parse(payload); + if (!"ok".equals(jsonObject.get("status").getAsString())) { + return null; + } + return jsonObject.get("data").getAsString(); + } + + public static JsonObject getJwtPayload(String jwt) { + String midPart = jwt.split("\\.")[1].replace("+", "-").replace("/", "_"); + String base64Decode = new String(Base64.decodeBase64(midPart)); // padding + return (JsonObject) new JsonParser().parse(base64Decode); + } + + public static String calculateServerHash(byte[] a, byte[] b) throws NoSuchAlgorithmException { + MessageDigest c = MessageDigest.getInstance("SHA-1"); + c.update("".getBytes()); + c.update(a); + c.update(b); + byte[] d = c.digest(); + return new BigInteger(d).toString(16); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/NullAuth.java b/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/NullAuth.java new file mode 100644 index 00000000..ec7e9aed --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/auth/authprovider/NullAuth.java @@ -0,0 +1,62 @@ +package kr.syeyoung.dungeonsguide.auth.authprovider; + +import com.mojang.authlib.exceptions.AuthenticationException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.PublicKey; + +public class NullAuth implements AuthProvider { + + Logger logger = LogManager.getLogger("NullAuth"); + + @Override + public String getToken() { + return "TOKEN"; + } + + @Override + public KeyPair getRsaKey() { + return new KeyPair(new PublicKey() { + @Override + public String getAlgorithm() { + return null; + } + + @Override + public String getFormat() { + return null; + } + + @Override + public byte[] getEncoded() { + return new byte[0]; + } + }, new PrivateKey() { + @Override + public String getAlgorithm() { + return null; + } + + @Override + public String getFormat() { + return null; + } + + @Override + public byte[] getEncoded() { + return new byte[0]; + } + }); + } + + @Override + public AuthProvider createAuthProvider() throws NoSuchAlgorithmException, AuthenticationException, IOException { + return new NullAuth(); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatProcessResult.java b/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatProcessResult.java deleted file mode 100644 index 94bafa95..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatProcessResult.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.chat; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@AllArgsConstructor -@Getter -public enum ChatProcessResult { - NONE(false, false), REMOVE_LISTENER(true, false), REMOVE_LISTENER_AND_CHAT(true, true), REMOVE_CHAT(false, true); - - private boolean removeListener; - private boolean removeChat; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatProcessor.java deleted file mode 100644 index 5fc666e2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatProcessor.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.chat; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.Tuple; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.simple.SimpleLogger; - -import java.util.*; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.CopyOnWriteArrayList; - -public class ChatProcessor { - public static final ChatProcessor INSTANCE = new ChatProcessor(); - - private static final Logger logger = LogManager.getLogger(); - private ChatProcessor() { - Logger l = LogManager.getLogger(GuiNewChat.class); - if (l instanceof SimpleLogger) { - ((SimpleLogger) l).setLevel(Level.OFF); - } else if (l instanceof org.apache.logging.log4j.core.Logger) { - ((org.apache.logging.log4j.core.Logger) l).setLevel(Level.OFF); - } - } - - private Queue chatSubscriberQueue = new ConcurrentLinkedQueue<>(); - private Queue> chatQueue = new ConcurrentLinkedQueue<>(); - - public void subscribe(ChatSubscriber chatSubscribed) { - chatSubscriberQueue.add(chatSubscribed); - } - public void addToChatQueue(String chat, Runnable onSend, boolean noDupe) { - if (noDupe && chatQueue.stream().anyMatch(a -> a.getFirst().trim().equalsIgnoreCase(chat.trim()))) return; - chatQueue.add(new Tuple<>(chat, onSend)); - } - - - private long minimumNext = 0; - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent clientTickEvent) { - try { - if (clientTickEvent.phase == TickEvent.Phase.START && Minecraft.getMinecraft().thePlayer != null && minimumNext < System.currentTimeMillis()) { - if (!chatQueue.isEmpty()) { - Tuple tuple = chatQueue.poll(); - Minecraft.getMinecraft().thePlayer.sendChatMessage(tuple.getFirst()); - if (tuple.getSecond() != null) - tuple.getSecond().run(); - minimumNext = System.currentTimeMillis() + 200; - DungeonsGuide.sendDebugChat(new ChatComponentText("Sending " + tuple.getFirst() + " Secretly")); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - - - @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) - public void onMessage(ClientChatReceivedEvent chatReceivedEvent) { - if (chatReceivedEvent.type == 2) return; - String txt = chatReceivedEvent.message.getFormattedText(); - logger.log(Level.INFO, "[CHAT] "+txt); - - int processed = 0; - int listenened = 0; - Map context = new HashMap<>(); - Iterator it = chatSubscriberQueue.iterator(); - while (it.hasNext()) { - ChatSubscriber chatSubscribed = it.next(); - context.put("removed", processed); - context.put("onceListenered", listenened); - ChatProcessResult chatProcessResult = chatSubscribed.process(txt, context); - if (chatProcessResult.isRemoveChat()) processed++; - if (chatProcessResult.isRemoveListener()) listenened++; - - if (chatProcessResult.isRemoveChat()) chatReceivedEvent.setResult(Event.Result.DENY); - if (chatProcessResult.isRemoveListener()) it.remove(); - } - } - - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void cancelMessage(ClientChatReceivedEvent chatReceivedEvent) { - if (chatReceivedEvent.getResult() == Event.Result.DENY) - chatReceivedEvent.setCanceled(true); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatSubscriber.java b/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatSubscriber.java deleted file mode 100644 index 72879eb0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/chat/ChatSubscriber.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.chat; - -import java.util.Map; - -@FunctionalInterface -public interface ChatSubscriber { - ChatProcessResult process(String txt, Map context); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/chat/PartyContext.java b/src/main/java/kr/syeyoung/dungeonsguide/chat/PartyContext.java deleted file mode 100644 index 87d1a264..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/chat/PartyContext.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.chat; - -import lombok.Data; -import net.minecraft.client.Minecraft; - -import java.util.HashSet; -import java.util.Set; -import java.util.TreeSet; - - -@Data -public class PartyContext { - private String partyID; - - private String partyOwner; - private Set partyModerator; private boolean isModeratorComplete; - private Set partyMember; private boolean isMemberComplete; - - private Set partyRawMembers = new HashSet<>(); private boolean isRawMemberComplete; - - private Boolean allInvite; - - private boolean partyExistHypixel = true; - - public void setPartyOwner(String partyOwner) { - this.partyOwner = partyOwner; - if (partyMember != null) partyMember.remove(partyOwner); - if (partyModerator != null) partyModerator.remove(partyOwner); - addRawMember(partyOwner); - } - public void addPartyModerator(String partyModerator) { - if (partyModerator.equalsIgnoreCase(partyOwner)) partyOwner = null; - if (partyMember != null) partyMember.remove(partyModerator); - - if (this.partyModerator == null) this.partyModerator = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); - this.partyModerator.add(partyModerator); - addRawMember(partyModerator); - } - public void addPartyMember(String partyMember) { - if (partyMember.equalsIgnoreCase(partyOwner)) partyOwner = null; - if (partyModerator != null) partyModerator.remove(partyMember); - - if (this.partyMember == null) this.partyMember = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); - this.partyMember.add(partyMember); - addRawMember(partyMember); - } - public void addRawMember(String partyMember){ - partyRawMembers.add(partyMember); - } - public void removeFromParty(String username) { - if (username.equalsIgnoreCase(partyOwner)) { - partyOwner = null; - } - if (partyModerator != null) partyModerator.remove(username); - if (partyMember != null) partyMember.remove(username); - partyRawMembers.remove(username); - } - - public boolean hasModerator(String username) { - return partyModerator != null && partyModerator.contains(username); - } - public boolean hasMember(String username) { - return partyMember != null && partyMember.contains(username); - } - public boolean hasLeader(String username) { - return username.equalsIgnoreCase(partyOwner); - } - public boolean isSelfSolo() { - return hasLeader(Minecraft.getMinecraft().getSession().getUsername()) && getPartyRawMembers().size() == 1; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/chat/PartyManager.java b/src/main/java/kr/syeyoung/dungeonsguide/chat/PartyManager.java deleted file mode 100644 index 3053c74c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/chat/PartyManager.java +++ /dev/null @@ -1,605 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.chat; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.events.HypixelJoinedEvent; -import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; -import kr.syeyoung.dungeonsguide.stomp.*; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.json.JSONArray; -import org.json.JSONObject; - -import java.security.SecureRandom; -import java.util.*; -import java.util.function.Consumer; - -public class PartyManager implements StompMessageHandler { - public static final PartyManager INSTANCE = new PartyManager(); - @Getter - private PartyContext partyContext; - - public PartyContext getPartyContext(boolean createIfNeeded) { - PartyContext pc = partyContext == null && createIfNeeded ? partyContext = new PartyContext() : partyContext; - if (createIfNeeded) - pc.addRawMember(Minecraft.getMinecraft().getSession().getUsername()); - return pc; - } - - @Getter - @Setter - private int maxParty = 5; - @Getter - private String askToJoinSecret = null; - - private static final SecureRandom random = new SecureRandom(); - private static final String validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"; - - - private Set> partyBuiltCallback = new HashSet<>(); - - public PartyManager() { - ChatProcessor cp = ChatProcessor.INSTANCE; - // Not in Party - cp.subscribe((str, a) -> { - if (str.equals("ยงcYou are not currently in a party.ยงr") - || str.equals("ยงeYou left the party.ยงr") - || str.equals("ยงcYou must be in a party to join the party channel!ยงr") - || str.equals("ยงcThe party was disbanded because all invites expired and the party was emptyยงr") - || str.equals("ยงcYou are not in a party and were moved to the ALL channel.ยงr") - || str.startsWith("ยงcThe party was disbanded") - || str.endsWith("ยงehas disbanded the party!ยงr") - || str.startsWith("ยงcYou are not in a party") - || str.startsWith("ยงeYou have been kicked from the party by ")) { - leaveParty(); - - for (Consumer partyContextConsumer : partyBuiltCallback) { - try { - partyContextConsumer.accept(null); - } catch (Exception e) { - e.printStackTrace(); - } - } - partyBuiltCallback.clear(); - a.put("type", "notinparty"); - } - return ChatProcessResult.NONE; - }); - // All invite - cp.subscribe((str, a) -> { - if (str.endsWith("ยงaenabled All Inviteยงr")) { - getPartyContext(true).setAllInvite(true); - a.put("type", "allinvite_on"); - } else if (str.endsWith("ยงcdisabled All Inviteยงr") - || str.equals("ยงcYou are not allowed to invite players.ยงr")) { - getPartyContext(true).setAllInvite(false); - a.put("type", "allinvite_off"); - potentialInvitenessChange(); - } - return ChatProcessResult.NONE; - }); - // Member building - cp.subscribe(new ChatSubscriber() { - boolean memberExpected; - PartyContext partyContext = new PartyContext(); - @Override - public ChatProcessResult process(String txt, Map context) { - if (txt.startsWith("ยง6Party Members ")) { - memberExpected = true; - partyContext = new PartyContext(); - partyContext.setPartyModerator(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); - partyContext.setPartyMember(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); - context.put("type", "member_start"); - } else if (txt.startsWith("ยงeParty ") && txt.contains(":")){ - String role = txt.split(":")[0]; - String playerNames = TextUtils.stripColor(txt.split(":")[1]); - for (String s : playerNames.split(" ")) { - if (s.isEmpty()) continue; - if (s.equals("โ—")) continue; - if (s.startsWith("[")) continue; - partyContext.addRawMember(s); - if (role.contains("Moder")) partyContext.addPartyModerator(s); - if (role.contains("Member")) partyContext.addPartyMember(s); - if (role.contains("Leader")) partyContext.setPartyOwner(s); - } - if (role.contains("Moder")) { - partyContext.setModeratorComplete(true); - context.put("type", "member_moder"); - } - if (role.contains("Member")) { - partyContext.setMemberComplete(true); - context.put("type", "member_member"); - } - if (role.contains("Leader")) { - context.put("type", "member_leader"); - } - } else if (txt.startsWith("ยง9ยงm---------------------------")) { - if (memberExpected) { - PartyContext old = getPartyContext(true); - old.setPartyOwner(partyContext.getPartyOwner()); - old.setPartyModerator(partyContext.getPartyModerator()); - old.setPartyMember(partyContext.getPartyMember()); - old.setPartyRawMembers(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); - old.getPartyRawMembers().addAll(old.getPartyMember()); - old.getPartyRawMembers().addAll(old.getPartyModerator()); - old.getPartyRawMembers().add(old.getPartyOwner()); - old.setModeratorComplete(true); old.setMemberComplete(true); - old.setRawMemberComplete(true); - old.setPartyExistHypixel(true); - - memberExpected = false; - context.put("type", "member_end"); - - for (Consumer partyContextConsumer : partyBuiltCallback) { - try { - partyContextConsumer.accept(partyContext); - } catch (Exception e) { - e.printStackTrace(); - } - } - partyBuiltCallback.clear(); - - if (old.getPartyID() == null) { - joinedParty(); - } - potentialInvitenessChange(); - } - } - return ChatProcessResult.NONE; - } - }); - // Player party join / leave - cp.subscribe((str ,a) -> { - if (str.endsWith("ยงejoined the party.ยงr")) { - String username = null; - for (String s : TextUtils.stripColor(str).split(" ")) { - if (s.startsWith("[")) continue; - username = s; - break; - } - if (username != null) { - getPartyContext(true).addPartyMember(username); - } - a.put("type", "party_join"); - } else if (str.endsWith("ยงehas been removed from the party.ยงr") - || str.endsWith("ยงehas left the party.ยงr")) { - String username = null; - for (String s : TextUtils.stripColor(str).split(" ")) { - if (s.startsWith("[")) continue; - username = s; - break; - } - if (username != null && partyContext != null) { - getPartyContext().removeFromParty(username); - } - a.put("type", "party_leave"); - } else if (str.endsWith(" They have ยงrยงc60 ยงrยงeseconds to accept.ยงr")) { - String[] messageSplit = TextUtils.stripColor(str).split(" "); - String inviter = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - inviter = s; - break; - } - if (inviter != null && partyContext != null) { - if (getPartyContext().hasMember(inviter)) { - getPartyContext().setAllInvite(true); - } - } - getPartyContext(true).setPartyExistHypixel(true); - a.put("type", "party_invite_exist"); - } else if (str.equals("ยงcCouldn't find a player with that name!ยงr") || str.equals("ยงcYou cannot invite that player since they're not online.")) { - a.put("type", "party_invite_noexist"); - String username = Minecraft.getMinecraft().getSession().getUsername(); - if (partyContext != null && getPartyContext().hasMember(username)) { - getPartyContext().setAllInvite(true); - } - } - return ChatProcessResult.NONE; - }); - // Promotion - cp.subscribe((str, a) -> { - if (str.startsWith("ยงeThe party was transferred to ")) { - // ยงeThe party was transferred to ยงrยงb[MVPยงrยงf+ยงrยงb] apotato321 ยงrยงeby ยงrยงa[VIPยงrยง6+ยงrยงa] syeyoungยงr - String[] messageSplit = TextUtils.stripColor(str.substring(31)).split(" "); - String newLeader = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - newLeader = s; - break; - } - String oldLeader; - boolean left= false; - if (str.endsWith("ยงrยงeleftยงr")) { - oldLeader = messageSplit[messageSplit.length-2]; - left = true; - } else { - oldLeader = messageSplit[messageSplit.length-1]; - } - - if (oldLeader != null && newLeader != null ) { - getPartyContext(true).setPartyOwner(newLeader); - if (left) - getPartyContext(true).removeFromParty(oldLeader); - else - getPartyContext(true).addPartyModerator(oldLeader); - } - a.put("type", "party_transfer"); - potentialInvitenessChange(); - } else if (str.endsWith("ยงeto Party Leaderยงr")) { - // ยงa[VIPยงrยง6+ยงrยงa] syeyoungยงrยงe has promoted ยงrยงb[MVPยงrยงf+ยงrยงb] apotato321 ยงrยงeto Party Leaderยงr - String[] messageSplit = TextUtils.stripColor(str).split(" "); - String oldLeader = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - oldLeader = s; - break; - } - messageSplit = TextUtils.stripColor(str.substring(str.indexOf("has promoted") + 13)).split(" "); - String newLeader = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - newLeader = s; - break; - } - - if (oldLeader != null && newLeader != null) { - getPartyContext(true).setPartyOwner(newLeader); - getPartyContext(true).addPartyModerator(oldLeader); - } - a.put("type", "party_transfer"); - potentialInvitenessChange(); - } else if (str.endsWith("ยงrยงeto Party Moderatorยงr")) { - // ยงb[MVPยงrยงf+ยงrยงb] apotato321ยงrยงe has promoted ยงrยงa[VIPยงrยง6+ยงrยงa] syeyoung ยงrยงeto Party Moderatorยงr - String[] messageSplit = TextUtils.stripColor(str).split(" "); - String oldLeader = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - oldLeader = s; - break; - } - messageSplit = TextUtils.stripColor(str.substring(str.indexOf("has promoted") + 13)).split(" "); - String newModerator = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - newModerator = s; - break; - } - - if (oldLeader != null && newModerator != null) { - getPartyContext(true).setPartyOwner(oldLeader); - getPartyContext(true).addPartyModerator(newModerator); - } - a.put("type", "party_promotion"); - potentialInvitenessChange(); - } else if (str.endsWith("ยงrยงeto Party Memberยงr")) { - String[] messageSplit = TextUtils.stripColor(str).split(" "); - String oldLeader = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - oldLeader = s; - break; - } - messageSplit = TextUtils.stripColor(str.substring(str.indexOf("has demoted") + 12)).split(" "); - String newMember = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - newMember = s; - break; - } - - if (oldLeader != null && newMember != null) { - getPartyContext(true).setPartyOwner(oldLeader); - getPartyContext(true).addPartyMember(newMember); - } - a.put("type", "party_demotion"); - potentialInvitenessChange(); - } - return ChatProcessResult.NONE; - }); - // Player Join - cp.subscribe(new ChatSubscriber() { - boolean joined; - @Override - public ChatProcessResult process(String str, Map context) { - if (str.startsWith("ยงeYou have joined ")) { - String[] messageSplit = TextUtils.stripColor(str.substring(18)).split(" "); - String leader = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - leader = s; - break; - } - leader = leader.substring(0, leader.length()-2); // remove 's - partyContext = new PartyContext(); - getPartyContext().setPartyOwner(leader); - getPartyContext().addPartyMember(Minecraft.getMinecraft().getSession().getUsername()); - context.put("type", "party_selfjoin_leader"); - joined= true; - } else if (str.startsWith("ยงeYou'll be partying with: ")) { - String[] players = TextUtils.stripColor(str.substring(27)).split(" "); - for (String player : players) { - if (player.startsWith("[")) continue; - getPartyContext().addRawMember(player); - } - context.put("type", "party_selfjoin_players"); - } else if (str.startsWith("ยง9ยงm---------------------------") && joined) { - joined = false; - getPartyContext().setRawMemberComplete(true); - joinedParty(); - potentialInvitenessChange(); - } - return ChatProcessResult.NONE; - }}); - // Player Join Dungon - cp.subscribe((str, a)-> { - if (str.contains("ยงrยงejoined the dungeon group! (ยงrยงb")) { - String username = TextUtils.stripColor(str).split(" ")[3]; - if (username.equalsIgnoreCase(Minecraft.getMinecraft().getSession().getUsername())) { - partyContext = new PartyContext(); - requestPartyList((str2) -> { - potentialInvitenessChange(); - }); - } else { - getPartyContext(true).setMemberComplete(false); - requestPartyList((str2) -> {}); - } - } - return ChatProcessResult.NONE; - }); - } - - public void toggleAllowAskToJoin() { - if (canInvite()) { - if (askToJoinSecret != null) askToJoinSecret = null; - else { - updateAskToJoin(); - } - } - } - - public void updateAskToJoin() { - StringBuilder secretBuilder = new StringBuilder(); - for (int i = 0; i < 20; i++) { - secretBuilder.append(validChars.charAt(random.nextInt(validChars.length()))); - } - askToJoinSecret = secretBuilder.toString(); - - StompInterface stompInterface = DungeonsGuide.getDungeonsGuide().getStompConnection(); - stompInterface.send(new StompPayload().payload(new JSONObject().put("secret", askToJoinSecret).toString()).header("destination", "/app/party.setjoinsecret")); - } - - public static ChatSubscriber dashShredder() { - return (str, a) -> (int)a.get("removed") == 0 && str.startsWith("ยง9ยงm---------------------------") ? ChatProcessResult.REMOVE_LISTENER_AND_CHAT : ChatProcessResult.NONE; - } - - public static ChatSubscriber typeShredder(boolean end, String... types) { - return (str, a) -> (int)a.get("removed") == 0 &&Arrays.stream(types).anyMatch(s -> s.equals(a.getOrDefault("type", null))) ? (end ? ChatProcessResult.REMOVE_LISTENER_AND_CHAT : ChatProcessResult.REMOVE_CHAT) : ChatProcessResult.NONE; - } - - public static ChatSubscriber combinedShredder(ChatSubscriber... chatSubscribers) { - return (str, a) -> { - boolean removeChat = false; - boolean removeListener = false; - for (ChatSubscriber chatSubscriber : chatSubscribers) { - ChatProcessResult chatProcessResult = chatSubscriber.process(str, a); - if (chatProcessResult.isRemoveChat()) removeChat = true; - if (chatProcessResult.isRemoveListener()) removeListener = true; - } - return (removeChat && removeListener) ? ChatProcessResult.REMOVE_LISTENER_AND_CHAT : (removeChat ? ChatProcessResult.REMOVE_CHAT : (removeListener ? ChatProcessResult.REMOVE_LISTENER : ChatProcessResult.NONE)); - }; - } - - @SubscribeEvent - public void onHypixelJoin(HypixelJoinedEvent skyblockJoinedEvent) { - partyContext = null; - requestPartyList((a) -> { - if (a == null) return; - if (isLeader() || isModerator()) return; - if (a.getAllInvite() != null) return; - requestAllInvite(); - }); - } - - private void leaveParty() { - if (partyContext != null) { - getPartyContext().setPartyExistHypixel(false); - if (getPartyContext().isSelfSolo()) return; - if (getPartyContext().getPartyID() != null) { - JSONObject object = new JSONObject(); - object.put("partyid", getPartyContext().getPartyID()); - StompInterface stompInterface = DungeonsGuide.getDungeonsGuide().getStompConnection(); - stompInterface.send(new StompPayload().payload(object.toString()).header("destination", "/app/party.leave")); - } - } - - partyContext = new PartyContext(); - playerInvAntiSpam.clear(); - - getPartyContext().setPartyExistHypixel(false); - getPartyContext().setPartyOwner(Minecraft.getMinecraft().getSession().getUsername()); - getPartyContext().setPartyModerator(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); getPartyContext().setMemberComplete(true); - getPartyContext().setPartyMember(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); getPartyContext().setModeratorComplete(true); - getPartyContext().setAllInvite(false); - joinedParty(); - } - private void joinedParty() { - JSONArray jsonArray = new JSONArray(); - for (String member : getPartyContext().getPartyRawMembers()) { - jsonArray.put(member); - } - JSONObject object = new JSONObject(); - object.put("members", jsonArray); - StompInterface stompInterface = DungeonsGuide.getDungeonsGuide().getStompConnection(); - stompInterface.send(new StompPayload().payload(object.toString()).header("destination", "/app/party.join")); - - getPartyContext().setPartyID("!@#!@#!@#..........FETCHING..........$!@$!@$!@$"+UUID.randomUUID().toString()); - } - - public boolean isLeader() { - return partyContext != null && getPartyContext().hasLeader(Minecraft.getMinecraft().getSession().getUsername()); // "getUsername" - } - public boolean isModerator() { - return partyContext != null && getPartyContext().hasModerator(Minecraft.getMinecraft().getSession().getUsername()); - } - public boolean canInvite() { - return isLeader() || isModerator() || (partyContext != null && getPartyContext().getAllInvite() != null && getPartyContext().getAllInvite()); - } - - private boolean requested = false; - public void requestPartyList(Consumer onPartyCallback) { - if (requested) { - partyBuiltCallback.add(onPartyCallback); - return; - } - requested = true; - - ChatProcessor.INSTANCE.addToChatQueue("/pl", () -> { - ChatProcessor.INSTANCE.subscribe(dashShredder()); - ChatProcessor.INSTANCE.subscribe(combinedShredder(typeShredder(true, "member_end"), dashShredder(), typeShredder(false,"notinparty", "member_start", "member_moder", "member_leader", "member_member"))); - }, true); - partyBuiltCallback.add(onPartyCallback); - partyBuiltCallback.add(pc -> requested=false); - } - - public void requestAllInvite() { - if (isLeader() || isModerator()) return; - if (partyContext != null && getPartyContext().getAllInvite() != null) return; - - ChatProcessor.INSTANCE.addToChatQueue("/p invite -", () -> { - ChatProcessor.INSTANCE.subscribe(dashShredder()); - ChatProcessor.INSTANCE.subscribe(typeShredder(true, "notinparty", "allinvite_off", "party_invite_noexist")); - ChatProcessor.INSTANCE.subscribe(dashShredder()); - }, true); - } - - private Map playerInvAntiSpam = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - - @Override - public void handle(StompInterface stompInterface, StompPayload stompPayload) { - JSONObject object = new JSONObject(stompPayload.payload()); - if ("/user/queue/party.check".equals(stompPayload.headers().get("destination"))) { - String playerName = object.getString("player"); - String token = object.getString("token"); - if (partyContext == null) { - requestPartyList((pc) -> { - boolean contains = pc.getPartyRawMembers().contains(playerName); - if (!contains) { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().payload(new JSONObject().put("status", "failure").put("token", token).toString()).header("destination", "/app/party.check.resp")); - } else { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().payload(new JSONObject().put("status", "success").put("token", token).toString()).header("destination", "/app/party.check.resp")); - } - }); - } else { - if (getPartyContext().getPartyRawMembers().contains(playerName)) { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().payload(new JSONObject().put("status", "success").put("token", token).toString()).header("destination", "/app/party.check.resp")); - } else if (getPartyContext().isMemberComplete() && getPartyContext().isModeratorComplete() && getPartyContext().getPartyOwner() != null) { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().payload(new JSONObject().put("status", "failure").put("token", token).toString()).header("destination", "/app/party.check.resp")); - } else { - requestPartyList((pc) -> { - boolean contains = pc.getPartyRawMembers().contains(playerName); - if (!contains) { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().payload(new JSONObject().put("status", "failure").put("token", token).toString()).header("destination", "/app/party.check.resp")); - } else { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().payload(new JSONObject().put("status", "success").put("token", token).toString()).header("destination", "/app/party.check.resp")); - } - }); - } - } - } else if ("/user/queue/party.broadcast".equals(stompPayload.headers().get("destination"))) { - try { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: Message Broadcasted from player:: \n" + new JSONObject(stompPayload.payload()).getString("payload"))); - } catch (Exception e) { - e.printStackTrace(); - } - } else if ("/user/queue/party.join".equals(stompPayload.headers().get("destination"))) { - String playerName = object.getString("player"); - String secret = object.getString("secret"); - if (secret.equals(askToJoinSecret) && partyContext != null && getPartyContext().getPartyRawMembers().size() < maxParty && playerInvAntiSpam.getOrDefault(playerName, 0L) < System.currentTimeMillis() - 5000) { - playerInvAntiSpam.put(playerName, System.currentTimeMillis()); - ChatProcessor.INSTANCE.addToChatQueue("/p invite "+playerName,() -> {}, true); - } - } else if ("/user/queue/party.askedtojoin.resp".equals(stompPayload.headers().get("destination"))) { - String invFrom = object.getString("username"); - String token2 = object.getString("token"); - if (!token2.equals(lastToken)) return; - lastToken = null; - ChatProcessor.INSTANCE.addToChatQueue("/p accept "+invFrom, () -> {}, true); - long end = System.currentTimeMillis() + 3000; - ChatProcessor.INSTANCE.subscribe((str, a) -> { - if (!str.contains("ยงrยงehas invited you to join their party!")) return System.currentTimeMillis() > end ? ChatProcessResult.REMOVE_LISTENER : ChatProcessResult.NONE; - String[] messageSplit = TextUtils.stripColor(str).split(" "); - String inviter = null; - for (String s : messageSplit) { - if (s.startsWith("[")) continue; - if (s.startsWith("-")) continue;; - inviter = s; - break; - } - if (invFrom.equalsIgnoreCase(inviter)) { - ChatProcessor.INSTANCE.addToChatQueue("/p accept "+invFrom, () -> {}, true); - } - return ChatProcessResult.NONE; - }); - } else { - String str = object.getString("status"); - if ("success".equals(str) && partyContext != null) { - getPartyContext().setPartyID(object.getString("partyId")); - if (askToJoinSecret != null) { - updateAskToJoin(); - } - } else if (partyContext != null){ - getPartyContext().setPartyID(null); - } - } - } - - @SubscribeEvent - public void stompConnect(StompConnectedEvent stompConnectedEvent) { - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/party.resp").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/party.check").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/party.broadcast").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/party.join").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/party.askedtojoin.resp").build()); - } - - private String lastToken; - public void joinWithToken(String secret) { - lastToken = secret; - if (partyContext != null && getPartyContext().isPartyExistHypixel()) - ChatProcessor.INSTANCE.addToChatQueue("/p leave", () -> {}, true); - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().method(StompHeader.SEND) - .header("destination", "/app/party.askedtojoin") - .payload(new JSONObject().put("token", secret).toString())); - } - - private void potentialInvitenessChange() { - if (askToJoinSecret != null && !canInvite()) askToJoinSecret = null; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java deleted file mode 100644 index 95850fdc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ /dev/null @@ -1,602 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.commands; - -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.chat.PartyContext; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.rpc.RichPresenceManager; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfigV2; -import kr.syeyoung.dungeonsguide.config.guiconfig.NestedCategory; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.MapProcessor; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProvider; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProviderRegistry; -import kr.syeyoung.dungeonsguide.dungeon.events.DungeonEventHolder; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; -import kr.syeyoung.dungeonsguide.events.DungeonLeftEvent; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerStatsOnJoin; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.ApiFetcher; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessor; -import kr.syeyoung.dungeonsguide.stomp.*; -import kr.syeyoung.dungeonsguide.utils.AhUtils; -import kr.syeyoung.dungeonsguide.utils.MapUtils; -import kr.syeyoung.dungeonsguide.utils.ShortUtils; -import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.*; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.json.JSONObject; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.vecmath.Vector2d; -import java.awt.*; -import java.io.*; -import java.security.*; -import java.security.cert.CertificateException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.List; -import java.util.regex.Pattern; - -public class CommandDungeonsGuide extends CommandBase { - @Override - public String getCommandName() { - return "dg"; - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return "dg"; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (args.length == 0) { - openConfig = true; - } else if (args[0].equalsIgnoreCase("saverooms")) { - DungeonRoomInfoRegistry.saveAll(DungeonsGuide.getDungeonsGuide().getConfigDir()); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully saved user generated roomdata")); - } else if (args[0].equalsIgnoreCase("loadrooms")) { - try { - DungeonRoomInfoRegistry.loadAll(DungeonsGuide.getDungeonsGuide().getConfigDir()); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully loaded roomdatas")); - return; - } catch (BadPaddingException e) { - e.printStackTrace(); - } catch (InvalidAlgorithmParameterException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcAn error has occurred while loading roomdata")); - } else if (args[0].equalsIgnoreCase("reloadah")) { - try { - AhUtils.loadAuctions(); - } catch (CertificateException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidAlgorithmParameterException e) { - e.printStackTrace(); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - } catch (BadPaddingException e) { - e.printStackTrace(); - } catch (KeyStoreException e) { - e.printStackTrace(); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - } catch (KeyManagementException e) { - e.printStackTrace(); - } - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfReloaded Ah data")); - } else if (args[0].equalsIgnoreCase("brand")) { - String serverBrand = Minecraft.getMinecraft().thePlayer.getClientBrand(); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + serverBrand)); - } else if (args[0].equalsIgnoreCase("reparty")) { - if (!DungeonsGuide.getDungeonsGuide().getCommandReparty().requestReparty(false)) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCurrently Repartying")); - } - } else if (args[0].equalsIgnoreCase("gui")) { - openConfig = true; - } else if (args[0].equalsIgnoreCase("info")) { - JsonObject obj = DungeonsGuide.getDungeonsGuide().getAuthenticator().getJwtPayload(DungeonsGuide.getDungeonsGuide().getAuthenticator().getToken()); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); - - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfCurrent Planยง7: ยงe" + obj.get("plan").getAsString())); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfBound toยง7: ยงe" + obj.get("nickname").getAsString())); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfBound uuidยง7: ยงe" + obj.get("uuid").getAsString())); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSession Expireยง7: ยงe" + sdf.format(new Date(obj.get("exp").getAsLong() * 1000)))); - } else if (args[0].equalsIgnoreCase("pathfind")) { - try { - DungeonContext context = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext(); - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - if (thePlayer == null) return; - if (context.getBossfightProcessor() != null) context.getBossfightProcessor().tick(); - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - grp.pathfind("COMMAND", args[1], args[2], FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.getRouteProperties()); - } catch (Throwable t) { - t.printStackTrace(); - } - } else if (args[0].equals("process") && Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")) { - File root = DungeonsGuide.getDungeonsGuide().getConfigDir(); - File dir = new File(root, "processorinput"); - File outsecret = new File(root, "processoroutsecret"); - for (File f : dir.listFiles()) { - if (!f.getName().endsWith(".roomdata")) continue; - try { - InputStream fis = new FileInputStream(f); - ObjectInputStream ois = new ObjectInputStream(fis); - DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); - ois.close(); - fis.close(); - dri.setUserMade(false); - - FileOutputStream fos = new FileOutputStream(new File(outsecret, dri.getUuid().toString() + ".roomdata")); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(dri); - oos.flush(); - oos.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } else if (args[0].equals("check") && Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")) { - File root = DungeonsGuide.getDungeonsGuide().getConfigDir(); - for (File f : root.listFiles()) { - if (!f.getName().endsWith(".roomdata")) continue; - try { - InputStream fis = new FileInputStream(f); - ObjectInputStream ois = new ObjectInputStream(fis); - DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); - ois.close(); - fis.close(); - System.out.println("Starting at " + dri.getName() + " - " + dri.getUuid()); - for (Map.Entry value2 : dri.getMechanics().entrySet()) { - DungeonMechanic value = value2.getValue(); - if (value instanceof DungeonSecret && - (((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.BAT - || ((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.CHEST) - && ((DungeonSecret) value).getSecretPoint().getY() == 0) { - OffsetPoint offsetPoint = ((DungeonSecret) value).getSecretPoint(); - if (dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { - dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing " + value2.getKey() + " - as secret " + ((DungeonSecret) value).getSecretType() + " - at " + ((DungeonSecret) value).getSecretPoint()); - } - } else if (value instanceof DungeonOnewayDoor) { - for (OffsetPoint offsetPoint : ((DungeonOnewayDoor) value).getSecretPoint().getOffsetPointList()) { - if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { - dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing " + value2.getKey() + " - o-door - at " + offsetPoint); - } - } - } else if (value instanceof DungeonDoor) { - for (OffsetPoint offsetPoint : ((DungeonDoor) value).getSecretPoint().getOffsetPointList()) { - if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { - dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing " + value2.getKey() + " - door - at " + offsetPoint); - } - } - } else if (value instanceof DungeonBreakableWall) { - for (OffsetPoint offsetPoint : ((DungeonBreakableWall) value).getSecretPoint().getOffsetPointList()) { - if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { - dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing " + value2.getKey() + " - wall - at " + offsetPoint); - } - } - } else if (value instanceof DungeonTomb) { - for (OffsetPoint offsetPoint : ((DungeonTomb) value).getSecretPoint().getOffsetPointList()) { - if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { - dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing " + value2.getKey() + " - crypt - at " + offsetPoint); - } - } - } - } - FileOutputStream fos = new FileOutputStream(f); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(dri); - oos.flush(); - oos.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } else if (args[0].equals("reloaddungeon") && Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")) { - try { - MinecraftForge.EVENT_BUS.post(new DungeonLeftEvent()); - DungeonsGuide.getDungeonsGuide().getSkyblockStatus().setContext(null); - MapUtils.clearMap(); - } catch (Throwable t) { - t.printStackTrace(); - } - } else if (args[0].equalsIgnoreCase("pvall")) { - PartyManager.INSTANCE.requestPartyList((context) -> { - if (context == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcNot in Party")); - return; - } - FeatureViewPlayerStatsOnJoin.processPartyMembers(context); - }); -// } else if (args[0].equals("fixschematic")) { -// File root = new File(e.getDungeonsGuide().getConfigDir(), "schematics"); -// Method method = null; -// try { -// method = NBTTagCompound.class.getDeclaredMethod("write", DataOutput.class); -// method.setAccessible(true); -// } catch (NoSuchMethodException e) { -// e.printStackTrace(); -// return; -// } -// for (File f : root.listFiles()) { -// try { -// NBTTagCompound nbtTagCompound = CompressedStreamTools.readCompressed(new FileInputStream(f)); -// if (nbtTagCompound.getKeySet().isEmpty()) { -// System.out.println("ah"); -// return; -// } -// nbtTagCompound.setString("Materials","Alpha"); -// FileOutputStream fos = new FileOutputStream(f); -// DataOutputStream dataoutputstream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fos))); -// -// try -// { -// dataoutputstream.writeByte(nbtTagCompound.getId()); -// -// dataoutputstream.writeUTF("Schematic"); -// method.invoke(nbtTagCompound, dataoutputstream); -// } -// finally -// { -// dataoutputstream.close(); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - } else if (args[0].equalsIgnoreCase("asktojoin") || args[0].equalsIgnoreCase("atj")) { - if (RichPresenceManager.INSTANCE.getLastSetupCode() == -9999) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcDiscord GameSDK has been disabled, or it failed to load!")); - return; - } - if (!PartyManager.INSTANCE.canInvite()) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcYou don't have perms in the party to invite people!")); - } else { - PartyManager.INSTANCE.toggleAllowAskToJoin(); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfToggled Ask to join to " + (PartyManager.INSTANCE.getAskToJoinSecret() != null ? "ยงeon" : "ยงcoff"))); - } - - if (!FeatureRegistry.DISCORD_RICHPRESENCE.isEnabled()) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcDiscord Rich Presence is disabled! Enable at /dg -> Discord ")); - } - if (!FeatureRegistry.DISCORD_ASKTOJOIN.isEnabled()) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcDiscord Invite Viewer is disabled! Enable at /dg -> Discord ")); // how - } - } else if (args[0].equalsIgnoreCase("partymax") || args[0].equalsIgnoreCase("pm")) { - if (args.length == 1) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfCurrent party max is ยงe" + PartyManager.INSTANCE.getMaxParty())); - } else if (args.length == 2) { - try { - int partyMax = Integer.parseInt(args[1]); - if (partyMax < 2) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcparty max can't be smaller than 2")); - return; - } - - PartyManager.INSTANCE.setMaxParty(partyMax); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully set partymax to ยงe" + PartyManager.INSTANCE.getMaxParty())); - } catch (Exception e) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงc" + args[1] + " is not valid number.")); - return; - } - } - } else if (args[0].equals("partyid")) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfInternal Party id: " + Optional.ofNullable(PartyManager.INSTANCE.getPartyContext()).map(PartyContext::getPartyID).orElse(null))); - } else if (args[0].equalsIgnoreCase("loc")) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfYou're in " + DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName())); - } else if (args[0].equalsIgnoreCase("saverun")) { - try { - File f = DungeonsGuide.getDungeonsGuide().getConfigDir(); - File runDir = new File(f, "dungeonruns"); - runDir.mkdirs(); - - File runFile = new File(runDir, UUID.randomUUID() + ".dgrun"); - - DungeonContext dungeonContext = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext(); - if (dungeonContext == null) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCouldn't find dungeon to save!")); - return; - } - DungeonEventHolder dungeonEventHolder = new DungeonEventHolder(); - dungeonEventHolder.setDate(dungeonContext.getInit()); - dungeonEventHolder.setPlayers(dungeonContext.getPlayers()); - dungeonEventHolder.setEventDataList(dungeonContext.getEvents()); - - - ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(runFile)); - oos.writeObject(dungeonEventHolder); - oos.flush(); - oos.close(); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully saved dungeon run to " + runFile.getAbsolutePath())); - } catch (Exception e) { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcAn error occured while writing rundata " + e.getMessage())); - e.printStackTrace(); - } - } else if (args[0].equals("pv")) { - try { - ApiFetcher.fetchUUIDAsync(args[1]) - .thenAccept(a -> { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + args[1] + "ยงf's Profile ").appendSibling(new ChatComponentText("ยง7view").setChatStyle(new ChatStyle().setChatHoverEvent(new FeatureViewPlayerStatsOnJoin.HoverEventRenderPlayer(a.orElse(null)))))); - }); - } catch (Exception e) { - e.printStackTrace(); - } - } else if (args[0].equals("purge")) { - ApiFetcher.purgeCache(); - CosmeticsManager cosmeticsManager = DungeonsGuide.getDungeonsGuide().getCosmeticsManager(); - cosmeticsManager.requestPerms(); - cosmeticsManager.requestCosmeticsList(); - cosmeticsManager.requestActiveCosmetics(); - StaticResourceCache.INSTANCE.purgeCache(); - FeatureRegistry.DISCORD_ASKTOJOIN.imageMap.clear(); - FeatureRegistry.DISCORD_ASKTOJOIN.futureMap.clear(); - - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully purged API Cache!")); - } else if (args[0].equals("pbroadcast")) { - try { - String[] payload = new String[args.length - 1]; - System.arraycopy(args, 1, payload, 0, payload.length); - String actualPayload = String.join(" ", payload).replace("$C$", "ยง"); - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().header("destination", "/app/party.broadcast").payload( - new JSONObject().put("partyID", PartyManager.INSTANCE.getPartyContext().getPartyID()) - .put("payload", actualPayload).toString() - )); - } catch (Exception e) { - e.printStackTrace(); - } - } else if (args[0].equals("requeststaticresource")) { - UUID uid = UUID.fromString(args[1]); - StaticResourceCache.INSTANCE.getResource(uid).thenAccept(a -> { - sender.addChatMessage(new ChatComponentText(a.getResourceID() + ": " + a.getValue() + ": " + a.isExists())); - }); - } else if (args[0].equals("createFakeRoom") && Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")) { - - // load schematic - File f = new File(DungeonsGuide.getDungeonsGuide().getConfigDir(), "schematics/new roonm-b2df250c-4af2-4201-963c-0ee1cb6bd3de-5efb1f0c-c05f-4064-bde7-cad0874fdf39.schematic"); - NBTTagCompound compound; - try { - compound = CompressedStreamTools.readCompressed(new FileInputStream(f)); - } catch (IOException e) { - e.printStackTrace(); - return; - } - - byte[] blocks = compound.getByteArray("Blocks"); - byte[] meta = compound.getByteArray("Data"); - for (int x = 0; x < compound.getShort("Width"); x++) { - for (int y = 0; y < compound.getShort("Height"); y++) { - for (int z = 0; z < compound.getShort("Length"); z++) { - int index = x + (y * compound.getShort("Length") + z) * compound.getShort("Width"); - BlockPos pos = new BlockPos(x, y, z); - World w = MinecraftServer.getServer().getEntityWorld(); - w.setBlockState(pos, Block.getBlockById(blocks[index] & 0xFF).getStateFromMeta(meta[index] & 0xFF), 2); - } - } - } - - - DungeonSpecificDataProviderRegistry.doorFinders.put(Pattern.compile("TEST DG"), new DungeonSpecificDataProvider() { - @Override - public BlockPos findDoor(World w, String dungeonName) { - return new BlockPos(0, 0, 0); - } - - @Override - public Vector2d findDoorOffset(World w, String dungeonName) { - return null; - } - - @Override - public BossfightProcessor createBossfightProcessor(World w, String dungeonName) { - return null; - } - - @Override - public boolean isTrapSpawn(String dungeonName) { - return false; - } - - @Override - public double secretPercentage(String dungeonName) { - return 0; - } - - @Override - public int speedSecond(String dungeonName) { - return 0; - } - }); - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - skyblockStatus.setDungeonName("TEST DG"); - DungeonContext fakeContext = new DungeonContext(Minecraft.getMinecraft().theWorld); - skyblockStatus.setContext(fakeContext); - skyblockStatus.setForceIsOnDungeon(true); - MapProcessor mapProcessor = fakeContext.getMapProcessor(); - mapProcessor.setUnitRoomDimension(new Dimension(16, 16)); - mapProcessor.setBugged(false); - mapProcessor.setDoorDimension(new Dimension(4, 4)); - mapProcessor.setTopLeftMapPoint(new Point(0, 0)); - fakeContext.setDungeonMin(new BlockPos(0, 70, 0)); - - DungeonRoom dungeonRoom = new DungeonRoom(Arrays.asList(new Point(0, 0)), ShortUtils.topLeftifyInt((short) 1), (byte) 63, new BlockPos(0, 70, 0), new BlockPos(31, 70, 31), fakeContext, Collections.emptySet()); - - fakeContext.getDungeonRoomList().add(dungeonRoom); - for (Point p : Arrays.asList(new Point(0, 0))) { - fakeContext.getRoomMapper().put(p, dungeonRoom); - } - - EditingContext.createEditingContext(dungeonRoom); - EditingContext.getEditingContext().openGui(new GuiDungeonRoomEdit(dungeonRoom)); - } else if (args[0].equals("CloseContext")) { - DungeonsGuide.getDungeonsGuide().getSkyblockStatus().setForceIsOnDungeon(false); - DungeonsGuide.getDungeonsGuide().getSkyblockStatus().setContext(null); - } else if (args[0].equals("dumpsettings")) { - NestedCategory root = new NestedCategory("ROOT"); - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - String category = abstractFeature.getCategory(); - NestedCategory currentRoot = root; - for (String s : category.split("\\.")) { - NestedCategory finalCurrentRoot = currentRoot; - if (currentRoot.children().containsKey(s)) - currentRoot = currentRoot.children().get(s); - else { - currentRoot.child(currentRoot = new NestedCategory(finalCurrentRoot.categoryFull() + "." + s)); - } - } - } - - StringBuilder stringBuilder = new StringBuilder(); - StringBuilder stringBuilder2 = new StringBuilder(); - - Stack> stak = new Stack<>(); - stak.push(new Tuple<>(root, 0)); - Set discovered = new HashSet<>(); - while (!stak.isEmpty()) { - Tuple n = stak.pop(); - if (discovered.contains(n.getFirst())) continue; - discovered.add(n.getFirst()); - for (Map.Entry stringNestedCategoryEntry : n.getFirst().children().entrySet()) { - stak.push(new Tuple<>(stringNestedCategoryEntry.getValue(), n.getSecond() + 1)); - } - - if (n.getFirst().categoryFull().equals("ROOT")) continue; - - String prefix = ""; - for (int i = 0; i < n.getSecond() - 1; i++) { - prefix += " "; - } - - List abstractFeatureList = FeatureRegistry.getFeaturesByCategory().getOrDefault(n.getFirst().categoryFull().substring(5), Collections.emptyList()); - stringBuilder.append(prefix).append("- C ").append(n.getFirst().categoryFull()).append("\n"); - stringBuilder2.append(n.getFirst().categoryFull()).append("\n"); - for (AbstractFeature abstractFeature : abstractFeatureList) { - stringBuilder.append(prefix).append(" - F ").append(abstractFeature.getName()).append(" / ").append(abstractFeature.getDescription().replace("\n", "$NEW_LINE$")).append("\n"); - } - } - System.out.println(stringBuilder.toString()); - System.out.println(stringBuilder2.toString()); - } else if (args[0].equals("readMap")) { - try { - int fromX = Integer.parseInt(args[1]); - int fromY = Integer.parseInt(args[2]); - sender.addChatMessage(new ChatComponentText(MapUtils.readDigit(MapUtils.getColors(), fromX, fromY)+"-")); -// int cntY = Integer.parseInt(args[3]); -// int target = Integer.parseInt(args[4]); -// StringBuilder sb = new StringBuilder("{"); -// for (int y = fromY; y < fromY + cntY; y++) { -// int curr = 0; -// for (int x = fromX; x < fromX+8; x++) { -// byte clr = MapUtils.getMapColorAt(MapUtils.getColors(), x,y); -// if (clr == target) curr = (curr << 1) | 1; -// else curr <<= 1; -// } -// sb.append("0x").append(Integer.toHexString(curr).toUpperCase()); -// if (y != fromY + cntY - 1) sb.append(", "); -// } -// sb.append("}"); -// System.out.println("\n"+sb.toString()); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg ยง7-ยงfOpens configuration gui")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg gui ยง7-ยงfOpens configuration gui")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg help ยง7-ยงfShows command help")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg saverooms ยง7-ยงf Saves usergenerated dungeon roomdata.")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg loadrooms ยง7-ยงf Reloads dungeon roomdata.")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg reloadah ยง7-ยงf Reloads price data from server.")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg brand ยง7-ยงf View server brand.")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg reparty ยง7-ยงf Reparty.")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg info ยง7-ยงf View Current DG User info.")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg asktojoin or /dg atj ยง7-ยงf Toggle ask to join ยงcRequires Discord Rich Presence enabled. (/dg -> Advanced)")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg partymax [number] or /dg pm [number] ยง7-ยงf Sets partymax ยง7(maximum amount people in party, for discord rpc)")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg pv [ign] ยง7-ยงf Profile Viewer")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg pvall ยง7-ยงf Profile Viewer For all people on party")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg purge ยง7-ยงf Purge api cache.")); - sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg saverun ยง7-ยงf Save run to be sent to developer.")); - } - } - - private boolean openConfig = false; - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent e) { - try { - if (openConfig && e.phase == TickEvent.Phase.START ) { - openConfig = false; - Minecraft.getMinecraft().displayGuiScreen(new GuiConfigV2()); - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java deleted file mode 100644 index 8df85529..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandReparty.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.commands; - -import kr.syeyoung.dungeonsguide.chat.ChatProcessor; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -public class CommandReparty extends CommandBase { - private String command; - public CommandReparty() { - command = FeatureRegistry.ETC_REPARTY.getParameter("command").getValue(); - command = command.replace(" ", ""); - } - - @Override - public String getCommandName() { - return command; - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return command; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (!requestReparty(false)) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCurrently Repartying")); - } - } - - private boolean reparting = false; - - - public boolean requestReparty(boolean noerror) { - if (reparting) { - return false; - } - reparting = true; - - PartyManager.INSTANCE.requestPartyList(pc -> { - if (pc == null) { - if (!noerror) - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcNot in Party")); - reparting = false; - return; - } - if (!pc.hasLeader(Minecraft.getMinecraft().getSession().getUsername())) { - if (!noerror) - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcYou're not leader")); - reparting = false; - return; - } - if (pc.isSelfSolo()) { - if (!noerror) - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcYou can not reparty yourself")); - reparting = false; - return; - } - String members = pc.getPartyRawMembers().stream().filter(a -> !a.equalsIgnoreCase(Minecraft.getMinecraft().getSession().getUsername())).collect(Collectors.joining(" ")); - String command = "/p invite "+members; - - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeDisbanding Party...")); - ChatProcessor.INSTANCE.addToChatQueue("/p disband", () -> { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeRunning invite command ยงf"+command)); - ChatProcessor.INSTANCE.addToChatQueue(command, () -> { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeSuccessfully repartied!ยงf")); - - reparting = false; - }, false); - }, false); - }); - return true; - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java deleted file mode 100644 index f8d60424..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; - -import java.io.*; - -public class Config { - public static JsonObject configuration; - - public static File f; - - public static void loadConfig(File f) throws IOException { - try { - configuration = (JsonObject) new JsonParser().parse(new InputStreamReader(new FileInputStream(Config.f = f == null ? Config.f : f))); - } catch (Exception e) { - configuration = new JsonObject(); - } - for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { - JsonObject object = configuration.getAsJsonObject(feature.getKey()); - if (object != null) feature.loadConfig(object); - } - - saveConfig(); - } - - public static void saveConfig() throws IOException { - for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { - JsonObject object = feature.saveConfig(); - configuration.add(feature.getKey(), object); - } - - String str = new Gson().toJson(configuration); - FileOutputStream fos = null; - try { - fos = new FileOutputStream(f); - BufferedWriter bos = new BufferedWriter(new OutputStreamWriter(fos)); - bos.write(str); - bos.flush(); - } finally { - fos.close(); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java deleted file mode 100644 index d02680bf..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Map; - -public class ConfigPanelCreator implements Function { - public static final ConfigPanelCreator INSTANCE = new ConfigPanelCreator(); - - public static final Map> map = new HashMap>(); - - @Nullable - @Override - public MPanel apply(@Nullable String input) { - if (!map.containsKey(input)) return null; - return map.get(input).get(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfigV2.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfigV2.java deleted file mode 100644 index d1888283..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfigV2.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.gui.MGui; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.util.MathHelper; - -import java.awt.*; - -public class GuiConfigV2 extends MGui { - - @Getter - private RootConfigPanel rootConfigPanel; - - public GuiConfigV2() { - rootConfigPanel = new RootConfigPanel(this); - getMainPanel().add(rootConfigPanel); - } - - - @Override - public void initGui() { - super.initGui(); - int dw = Minecraft.getMinecraft().displayWidth; - int dh = Minecraft.getMinecraft().displayHeight; - int width = MathHelper.clamp_int(dw - 200, 1250, 1500), height = MathHelper.clamp_int(dh - 200, 600, 800); - double scale = 2.0; - if (dw <= width || dh <= height) { - width = width/2; height = height/2; - scale = 1.0; - } - rootConfigPanel.setBounds(new Rectangle((dw-width)/2, (dh-height)/2, width,height)); - rootConfigPanel.setScale(scale); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawDefaultBackground(); - super.drawScreen(mouseX, mouseY, partialTicks); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategory.java deleted file mode 100644 index 77111fe7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategory.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; - -public class MCategory extends MPanel { - - private NestedCategory nestedCategory; - private RootConfigPanel rootConfigPanel; - @Getter - @Setter - private Color hover = new Color(94, 94, 94, 255); - public MCategory(NestedCategory nestedCategory, RootConfigPanel rootConfigPanel) { - this.nestedCategory = nestedCategory; - this.rootConfigPanel = rootConfigPanel; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - int border = RenderUtils.blendAlpha(0x141414, 0.12f); - if (!rootConfigPanel.getSearchWord().isEmpty() && (nestedCategory.categoryName().toLowerCase().contains(rootConfigPanel.getSearchWord()))) { - border = 0xFF02EE67; - } - - Gui.drawRect(0,0,getBounds().width, getBounds().height,border); - if (getBounds().height >= 28) - Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); - Gui.drawRect(1,1,getBounds().width-1, 18, RenderUtils.blendAlpha(0x141414, 0.12f)); - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.pushMatrix(); - GlStateManager.translate(5,5,0); - GlStateManager.scale(1.0,1.0,0); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - - fr.drawString((lastAbsClip.contains(absMousex, absMousey) ? "ยงn" : "") + nestedCategory.categoryName(), 0,0, 0xFFFFFFFF); - GlStateManager.popMatrix(); - - fr.drawSplitString(FeatureRegistry.getCategoryDescription().getOrDefault(nestedCategory.categoryFull(), ""), 5, 23, getBounds().width -10, 0xFFBFBFBF); - } - - - @Override - public Dimension getPreferredSize() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - int descriptionHeight = - FeatureRegistry.getCategoryDescription().containsKey(nestedCategory.categoryFull()) ? - fr.listFormattedStringToWidth(FeatureRegistry.getCategoryDescription().get(nestedCategory.categoryFull()), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT - : -9; - - return new Dimension(100, descriptionHeight + 28); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY)) { - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - rootConfigPanel.setCurrentPageAndPushHistory(nestedCategory.categoryFull()); - } - } - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (lastAbsClip.contains(absMouseX, absMouseY)) - setCursor(EnumCursor.POINTING_HAND); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategoryElement.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategoryElement.java deleted file mode 100644 index 22934fca..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategoryElement.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.util.ResourceLocation; - -import java.awt.*; - -public class MCategoryElement extends MPanel { - private String category; - private Runnable onClick; - private int leftPad = 0; - private int offsetX; - private RootConfigPanel rootConfigPanel; - public MCategoryElement(String category, Runnable onClick, int leftPad, int offsetX, RootConfigPanel rooot) { - this.category = category; - this.onClick = onClick; - this.leftPad = leftPad; - this.offsetX = offsetX; - this.rootConfigPanel = rooot; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (rootConfigPanel.getCurrentPage().equals(category)) { - clip(0,scissor.y, Minecraft.getMinecraft().displayWidth, scissor.height); - Gui.drawRect(leftPad - offsetX, 0, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.13f)); - } else if (lastAbsClip.contains(absMousex, absMousey) && getTooltipsOpen() == 0) { - clip(0,scissor.y, Minecraft.getMinecraft().displayWidth, scissor.height); - Gui.drawRect(leftPad - offsetX, 0, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.09f)); - } - clip(scissor.x, scissor.y, scissor.width, scissor.height); - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - String name = category.substring(category.lastIndexOf(".")+1); - fr.drawString(name, leftPad,2,-1); - - } - - @Override - public Dimension getPreferredSize() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - return new Dimension(fr.getStringWidth(category.substring(category.lastIndexOf(".")+1)) + leftPad+10, fr.FONT_HEIGHT+4); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (!lastAbsClip.contains(absMouseX, absMouseY) || getTooltipsOpen() > 0) { return; } - if (onClick != null) onClick.run(); - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - - } - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (lastAbsClip.contains(absMouseX, absMouseY)) - setCursor(EnumCursor.POINTING_HAND); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java deleted file mode 100644 index 49f637a5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -public class MFeature extends MPanel { - - @Getter - private final AbstractFeature feature; - - private final List addons = new ArrayList(); - - @Getter @Setter - private Color hover; - - private final RootConfigPanel panel; - - public MFeature(final AbstractFeature abstractFeature, final RootConfigPanel panel) { - this.panel = panel; - this.feature = abstractFeature; - - if (abstractFeature.isDisyllable()) { - final MToggleButton mStringSelectionButton = new MToggleButton(); - mStringSelectionButton.setOnToggle(new Runnable() { - @Override - public void run() { - boolean selected = mStringSelectionButton.isEnabled(); - feature.setEnabled(selected); - } - }); - mStringSelectionButton.setBackground(RenderUtils.blendAlpha(0x141414, 0.07f)); - addons.add(mStringSelectionButton); - mStringSelectionButton.setEnabled(feature.isEnabled()); - mStringSelectionButton.setSize(new Dimension(40, 15)); - add(mStringSelectionButton); - } - if (abstractFeature.getParameters().size() != 0) { - MButton button = new MButton(); - button.setText("Settings"); - button.setOnActionPerformed(new Runnable() { - @Override - public void run() { - panel.setCurrentPageAndPushHistory(abstractFeature.getEditRoute(panel)); - } - }); - button.setBackground(RenderUtils.blendAlpha(0x141414, 0.07f)); - button.setClicked(RenderUtils.blendAlpha(0x141414, 0.17f)); - button.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); - addons.add(button); - button.setSize(new Dimension(50, 15)); - add(button); - } - if (abstractFeature instanceof GuiFeature) { - MButton button = new MButton(); - button.setText("Relocate"); - button.setOnActionPerformed(new Runnable() { - @Override - public void run() { - Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(Minecraft.getMinecraft().currentScreen, abstractFeature)); - button.setIsclicked(false); - } - }); - button.setBackground(RenderUtils.blendAlpha(0x141414, 0.07f)); - button.setClicked(RenderUtils.blendAlpha(0x141414, 0.17f)); - button.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); - addons.add(button); - button.setSize(new Dimension(75, 15)); - add(button); - } - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - - int border = RenderUtils.blendAlpha(0x141414, 0.12f); - if (!panel.getSearchWord().isEmpty() && (feature.getName().toLowerCase().contains(panel.getSearchWord()) || feature.getDescription().toLowerCase().contains(panel.getSearchWord()))) { - border = 0xFF02EE67; - } - - Gui.drawRect(0,0,getBounds().width, getBounds().height,border); - Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); - Gui.drawRect(1,1,getBounds().width-1, 18, RenderUtils.blendAlpha(0x141414, 0.12f)); - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.pushMatrix(); - GlStateManager.translate(5,5,0); - GlStateManager.scale(1.0,1.0,0); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(feature.getName(), 0,0, 0xFFFFFFFF); - GlStateManager.popMatrix(); - - fr.drawSplitString(feature.getDescription(), 5, 23, getBounds().width -10, 0xFFBFBFBF); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - } - - @Override - public Dimension getPreferredSize() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int descriptionHeight = fr.listFormattedStringToWidth(feature.getDescription(), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT; - - return new Dimension(100, descriptionHeight + 28); - } - - @Override - public void onBoundsUpdate() { - int x = getBounds().width - 5; - for (MPanel panel : addons) { - panel.setBounds(new Rectangle(x - panel.getPreferredSize().width, 3, panel.getPreferredSize().width, 12)); - x -= panel.getPreferredSize().width + 5; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeatureEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeatureEdit.java deleted file mode 100644 index f2ee35bc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeatureEdit.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MList; -import kr.syeyoung.dungeonsguide.gui.elements.MModalConfirmation; - -import java.awt.*; -import java.util.HashMap; -import java.util.Map; - -public class MFeatureEdit extends MPanel { - private MList list; - private MButton goBack, resetToDefault; - private RootConfigPanel rootConfigPanel; - private AbstractFeature abstractFeature; - - private Map parameterEdits = new HashMap<>(); - - public MFeatureEdit(AbstractFeature abstractFeature, RootConfigPanel rootConfigPanel) { - this.abstractFeature = abstractFeature; - this.rootConfigPanel = rootConfigPanel; - list = new MList(); - list.setGap(5); - list.setDrawLine(false); - add(list); - - goBack = new MButton(); - goBack.setText("< Go Back"); - goBack.setOnActionPerformed(rootConfigPanel::goBack); - add(goBack); - resetToDefault = new MButton(); - resetToDefault.setText("Reset To Default"); - resetToDefault.setForeground(Color.red); - resetToDefault.setOnActionPerformed(() -> { - openResetConfirmation(); - }); - add(resetToDefault); - } - - public void openResetConfirmation() { - MModalConfirmation mModal = new MModalConfirmation("Are you sure?", - "Resetting to default will reset your configuration for the selected feature to default", - () -> { - for (FeatureParameter parameter : abstractFeature.getParameters()) { - parameter.setToDefault(); - } - abstractFeature.onParameterReset(); - rootConfigPanel.invalidatePage(abstractFeature.getEditRoute(rootConfigPanel)); - }, () -> {}); - mModal.setScale(getScale()); - mModal.getYes().setBorder(0xFFFF0000); - mModal.getYes().setText("Yes, Reset it"); - mModal.getNo().setText("Cancel"); - mModal.open(MFeatureEdit.this); - } - - public void addParameterEdit(String name, MPanel paramEdit) { - parameterEdits.put(name, paramEdit); - list.add(paramEdit); - } - public MPanel removeParameterEdit(String name) { - MPanel panel = parameterEdits.remove(name); - list.remove(panel); - return panel; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - super.resize(parentWidth, parentHeight); - setBounds(new Rectangle(0,0,parentWidth,parentHeight)); - Dimension prefSize = getPreferredSize(); - int hei = prefSize.height; - setBounds(new Rectangle(0,0,parentWidth,hei)); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - goBack.setBounds(new Rectangle(5,5,75,15)); - resetToDefault.setBounds(new Rectangle(bounds.width - 105, 5, 100, 15)); - - list.setBounds(new Rectangle(5,25,bounds.width - 10, bounds.height - 10)); - list.realignChildren(); - - } - - @Override - public Dimension getPreferredSize() { - Dimension listPref = list.getPreferredSize(); - return new Dimension(listPref.width + 10, listPref.height + 30); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MNotFound.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MNotFound.java deleted file mode 100644 index ef885487..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MNotFound.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class MNotFound extends MPanel { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0,0,parentWidth,parentHeight)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("404 Not Found", (getBounds().width - fr.getStringWidth("404 Not Found")) / 2, (getBounds().height - fr.FONT_HEIGHT) / 2, -1); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MPanelCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MPanelCategory.java deleted file mode 100644 index e2388c60..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MPanelCategory.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MList; - -import java.awt.*; - -public class MPanelCategory extends MPanel { - - private NestedCategory key; - private RootConfigPanel rootConfigPanel; - - private MList list; - - public MPanelCategory(NestedCategory nestedCategory, RootConfigPanel rootConfigPanel) { - this.key = nestedCategory; - this.rootConfigPanel = rootConfigPanel; - - list = new MList(); - list.setDrawLine(false); - list.setGap(5); - add(list); - - for (NestedCategory value : nestedCategory.children().values()) { - list.add(new MCategory(value, rootConfigPanel)); - } - if (nestedCategory.parent() != null) { - String actualCategory = nestedCategory.categoryFull().substring(5); - if (FeatureRegistry.getFeaturesByCategory().containsKey(actualCategory)) - for (AbstractFeature abstractFeature : FeatureRegistry.getFeaturesByCategory().get(actualCategory)) { - MFeature mFeature = new MFeature(abstractFeature, rootConfigPanel); - list.add(mFeature); - mFeature.setHover(new Color(94, 94, 94, 255)); - } - } - list.realignChildren(); - - } - - @Override - public void resize(int parentWidth, int parentHeight) { - super.resize(parentWidth, parentHeight); - setBounds(new Rectangle(0,0,parentWidth,parentHeight)); - Dimension prefSize = getPreferredSize(); - int hei = prefSize.height; - setBounds(new Rectangle(0,0,parentWidth,hei)); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - list.setBounds(new Rectangle(5,5,bounds.width- 10, bounds.height - 10)); - list.realignChildren(); - } - - @Override - public Dimension getPreferredSize() { - Dimension prefSize = list.getPreferredSize(); - int wid = prefSize.width + 10; - int hei = prefSize.height + 10; - return new Dimension(wid, hei); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java deleted file mode 100644 index 6f791bcf..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; - -import java.awt.*; -import java.util.function.Predicate; - -public class MParameterEdit extends MPanel { - private AbstractFeature abstractFeature; - private FeatureParameter featureParameter; - private RootConfigPanel rootConfigPanel; - private MPanel valueEditHolder; - private MPanel valueEdit; - - private Predicate isDisabled ; - - public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel) { - this(abstractFeature, parameter, rootConfigPanel, (a) -> false); - } - - public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, Predicate isDisabled ) { - this.abstractFeature = abstractFeature; - this.featureParameter = parameter; - this.rootConfigPanel = rootConfigPanel; - this.isDisabled = isDisabled; - - if (parameter.getValue_type().equals("string")) { - valueEdit = new MTextField() { - @Override - public void edit(String str) { - parameter.setValue(str); - } - }; - ((MTextField)valueEdit).setText((String) parameter.getValue()); - } else if (parameter.getValue_type().equals("integer")) { - valueEdit = new MIntegerSelectionButton((Integer) parameter.getValue()); - ((MIntegerSelectionButton)valueEdit).setOnUpdate(() -> { - parameter.setValue(((MIntegerSelectionButton) valueEdit).getData()); - }); - } else if (parameter.getValue_type().equals("float")) { - valueEdit = new MFloatSelectionButton((Float) parameter.getValue()); - ((MFloatSelectionButton)valueEdit).setOnUpdate(() -> { - parameter.setValue(((MFloatSelectionButton) valueEdit).getData()); - }); - } else if (parameter.getValue_type().equals("acolor")) { - valueEdit = new MEditableAColor(); - ((MEditableAColor)valueEdit).setColor((AColor) parameter.getValue()); - ((MEditableAColor)valueEdit).setEnableEdit(true); - ((MEditableAColor)valueEdit).setOnUpdate(() -> { - parameter.setValue(((MEditableAColor) valueEdit).getColor()); - }); - } else if (parameter.getValue_type().equals("color")) { - valueEdit = new MEditableAColor(); - ((MEditableAColor)valueEdit).setColor(new AColor(((Color) parameter.getValue()).getRGB(), true)); - ((MEditableAColor)valueEdit).setEnableEdit(true); - ((MEditableAColor)valueEdit).setOnUpdate(() -> { - parameter.setValue(((MEditableAColor) valueEdit).getColor()); - }); - } else if (parameter.getValue_type().equals("boolean")) { - valueEdit = new MToggleButton(); - ((MToggleButton)valueEdit).setEnabled((Boolean) parameter.getValue()); - ((MToggleButton)valueEdit).setOnToggle(() -> { - parameter.setValue(((MToggleButton) valueEdit).isEnabled()); - }); - } else if (parameter.getValue_type().equals("keybind")) { - valueEdit = new MKeyEditButton(); - ((MKeyEditButton)valueEdit).setKey((Integer) parameter.getValue()); - ((MKeyEditButton)valueEdit).setOnKeyEdit(() -> { - parameter.setValue(((MKeyEditButton) valueEdit).getKey()); - }); - ((MKeyEditButton)valueEdit).setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); - }else { - valueEdit = new MLabel(); - ((MLabel)valueEdit).setText("????"); - } - - - valueEditHolder = new MPanel() { - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - Dimension dimension = valueEdit.getPreferredSize(); - if (dimension.width <= 0) dimension.width = bounds.width/2; - if (dimension.height <= 0) dimension.height = bounds.height/2; - valueEdit.setBounds(new Rectangle((bounds.width - dimension.width)/2,(bounds.height - dimension.height)/2,dimension.width, dimension.height)); - } - }; - add(valueEditHolder); - valueEditHolder.add(valueEdit); - } - public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, MPanel valueEdit, Predicate isDisabled) { - this.abstractFeature = abstractFeature; - this.featureParameter = parameter; - this.rootConfigPanel = rootConfigPanel; - this.isDisabled = isDisabled; - - - valueEditHolder = new MPanel() { - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - Dimension dimension = valueEdit.getPreferredSize(); - if (dimension.width <= 0) dimension.width = bounds.width/2; - if (dimension.height <= 0) dimension.height = bounds.height/2; - valueEdit.setBounds(new Rectangle((bounds.width - dimension.width)/2,(bounds.height - dimension.height)/2,dimension.width, dimension.height)); - } - }; - add(valueEditHolder); - valueEditHolder.add(valueEdit); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f)); - Gui.drawRect(2*bounds.width / 3,1,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); - Gui.drawRect(4, 15,2*bounds.width / 3-5, 16, RenderUtils.blendAlpha(0x141414, 0.3f)); - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString(featureParameter.getName(), 5,5, 0xFFFFFFFF); - fr.drawSplitString(featureParameter.getDescription(), 5,18, 2*bounds.width /3-10, 0xFFAAAAAA); - - } - - @Override - public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { - super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); - if (isDisabled.test(featureParameter)) { - Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55000000); - } - } - - @Override - public Dimension getPreferredSize() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int descriptionHeight = fr.listFormattedStringToWidth(featureParameter.getDescription(), Math.max(50, 2*bounds.width/3-10)).size() * fr.FONT_HEIGHT; - return new Dimension(100, Math.max(30, descriptionHeight + 23)); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - valueEditHolder.setBounds(new Rectangle(2*bounds.width / 3, 0, bounds.width / 3, bounds.height)); - } - - @Override - public void keyPressed0(char typedChar, int keyCode) { - if (isDisabled.test(featureParameter)) return; - super.keyPressed0(typedChar, keyCode); - } - - @Override - public void keyHeld0(char typedChar, int keyCode) { - if (isDisabled.test(featureParameter)) return; - super.keyHeld0(typedChar, keyCode); - } - - @Override - public void keyReleased0(char typedChar, int keyCode) { - if (isDisabled.test(featureParameter)) return; - super.keyReleased0(typedChar, keyCode); - } - - @Override - public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { - if (isDisabled.test(featureParameter)) return false; - return super.mouseClicked0(absMouseX, absMouseY, relMouseX0, relMouseY0, mouseButton); - } - - @Override - public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { - if (isDisabled.test(featureParameter)) return ; - super.mouseReleased0(absMouseX, absMouseY, relMouseX0, relMouseY0, state); - } - - @Override - public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { - if (isDisabled.test(featureParameter)) return ; - super.mouseClickMove0(absMouseX, absMouseY, relMouseX0, relMouseY0, clickedMouseButton, timeSinceLastClick); - } - - @Override - public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (isDisabled.test(featureParameter)) return ; - super.mouseScrolled0(absMouseX, absMouseY, relMouseX0, relMouseY0, scrollAmount); - } - - @Override - public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (isDisabled.test(featureParameter)) return ; - super.mouseMoved0(absMouseX, absMouseY, relMouseX0, relMouseY0); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/NestedCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/NestedCategory.java deleted file mode 100644 index a4812fb7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/NestedCategory.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import lombok.experimental.Accessors; - -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -@Data -@Accessors(chain = true, fluent = true) -public -class NestedCategory { - private final String categoryFull; - @EqualsAndHashCode.Exclude - private String categoryName; - @EqualsAndHashCode.Exclude - @ToString.Exclude - private NestedCategory parent; - - public NestedCategory(String categoryFull) { - this.categoryFull = categoryFull; - this.categoryName = categoryFull.substring(categoryFull.lastIndexOf(".") + 1); - } - - @EqualsAndHashCode.Exclude - @ToString.Exclude - private Map children = new LinkedHashMap<>(); - - public NestedCategory child(NestedCategory child) { - this.children.put(child.categoryName, child); - child.parent = this; - return this; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/RootConfigPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/RootConfigPanel.java deleted file mode 100644 index 1827d766..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/RootConfigPanel.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig; - -import com.google.common.base.Function; -import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; - -import java.awt.*; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.*; - -public class RootConfigPanel extends MPanelScaledGUI { - private MScrollablePanel navigationScroll; - - private MList navigation = new MList(); - - private MScrollablePanel contentScroll; - - - private final Map pages = new HashMap(); - @Getter - @Setter - private Function pageGenerator = ConfigPanelCreator.INSTANCE; - @Getter - private String currentPage = ""; - - private GuiConfigV2 gui; - - private long lastPageSet = System.currentTimeMillis(); - - private MTextField search; - private MButton guiRelocate; - - private MButton github, discord; - - private final Stack history = new Stack(); - - public String getSearchWord() { - return search.getText().trim().toLowerCase(); - } - - public RootConfigPanel(GuiConfigV2 guiConfigV2) { - this.gui = guiConfigV2; - - search = new MTextField() { - @Override - public void edit(String str) { - setupNavigation(); - - setCurrentPageAndPushHistory(""); - if (!categoryMap.containsKey(lastOpenCategory)) { - for (Map.Entry nestedCategoryMPanelEntry : categoryMap.entrySet()) { - if (nestedCategoryMPanelEntry.getValue() instanceof MCategoryElement) { - setCurrentPageAndPushHistory(nestedCategoryMPanelEntry.getKey().categoryFull()); - lastOpenCategory = nestedCategoryMPanelEntry.getKey(); - break; - } - } - } - for (Map.Entry nestedCategoryMPanelEntry : categoryMap.entrySet()) { - if (nestedCategoryMPanelEntry.getValue() instanceof MCollapsable) { - ((MCollapsable) nestedCategoryMPanelEntry.getValue()).setCollapsed(false); - } - } - rePlaceElements(); - } - }; - search.setPlaceHolder("Search..."); - add(search); - guiRelocate = new MButton(); - guiRelocate.setText("Edit Gui Locations"); - guiRelocate.setOnActionPerformed(() -> { - Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(gui, null)); - guiRelocate.setIsclicked(false); - }); - guiRelocate.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); - add(guiRelocate); - - discord = new MButton(); github = new MButton(); - discord.setText("Discord"); github.setText("Github"); - discord.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); - github.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); - github.setOnActionPerformed(() -> { - try { - Desktop.getDesktop().browse(new URI("https://github.com/Dungeons-Guide/Skyblock-Dungeons-Guide/")); - } catch (IOException | URISyntaxException e) { - e.printStackTrace(); - } - }); - discord.setOnActionPerformed(() -> { - try { - Desktop.getDesktop().browse(new URI("https://discord.gg/VuxayCWGE8")); - } catch (IOException | URISyntaxException e) { - e.printStackTrace(); - } - }); - add(discord); add(github); - - navigationScroll = new MScrollablePanel(1); - navigationScroll.setHideScrollBarWhenNotNecessary(false); - - - add(navigationScroll); - navigationScroll.add(navigation); - - contentScroll = new MScrollablePanel(3); - contentScroll.setHideScrollBarWhenNotNecessary(true); - add(contentScroll); - - setupNavigation(); - navigation.setGap(0); - navigation.setDrawLine(false); - - setCurrentPageAndPushHistory("ROOT"); - rePlaceElements(); - - search.setFocused(true); - } - - - private Map categoryMap = new HashMap<>(); - private NestedCategory lastOpenCategory; - private void setupNavigation() { - categoryMap.clear(); - for (MPanel childComponent : navigation.getChildComponents()) { - navigation.remove(childComponent); - } - NestedCategory root = new NestedCategory("ROOT"); - Set categoryAllowed = new HashSet<>(); - String search = this.search.getText().trim().toLowerCase(); - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (search.isEmpty()) { - categoryAllowed.add("ROOT."+abstractFeature.getCategory()+"."); - } else if (abstractFeature.getName().toLowerCase().contains(search)) { - categoryAllowed.add("ROOT."+abstractFeature.getCategory()+"."); - } else if (abstractFeature.getDescription().toLowerCase().contains(search)) { - categoryAllowed.add("ROOT."+abstractFeature.getCategory()+"."); - } - } - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - String category = abstractFeature.getCategory(); - boolean test =false; - for (String s : categoryAllowed) { - if (s.startsWith("ROOT."+category+".")) { - test = true; - break; - } - } - if (!test) continue; - - NestedCategory currentRoot = root; - for (String s : category.split("\\.")) { - NestedCategory finalCurrentRoot = currentRoot; - if (currentRoot.children().containsKey(s)) - currentRoot = currentRoot.children().get(s); - else { - currentRoot.child(currentRoot = new NestedCategory(finalCurrentRoot.categoryFull()+"."+s)); - } - } - - } - - for (NestedCategory value : root.children().values()) { - setupNavigationRecursive(value, navigation, 0, 17); - } - ConfigPanelCreator.map.put("ROOT", () -> new MPanelCategory(root, this)); - } - private void setupNavigationRecursive(NestedCategory nestedCategory, MPanel parent, int depth, int offset) { - ConfigPanelCreator.map.put(nestedCategory.categoryFull(), () -> new MPanelCategory(nestedCategory, this)); - - if (nestedCategory.children().size() == 0) { - MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull(),() -> { - setCurrentPageAndPushHistory(nestedCategory.categoryFull()); - lastOpenCategory = nestedCategory; - }, 13 * depth + 17, offset, this); - parent.add(current); - categoryMap.put(nestedCategory, current); - } else { - MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull(),() -> { - setCurrentPageAndPushHistory(nestedCategory.categoryFull()); - lastOpenCategory = nestedCategory; - }, 3,offset, this); - MCollapsable mCollapsable = new MCollapsable(current, this::rePlaceElements); - mCollapsable.setLeftPad(offset-13); - mCollapsable.getLowerElements().setDrawLine(false); - mCollapsable.getLowerElements().setGap(0); - mCollapsable.setLeftPadElements(0); - parent.add(mCollapsable); - categoryMap.put(nestedCategory, mCollapsable); - - for (NestedCategory value : nestedCategory.children().values()) { - setupNavigationRecursive(value, mCollapsable, depth+1, offset+13); - } - } - } - - - public void setCurrentPageAndPushHistory(String currentPage) { - if (!this.currentPage.equals(currentPage)) - history.push(this.currentPage); - lastOpenCategory = null; - this.currentPage = currentPage; - setupPage(); - } - public void goBack() { - if (history.size() == 0) return; - this.currentPage = history.pop(); - setupPage(); - } - - private void setupPage() { - contentScroll.getContentArea().getChildComponents().forEach(contentScroll.getContentArea()::remove); - if (!pages.containsKey(currentPage)) { - MPanel page = pageGenerator.apply(currentPage); - if (page == null) page = new MNotFound(); - pages.put(currentPage, page); - } - contentScroll.getContentArea().add(pages.get(currentPage)); - rePlaceElements(); - } - - public void invalidatePage(String page) { - pages.remove(page); - if (page.equals(currentPage)) - setupPage(); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Dimension effectiveDim = getEffectiveDimension(); - Gui.drawRect(0,0, (int) (effectiveDim.width), (int) (effectiveDim.height), RenderUtils.blendAlpha(0x141414, 0.00f)); - Gui.drawRect(0,0, (int) (effectiveDim.width), 25, RenderUtils.blendAlpha(0x0, 0.20f)); -// Gui.drawRect(navigationScroll.getBounds().x + navigationScroll.getBounds().width - 10, 25, navigationScroll.getBounds().x + navigationScroll.getBounds().width , 50, RenderUtils.blendAlpha(0xFF141414, 0.04f)); - Gui.drawRect(0, 25,navigationScroll.getBounds().x + navigationScroll.getBounds().width , 50, RenderUtils.blendAlpha(0xFF141414, 0.08f)); - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("DungeonsGuide By syeyoung", (effectiveDim.width - fr.getStringWidth("DungeonsGuide By syeyoung"))/2, (25 - fr.FONT_HEIGHT)/2, 0xFF02EE67); - } - - @Override - public void render0(double parentScale, Point parentPoint, Rectangle parentClip, int absMousex0, int absMousey0, int relMousex0, int relMousey0, float partialTicks) { - super.render0(parentScale, parentPoint, parentClip, absMousex0, absMousey0, relMousex0, relMousey0, partialTicks); - Dimension effectiveDim = getEffectiveDimension(); - Gui.drawRect(0,24, (int) (Double.min(1, (System.currentTimeMillis() - lastPageSet)/1000.0) * effectiveDim.width), 25, 0xFF02EE67); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - rePlaceElements(); - } - - @Override - public void setScale(double scale) { - super.setScale(scale); - rePlaceElements(); - } - - private void rePlaceElements() { - Dimension effectiveDim = getEffectiveDimension(); - - navigation.setBounds(new Rectangle(new Point(0,1), new Dimension(Math.max(100, Math.max(navigation.getPreferredSize().width, navigationScroll.getBounds().width-10)), navigation.getPreferredSize().height))); - navigation.realignChildren(); - - navigationScroll.evalulateContentArea(); - Rectangle navBound; - navigationScroll.setBounds(navBound = new Rectangle(0,50, navigation.getBounds().width+10, effectiveDim.height-50)); - contentScroll.setBounds(new Rectangle(navBound.x + navBound.width, 25, effectiveDim.width - navBound.x - navBound.width, effectiveDim.height-25)); - - search.setBounds(new Rectangle(5,30,navBound.x + navBound.width - 10,15)); - - guiRelocate.setBounds(new Rectangle(5,5,100,15)); - github.setBounds(new Rectangle(effectiveDim.width - 80,5,75,15)); - discord.setBounds(new Rectangle(effectiveDim.width - 160,5,75,15)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/GuiGuiLocationConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/GuiGuiLocationConfig.java deleted file mode 100755 index 48c046c3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/GuiGuiLocationConfig.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig.location; - -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.gui.MGui; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.Vec3; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; -import java.util.*; -import java.util.List; - -public class GuiGuiLocationConfig extends MGui { - - @Getter - private final GuiScreen before; - - @Getter - private TreeMap> markerTreeMapByX = new TreeMap<>(); - @Getter - private TreeMap> markerTreeMapByY = new TreeMap<>(); - @Getter - private Set markerSet = new HashSet<>(); - - - Marker[] markers = new Marker[4]; - - - public GuiGuiLocationConfig(final GuiScreen before, AbstractFeature featureWhitelist) { - this.before = before; - for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { - if (feature instanceof GuiFeature && feature.isEnabled()) { - getMainPanel().add(new PanelDelegate((GuiFeature) feature, featureWhitelist == null || feature == featureWhitelist, this)); - } - } - - getMainPanel().setBackgroundColor(new Color(0,0,0, 100)); - } - - public static final Vec3[] facing = new Vec3[] { - new Vec3(0, 0.5, 2), - new Vec3(0.5, 0, 1), - new Vec3(0.5, 1, 3), - new Vec3(1, 0.5, 4), - }; - - public void removeAndAddMarker(Marker prev, Marker newM) { - if (prev != null) { - markerTreeMapByX.computeIfPresent(prev.getX(),(k,v) -> { - v.remove(prev); - if (v.isEmpty()) return null; - else return v; - }); - markerTreeMapByY.computeIfPresent(prev.getY(),(k,v) -> { - v.remove(prev); - if (v.isEmpty()) return null; - else return v; - }); - markerSet.remove(prev); - } - if (newM != null) { - markerTreeMapByX.compute(newM.getX(), (k,v) -> { - if (v == null) { - return new ArrayList<>(Arrays.asList(newM)); - } else { - v.add(newM); - return v; - } - }); - markerTreeMapByY.compute(newM.getY(), (k,v) -> { - if (v == null) { - return new ArrayList<>(Arrays.asList(newM)); - } else { - v.add(newM); - return v; - } - }); - markerSet.add(newM); - } - } - - public void setupMarkers() { - for (int i1 = 0; i1 < markers.length; i1++) { - Marker orig = markers[i1]; - Vec3 pt = facing[i1]; - markers[i1] = new Marker((int) (pt.xCoord * getMainPanel().getBounds().width), (int) (pt.yCoord * getMainPanel().getBounds().height), (int) pt.zCoord, this); - - removeAndAddMarker(orig, markers[i1]); - } - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - GlStateManager.pushMatrix(); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GlStateManager.translate(scaledResolution.getScaledWidth()/2, scaledResolution.getScaledHeight()/2, 0); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.enableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - GlStateManager.color(1, 1, 1, 1); - fr.drawString("Right Click On Elements to Open Popup Menu", - -fr.getStringWidth("Right Click On Elements to Open Popup Menu")/2 - ,-fr.FONT_HEIGHT/2, -1); - GlStateManager.popMatrix(); - super.drawScreen(mouseX, mouseY, partialTicks); - } - - @Override - public void keyTyped(char typedChar, int keyCode) throws IOException { - try { - getMainPanel().keyPressed0(typedChar, keyCode); - - if (keyCode == 1) { - Minecraft.getMinecraft().displayGuiScreen(before); - } - } catch (Throwable e) { - if (!e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - - @Override - public void initGui() { - super.initGui(); - getMainPanel().setBounds(new Rectangle(0,0,Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight)); - markerTreeMapByX.clear(); - markerTreeMapByY.clear(); - markerSet.clear(); - setupMarkers(); - for (MPanel childComponent : getMainPanel().getChildComponents()) { - if (childComponent instanceof PanelDelegate) { - ((PanelDelegate) childComponent).rebuildMarker(); - } - } - - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/Marker.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/Marker.java deleted file mode 100644 index 7a0b9c58..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/Marker.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig.location; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.ToString; - -@Getter -@ToString -@AllArgsConstructor -public class Marker { - private final int x; - private final int y; - /** - * 0xABCDEFGH - * A: ? - * B: ? - * C: ? - * D: ? - * EF: 0~3 (TC 0x00 CL 0x01 BC 0x10 CR 0x11) - */ - private final int type; - private final Object parent; - - public int distanceSQ(Marker m2) { - return (m2.x - x)*(m2.x - x) + (m2.y - y)*(m2.y - y); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/PanelDelegate.java deleted file mode 100644 index d34eb6c1..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/PanelDelegate.java +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.guiconfig.location; - -import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.config.guiconfig.location.Marker; -import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MPopupMenu; -import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Tuple; -import net.minecraft.util.Vec3; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class PanelDelegate extends MPanel { - private final GuiFeature guiFeature; - private boolean draggable = false; - private GuiGuiLocationConfig guiGuiLocationConfig; - - private Set markerSet = new HashSet<>(); - public PanelDelegate(GuiFeature guiFeature, boolean draggable, GuiGuiLocationConfig guiGuiLocationConfig) { - this.guiFeature = guiFeature; - this.draggable = draggable; - this.guiGuiLocationConfig = guiGuiLocationConfig; - } - - public void rebuildMarker() { - internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale(); - applyConstraint(); - } - - @Override - public Rectangle getBounds() { - Rectangle rectangle = guiFeature.getFeatureRect().getRectangle(); - return new Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height); - } - - @Override - public void render(int absMousex, int absMousey, int relMouseX, int relMouseY, float partialTicks, Rectangle scissor) { - if (!guiFeature.isEnabled()) return; - - GlStateManager.pushMatrix(); - guiFeature.drawDemo(partialTicks); - GlStateManager.popMatrix(); - if (!draggable) return; - Gui.drawRect(0,0, 4, 4, 0xFFBBBBBB); - Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0xFFBBBBBB); - Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0xFFBBBBBB); - Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0xFFBBBBBB); - if (lastAbsClip.contains(absMousex, absMousey)) { - if (relMouseX < 4 && relMouseY < 4) { - Gui.drawRect(0,0, 4, 4, 0x55FFFFFF); - } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { - Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0x55FFFFFF); - } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { - Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0x55FFFFFF); - } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { - Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0x55FFFFFF); - } else if (selectedPart == -2){ - Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55FFFFFF); - } - } - GlStateManager.enableBlend(); - } - - @Override - public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { - GlStateManager.pushMatrix(); - super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); - GlStateManager.popMatrix(); - - if (snapped != null && selectedPart != -2) { - Tessellator tessellator = Tessellator.getInstance(); - GlStateManager.disableTexture2D(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); - GL11.glLineWidth(1); - for (Tuple markerAxisTuple : snapped) { - if (markerAxisTuple.getSecond() == EnumFacing.Axis.X) { - worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), 0, 0).color(0,255,0,255).endVertex(); - worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), Minecraft.getMinecraft().displayHeight, 0).color(0,255,0,255).endVertex(); - } else { - worldRenderer.pos(0, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex(); - worldRenderer.pos(Minecraft.getMinecraft().displayWidth, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex(); - } - } - tessellator.draw(); - for (Marker marker : guiGuiLocationConfig.getMarkerSet()) { - Gui.drawRect(marker.getX(),marker.getY(), marker.getX()+1, marker.getY()+1, 0xFFFF0000); - } - } - } - - private int selectedPart = -2; - - private int lastX = 0; - private int lastY = 0; - - private Rectangle internallyThinking; - private Rectangle constraintApplied; - - private Set> snapped = new HashSet<>(); - - public void applyConstraint() { - constraintApplied = internallyThinking.getBounds(); - - // SNAP Moving Point. - snapped.clear(); - int scailingThreshold = 5; - if (selectedPart == 0){ - Point snapPt = new Point(constraintApplied.x +constraintApplied.width, constraintApplied.y + constraintApplied.height); - Optional snapX, snapY; - SortedMap> markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(snapPt.x-scailingThreshold, snapPt.x +scailingThreshold); - snapX = markerSortedMap.values().stream() - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(a -> a.getParent() != this) - .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY()))); - markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(snapPt.y-scailingThreshold, snapPt.y +scailingThreshold); - snapY = markerSortedMap.values().stream() - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(a -> a.getParent() != this) - .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY()))); - snapX.ifPresent(a -> { - snapPt.x = a.getX(); - }); - snapY.ifPresent(a -> { - snapPt.y = a.getY(); - }); - - constraintApplied = new Rectangle(constraintApplied.x, constraintApplied.y, snapPt.x - constraintApplied.x, snapPt.y - constraintApplied.y); - - - - int minWidth; - int minHeight; - if (guiFeature.isKeepRatio()) { - if (guiFeature.getDefaultRatio() >= 1) { - minHeight = constraintApplied.height < 0 ? -8 : 8; - minWidth = (int) (guiFeature.getDefaultRatio() * minHeight); - } else { - minWidth = constraintApplied.width < 0 ? -8 : 8; - minHeight = (int) (minWidth / guiFeature.getDefaultRatio()); - } - } else { - minWidth = constraintApplied.width < 0 ? -8 : 8; - minHeight = constraintApplied.height < 0 ? -8 : 8; - } - - - constraintApplied.width = Math.abs(constraintApplied.width) > Math.abs(minWidth) ? constraintApplied.width : - Math.abs(internallyThinking.width) > Math.abs(minWidth) ? internallyThinking.width : minWidth; - constraintApplied.height = Math.abs(constraintApplied.height) > Math.abs(minHeight) ? constraintApplied.height : - Math.abs(internallyThinking.height) > Math.abs(minHeight) ? internallyThinking.height : minHeight; - - if (guiFeature.isKeepRatio()) { - double ratio = guiFeature.getDefaultRatio(); - - int heightWhenWidthFix = (int) Math.abs(constraintApplied.width / ratio); - int widthWhenHeightFix = (int) Math.abs(ratio * constraintApplied.height); - if (Math.abs(heightWhenWidthFix) <= Math.abs(constraintApplied.height)) { - constraintApplied.height = constraintApplied.height < 0 ? -heightWhenWidthFix : heightWhenWidthFix; - } else if (Math.abs(widthWhenHeightFix) <= Math.abs(constraintApplied.width)) { - constraintApplied.width =constraintApplied.width < 0 ? - widthWhenHeightFix : widthWhenHeightFix; - } - } - - - snapX.ifPresent(a -> { - if (snapPt.x - constraintApplied.x == constraintApplied.width) { - Marker m = new Marker((int) (GuiGuiLocationConfig.facing[3].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[3].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[3].zCoord, this); - snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.X)); - } - }); - snapY.ifPresent(a -> { - if (snapPt.y - constraintApplied.y == constraintApplied.height) { - Marker m = new Marker((int) (GuiGuiLocationConfig.facing[2].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[2].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[2].zCoord, this); - snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.Y)); - } - }); - - if (constraintApplied.height < 0) { - constraintApplied.height = -constraintApplied.height; - constraintApplied.y -= constraintApplied.height; - } - - if (constraintApplied.width < 0) { - constraintApplied.width = -constraintApplied.width; - constraintApplied.x -= constraintApplied.width; - } - } else if (selectedPart == -1) { - for (int i : Arrays.asList(0,3,1,2)) { - Vec3 pt = GuiGuiLocationConfig.facing[i]; - Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); - Optional result = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(m.getX()-scailingThreshold, m.getX() +scailingThreshold).values().stream() - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(a -> a.getParent() != this) - .filter(a -> Math.abs(a.getX() - m.getX()) < scailingThreshold) - .filter(a -> ((a.getX() - pt.xCoord * constraintApplied.width) >= 0 - && (a.getX() - pt.xCoord * constraintApplied.width + constraintApplied.width) <= Minecraft.getMinecraft().displayWidth)) - .min(Comparator.comparingInt(a -> a.distanceSQ(m))); - if (result.isPresent()) { - int x = result.get().getX(); - constraintApplied.x = (int) (x - pt.xCoord * constraintApplied.width); - - snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.X)); - break; - } - } - for (int i : Arrays.asList(1,2,0,3)) { - Vec3 pt = GuiGuiLocationConfig.facing[i]; - Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); - Optional result = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(m.getY()-scailingThreshold, m.getY() +scailingThreshold).values().stream() - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .filter(a -> a.getParent() != this) - .filter(a -> Math.abs(a.getY() - m.getY()) < scailingThreshold) - .filter(a -> ((a.getY() - pt.yCoord * constraintApplied.height) >= 0 - && (a.getY() - pt.yCoord * constraintApplied.height+ constraintApplied.height) <= Minecraft.getMinecraft().displayHeight)) - .min(Comparator.comparingInt(a -> a.distanceSQ(m))); - if (result.isPresent()) { - int y = result.get().getY(); - constraintApplied.y = (int) (y - pt.yCoord * constraintApplied.height); - snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.Y)); - break; - } - } - } - - if (constraintApplied.x < 0) constraintApplied.x = 0; - if (constraintApplied.y < 0) constraintApplied.y = 0; - if (constraintApplied.x + constraintApplied.width + 1 >=Minecraft.getMinecraft().displayWidth) constraintApplied.x = Minecraft.getMinecraft().displayWidth - constraintApplied.width - 1; - if (constraintApplied.y + constraintApplied.height + 1>= Minecraft.getMinecraft().displayHeight) constraintApplied.y = Minecraft.getMinecraft().displayHeight - constraintApplied.height - 1; - - - setupMarkers(); - } - - Marker[] markers = new Marker[4]; - public void setupMarkers() { - for (int i1 = 0; i1 < markers.length; i1++) { - Marker orig = markers[i1]; - - Vec3 pt = GuiGuiLocationConfig.facing[i1]; - markers[i1] = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); - - guiGuiLocationConfig.removeAndAddMarker(orig, markers[i1]); - } - } - - MTooltip mTooltip; - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (!draggable) return; - if (!guiFeature.isEnabled()) return; - if (getTooltipsOpen() > 0) return; - if (!lastAbsClip.contains(absMouseX, absMouseY)) return; - if (mouseButton == 0) { - internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale(); - if (relMouseX < 4 && relMouseY < 4) { // TL - selectedPart = 0; - internallyThinking.y += internallyThinking.height; - internallyThinking.height = -internallyThinking.height; - internallyThinking.x += internallyThinking.width; - internallyThinking.width = -internallyThinking.width; - } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { // BL - selectedPart = 0; - internallyThinking.x += internallyThinking.width; - internallyThinking.width = -internallyThinking.width; - } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { // BR - selectedPart = 0; - } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { // TR - selectedPart = 0; - internallyThinking.y += internallyThinking.height; - internallyThinking.height = -internallyThinking.height; - } else { - selectedPart = -1; - } - lastX = absMouseX; - lastY = absMouseY; - applyConstraint(); - - } else if (getTooltipsOpen() == 0){ - if (mTooltip != null) mTooltip.close(); - mTooltip = new MPopupMenu(absMouseX, absMouseY, guiFeature.getTooltipForEditor(guiGuiLocationConfig)); - mTooltip.setScale(2.0f); - mTooltip.open(this); - } - throw new IllegalArgumentException("bruh, a hack to stop event progress"); - } - - @Override - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - if (!draggable) return; - if (!guiFeature.isEnabled()) return; - if (selectedPart >= -1) { - guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); - } - - selectedPart = -2; - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - if (!draggable) return; - if (!guiFeature.isEnabled()) return; - int dx = (absMouseX - lastX); - int dy = (absMouseY - lastY); - if (selectedPart >= 0) { - Rectangle rectangle = internallyThinking; - - int prevWidth = rectangle.width; - int prevHeight= rectangle.height; - - rectangle.width = prevWidth + dx; - rectangle.height = prevHeight + dy; - - if (rectangle.height * prevHeight <= 0 && prevHeight != rectangle.height) { - rectangle.height += prevHeight < 0 ? 4 : -4; - } - if (rectangle.width * prevWidth <= 0 && prevWidth != rectangle.width) { - rectangle.width += prevWidth < 0 ? 4 : -4; - } - - - applyConstraint(); - guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); - lastX = absMouseX; - lastY = absMouseY; - throw new IllegalArgumentException("bruh, a hack to stop event progress"); - } else if (selectedPart == -1){ - Rectangle rectangle = internallyThinking; - rectangle.translate(dx, dy); - applyConstraint(); - guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); - lastX = absMouseX; - lastY = absMouseY; - } - } - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX, int relMouseY) { - if (!draggable) return; - if (!guiFeature.isEnabled()) return; - if (getTooltipsOpen() > 0) return; - - if (selectedPart == -1) { - setCursor(EnumCursor.CLOSED_HAND); - } else if (selectedPart >= 0) { - if (internallyThinking.width < 0 && internallyThinking.height < 0) { - setCursor(EnumCursor.RESIZE_TL); - } else if (internallyThinking.width < 0 && internallyThinking.height >= 0) { - setCursor(EnumCursor.RESIZE_DL); - } else if (internallyThinking.width >= 0 && internallyThinking.height >= 0) { - setCursor(EnumCursor.RESIZE_DR); - } else if (internallyThinking.width >= 0 && internallyThinking.height < 0) { - setCursor(EnumCursor.RESIZE_TR); - } - } else if (lastAbsClip.contains(absMouseX, absMouseY)) { - if (relMouseX < 4 && relMouseY < 4) { - setCursor(EnumCursor.RESIZE_TL); - } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { - setCursor(EnumCursor.RESIZE_DL); - } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { - setCursor(EnumCursor.RESIZE_DR); - } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { - setCursor(EnumCursor.RESIZE_TR); - } else { - setCursor(EnumCursor.OPEN_HAND); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/AColor.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/AColor.java deleted file mode 100644 index c9f464df..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/AColor.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; - -@Getter -@Setter -public class AColor extends Color { - private boolean chroma; - private float chromaSpeed; - - public AColor(int r, int g, int b, int a) { - super(r, g, b, a); - } - - public AColor(int rgba, boolean hasalpha) { - super(rgba, hasalpha); - } - - public AColor(AColor clone) { - super(clone.getRGB(), true); - chroma = clone.isChroma(); - chromaSpeed = clone.getChromaSpeed(); - } - - public AColor multiplyAlpha(double multiplier) { - AColor aColor = new AColor(getRed(), getGreen(), getBlue(), (int) (getAlpha() * multiplier)); - aColor.chroma = this.chroma; - aColor.chromaSpeed = this.chromaSpeed; - return aColor; - } - - @Override - public String toString() { - return "AColor{" + - ", r="+getRed()+ - ", g="+getGreen()+ - ", b="+getBlue()+ - ", a="+getAlpha()+ - ", chromaSpeed=" + chromaSpeed + - '}'; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java deleted file mode 100644 index 1c129d2e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; - -import java.awt.*; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class GUIRectangle { - public GUIRectangle(Rectangle rectangle) { - if (rectangle.x < Minecraft.getMinecraft().displayWidth / 2) { - this.x = rectangle.x; - this.width = rectangle.width; - } else { - this.x = rectangle.x + rectangle.width - Minecraft.getMinecraft().displayWidth; - this.width = -rectangle.width; - } - - if (rectangle.y < Minecraft.getMinecraft().displayHeight / 2) { - this.y = rectangle.y; - this.height = rectangle.height; - } else { - this.y = rectangle.y +rectangle.height - Minecraft.getMinecraft().displayHeight; - this.height = -rectangle.height; - } - } - - private int x; - private int y; - private int width; - private int height; - - public Rectangle getRectangle() { - return getRectangleNoScale(); - } -// public Rectangle getRectangle(ScaledResolution scaledResolution) { -// double realX = (int) (x < 0 ? scaledResolution.getScaledWidth() + x : x); -// double realY = (int) (y < 0 ? scaledResolution.getScaledHeight() + y : y); -// -// return new Rectangle((int)Math.min(realX + width, realX), (int)Math.min(realY + height, realY), -// (int)Math.abs(width), (int)Math.abs(height)); -// } - public Rectangle getRectangleNoScale() { - int x = this.x, y = this.y; - if (Math.abs(x) > Minecraft.getMinecraft().displayWidth / 2) { - x = x < 0 ? -Minecraft.getMinecraft().displayWidth/2 : Minecraft.getMinecraft().displayWidth/2; - } - if (Math.abs(y) > Minecraft.getMinecraft().displayHeight / 2) { - y = y < 0 ? -Minecraft.getMinecraft().displayHeight/2 : Minecraft.getMinecraft().displayHeight/2; - } - - - double realX = (int) (x < 0 ? Minecraft.getMinecraft().displayWidth + x : x); - double realY = (int) (y < 0 ? Minecraft.getMinecraft().displayHeight + y : y); - - return new Rectangle((int)Math.min(realX + width, realX), (int)Math.min(realY + height, realY), - (int)Math.abs(width), (int)Math.abs(height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCAColor.java deleted file mode 100644 index 33748a8b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCAColor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; - -import java.awt.*; - -public class TCAColor implements TypeConverter { - @Override - public String getTypeString() { - return "acolor"; - } - - @Override - public AColor deserialize(JsonElement element) { - if (element instanceof JsonPrimitive) - return new AColor(element.getAsInt(), true); - - JsonObject object = element.getAsJsonObject(); - AColor color = new AColor(object.get("color").getAsInt(), true); - color.setChroma(object.get("chroma").getAsBoolean()); - color.setChromaSpeed(object.get("chromaSpeed").getAsFloat()); - return color; - } - - @Override - public JsonElement serialize(AColor element) { - JsonObject object = new JsonObject(); - object.addProperty("color", element.getRGB()); - object.addProperty("chroma", element.isChroma()); - object.addProperty("chromaSpeed", element.getChromaSpeed()); - return object; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java deleted file mode 100644 index 15a26d0f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCBoolean.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -public class TCBoolean implements TypeConverter { - @Override - public String getTypeString() { - return "boolean"; - } - - @Override - public Boolean deserialize(JsonElement element) { - return element.getAsBoolean(); - } - - @Override - public JsonElement serialize(Boolean element) { - return new JsonPrimitive(element); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCColor.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCColor.java deleted file mode 100644 index 6014b122..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCColor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; - -import java.awt.*; - -public class TCColor implements TypeConverter { - @Override - public String getTypeString() { - return "color"; - } - - @Override - public Color deserialize(JsonElement element) { - return new Color(element.getAsInt()); - } - - @Override - public JsonElement serialize(Color element) { - return new JsonPrimitive(element.getRGB()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCFloat.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCFloat.java deleted file mode 100644 index 0890f350..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCFloat.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -public class TCFloat implements TypeConverter { - @Override - public String getTypeString() { - return "float"; - } - - @Override - public Float deserialize(JsonElement element) { - return element.getAsFloat(); - } - - @Override - public JsonElement serialize(Float element) { - return new JsonPrimitive(element); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java deleted file mode 100644 index 8880a628..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.awt.*; - -public class TCGUIRectangle implements TypeConverter { - @Override - public String getTypeString() { - return "guirect"; - } - - @Override - public GUIRectangle deserialize(JsonElement element) { - if (element == null) return null; - GUIRectangle rectangle = new GUIRectangle(); - rectangle.setX(((JsonObject)element).get("x").getAsInt()); - rectangle.setY(((JsonObject)element).get("y").getAsInt()); - rectangle.setWidth(((JsonObject)element).get("width").getAsInt()); - rectangle.setHeight(((JsonObject)element).get("height").getAsInt()); - return rectangle; - } - - @Override - public JsonElement serialize(GUIRectangle element) { - JsonObject object = new JsonObject(); - object.addProperty("x", element.getX()); - object.addProperty("y", element.getY()); - object.addProperty("width", element.getWidth()); - object.addProperty("height", element.getHeight()); - return object; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java deleted file mode 100644 index 2a066921..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCInteger.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -public class TCInteger implements TypeConverter { - @Override - public String getTypeString() { - return "integer"; - } - - @Override - public Integer deserialize(JsonElement element) { - return element.getAsInt(); - } - - @Override - public JsonElement serialize(Integer element) { - return new JsonPrimitive(element); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java deleted file mode 100644 index 4ae89395..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCKeybind.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -public class TCKeybind implements TypeConverter { - @Override - public String getTypeString() { - return "keybind"; - } - - @Override - public Integer deserialize(JsonElement element) { - return element.getAsInt(); - } - - @Override - public JsonElement serialize(Integer element) { - return new JsonPrimitive(element); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java deleted file mode 100644 index ba778872..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCRectangle.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import org.w3c.dom.css.Rect; - -import java.awt.*; - -public class TCRectangle implements TypeConverter { - @Override - public String getTypeString() { - return "rect"; - } - - @Override - public Rectangle deserialize(JsonElement element) { - Rectangle rectangle = new Rectangle(); - rectangle.x = ((JsonObject)element).get("x").getAsInt(); - rectangle.y = ((JsonObject)element).get("y").getAsInt(); - rectangle.width = ((JsonObject)element).get("width").getAsInt(); - rectangle.height = ((JsonObject)element).get("height").getAsInt(); - return rectangle; - } - - @Override - public JsonElement serialize(Rectangle element) { - JsonObject object = new JsonObject(); - object.addProperty("x", element.x); - object.addProperty("y", element.y); - object.addProperty("width", element.width); - object.addProperty("height", element.height); - return object; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java deleted file mode 100644 index a90bedc6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCString.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -public class TCString implements TypeConverter { - @Override - public String getTypeString() { - return "string"; - } - - @Override - public String deserialize(JsonElement element) { - return element.getAsString(); - } - - @Override - public JsonElement serialize(String element) { - return new JsonPrimitive(element); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCStringList.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCStringList.java deleted file mode 100644 index 0a3e6217..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCStringList.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -public class TCStringList implements TypeConverter> { - @Override - public String getTypeString() { - return "stringlist"; - } - - @Override - public List deserialize(JsonElement element) { - List strList = new ArrayList<>(); - for (JsonElement jsonElement : element.getAsJsonArray()) { - strList.add(jsonElement.getAsString()); - } - return strList; - } - - @Override - public JsonElement serialize(List element) { - JsonArray jsonElements = new JsonArray(); - for (String s : element) { - jsonElements.add(new JsonPrimitive(s)); - } - return jsonElements; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyle.java deleted file mode 100644 index d27b311e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyle.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; - -import java.util.List; - -public class TCTextStyle implements TypeConverter { - @Override - public String getTypeString() { - return "textstyle"; - } - - @Override - public TextStyle deserialize(JsonElement element) { - TextStyle textStyle = new TextStyle(); - textStyle.setColor(TypeConverterRegistry.getTypeConverter("acolor", AColor.class).deserialize(element.getAsJsonObject().get("color"))); - textStyle.setBackground(element.getAsJsonObject().has("background") ? TypeConverterRegistry.getTypeConverter("acolor", AColor.class).deserialize(element.getAsJsonObject().get("background")) - : new AColor(0x00777777, true)); - textStyle.setGroupName(element.getAsJsonObject().get("group").getAsString()); - if (element.getAsJsonObject().has("shadow")) - textStyle.setShadow(element.getAsJsonObject().get("shadow").getAsBoolean()); - return textStyle; - } - - @Override - public JsonElement serialize(TextStyle element) { - JsonObject jsonObject = new JsonObject(); - jsonObject.add("color", TypeConverterRegistry.getTypeConverter("acolor", AColor.class).serialize(element.getColor())); - jsonObject.add("background", TypeConverterRegistry.getTypeConverter("acolor", AColor.class).serialize(element.getBackground())); - jsonObject.addProperty("group", element.getGroupName()); - jsonObject.addProperty("shadow", element.isShadow()); - return jsonObject; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyleList.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyleList.java deleted file mode 100644 index e9721ab7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCTextStyleList.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; - -import java.util.ArrayList; -import java.util.List; - -public class TCTextStyleList implements TypeConverter> { - @Override - public String getTypeString() { - return "list_textStyle"; - } - - @Override - public List deserialize(JsonElement element) { - JsonArray arr = element.getAsJsonArray(); - TypeConverter conv = TypeConverterRegistry.getTypeConverter("textstyle", TextStyle.class); - List texts = new ArrayList(); - for (JsonElement element2:arr) { - texts.add(conv.deserialize(element2)); - } - return texts; - } - - @Override - public JsonElement serialize(List element) { - JsonArray array = new JsonArray(); - TypeConverter conv = TypeConverterRegistry.getTypeConverter("textstyle", TextStyle.class); - for (TextStyle st:element) { - array.add(conv.serialize(st)); - } - return array; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java deleted file mode 100644 index b1c3ed5c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverter.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import com.google.gson.JsonElement; - -public interface TypeConverter { - String getTypeString(); - - T deserialize(JsonElement element); - - JsonElement serialize(T element); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java deleted file mode 100644 index abffd34a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.config.types; - -import kr.syeyoung.dungeonsguide.roomedit.Parameter; - -import java.util.HashMap; -import java.util.Map; - -public class TypeConverterRegistry { - private static final Map typeConverterMap = new HashMap(); - - public static void register(TypeConverter typeConverter) { - typeConverterMap.put(typeConverter.getTypeString(), typeConverter); - } - - public static TypeConverter getTypeConverter(String type_string) { - return typeConverterMap.get(type_string); - } - public static TypeConverter getTypeConverter(String type_string, Class t) { - return (TypeConverter)typeConverterMap.get(type_string); - } - - static { - register(new TCBoolean()); - register(new TCInteger()); - register(new TCRectangle()); - register(new TCGUIRectangle()); - register(new TCString()); - register(new TCColor()); - register(new TCFloat()); - register(new TCAColor()); - register(new TCTextStyleList()); - register(new TCTextStyle()); - register(new TCStringList()); - register(new TCKeybind()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/ActiveCosmetic.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/ActiveCosmetic.java deleted file mode 100644 index f00ecf06..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/ActiveCosmetic.java +++ /dev/null @@ -1,12 +0,0 @@ -package kr.syeyoung.dungeonsguide.cosmetics; - -import lombok.Data; -import java.util.UUID; - -@Data -public class ActiveCosmetic { - private UUID activityUID; - private UUID playerUID; - private UUID cosmeticData; - private String username; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticData.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticData.java deleted file mode 100644 index 24842a8e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticData.java +++ /dev/null @@ -1,14 +0,0 @@ -package kr.syeyoung.dungeonsguide.cosmetics; - - -import lombok.Data; - -import java.util.UUID; - -@Data -public class CosmeticData { - private UUID id; - private String cosmeticType; - private String reqPerm; - private String data; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java deleted file mode 100644 index fa597962..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.cosmetics; - -import com.google.gson.JsonPrimitive; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.cosmetics.chatreplacers.*; -import kr.syeyoung.dungeonsguide.events.PlayerListItemPacketEvent; -import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; -import kr.syeyoung.dungeonsguide.stomp.*; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.play.server.S38PacketPlayerListItem; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.*; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.relauncher.ReflectionHelper; -import org.json.JSONArray; -import org.json.JSONObject; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class CosmeticsManager implements StompMessageHandler { - @Getter - private Map cosmeticDataMap = new ConcurrentHashMap<>(); - @Getter - private Map activeCosmeticMap = new ConcurrentHashMap<>(); - @Getter - private Map> activeCosmeticByType = new ConcurrentHashMap<>(); - @Getter - private Map> activeCosmeticByPlayer = new ConcurrentHashMap<>(); - @Getter - private Map> activeCosmeticByPlayerNameLowerCase = new ConcurrentHashMap<>(); - @Getter - private Set perms = new CopyOnWriteArraySet<>(); - - public void requestActiveCosmetics() { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/cosmetic.activelist") - ); - } - public void requestCosmeticsList() { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/cosmetic.list") - ); - } - public void requestPerms() { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/user.perms") - ); - } - public void setCosmetic(CosmeticData cosmetic) { - if (!perms.contains(cosmetic.getReqPerm())) return; - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/cosmetic.set") - .payload(cosmetic.getId().toString()) - ); - } - public void removeCosmetic(ActiveCosmetic activeCosmetic) { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/cosmetic.remove") - .payload(activeCosmetic.getActivityUID().toString()) - ); - } - - @Override - public void handle(StompInterface stompInterface, StompPayload stompPayload) { - String destination = stompPayload.headers().get("destination"); - if (destination.equals("/topic/cosmetic.set")) { - JSONObject jsonObject = new JSONObject(stompPayload.payload()); - ActiveCosmetic activeCosmetic = new ActiveCosmetic(); - activeCosmetic.setActivityUID(UUID.fromString(jsonObject.getString("activityUID"))); - activeCosmetic.setPlayerUID(UUID.fromString(jsonObject.getString("playerUID"))); - if (jsonObject.isNull("cosmeticUID")) { - ActiveCosmetic activeCosmetic1 = activeCosmeticMap.remove(activeCosmetic.getActivityUID()); - - List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(activeCosmetic.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.remove(activeCosmetic1); - - activeCosmetics = activeCosmeticByPlayerNameLowerCase.computeIfAbsent(activeCosmetic1.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.remove(activeCosmetic1); - - CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); - if (cosmeticData != null) { - List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); - cosmeticsByTypeList.remove(activeCosmetic1); - } - } else { - activeCosmetic.setCosmeticData(UUID.fromString(jsonObject.getString("cosmeticUID"))); - activeCosmetic.setUsername(jsonObject.getString("username")); - - ActiveCosmetic previousThing = activeCosmeticMap.get(activeCosmetic.getActivityUID()); - activeCosmeticMap.put(activeCosmetic.getActivityUID(), activeCosmetic); - - CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); - if (cosmeticData != null) { - List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); - cosmeticsByTypeList.add(activeCosmetic); - cosmeticsByTypeList.remove(previousThing); - } - List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(activeCosmetic.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.add(activeCosmetic); - activeCosmetics.remove(previousThing); - - activeCosmetics = activeCosmeticByPlayerNameLowerCase.computeIfAbsent(activeCosmetic.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.add(activeCosmetic); - activeCosmetics.remove(previousThing); - } - - try { - if (Minecraft.getMinecraft().theWorld != null) { - EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(activeCosmetic.getPlayerUID()); - if (entityPlayer != null) entityPlayer.refreshDisplayName(); - } - } catch (Exception e) {e.printStackTrace();} - - } else if (destination.equals("/user/queue/reply/user.perms")) { - JSONArray object = new JSONArray(stompPayload.payload()); - Set cache = new HashSet<>(); - for (Object o : object) { - cache.add((String) o); - } - this.perms = cache; - } else if (destination.equals("/user/queue/reply/cosmetic.activelist")) { - Map activeCosmeticMap = new HashMap<>(); - JSONArray object = new JSONArray(stompPayload.payload()); - for (Object o : object) { - JSONObject jsonObject = (JSONObject) o; - ActiveCosmetic cosmeticData = new ActiveCosmetic(); - cosmeticData.setActivityUID(UUID.fromString(jsonObject.getString("activityUID"))); - cosmeticData.setPlayerUID(UUID.fromString(jsonObject.getString("playerUID"))); - cosmeticData.setCosmeticData(UUID.fromString(jsonObject.getString("cosmeticUID"))); - cosmeticData.setUsername(jsonObject.getString("username")); - - activeCosmeticMap.put(cosmeticData.getActivityUID(), cosmeticData); - try { - if (Minecraft.getMinecraft().theWorld != null) { - EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(cosmeticData.getPlayerUID()); - if (entityPlayer != null) entityPlayer.refreshDisplayName(); - } - } catch (Exception e) {e.printStackTrace();} - } - this.activeCosmeticMap = activeCosmeticMap; - rebuildCaches(); - } else if (destination.equals("/user/queue/reply/cosmetic.list")) { - JSONArray object = new JSONArray(stompPayload.payload()); - Map newCosmeticList = new HashMap<>(); - for (Object o : object) { - JSONObject jsonObject = (JSONObject) o; - CosmeticData cosmeticData = new CosmeticData(); - cosmeticData.setCosmeticType(jsonObject.getString("cosmeticType")); - cosmeticData.setReqPerm(jsonObject.getString("reqPerm")); - cosmeticData.setData(jsonObject.getString("data")); - cosmeticData.setId(UUID.fromString(jsonObject.getString("id"))); - - newCosmeticList.put(cosmeticData.getId(), cosmeticData); - } - - cosmeticDataMap = newCosmeticList; - rebuildCaches(); - } - } - - private void rebuildCaches() { - Map> activeCosmeticByType = new HashMap<>(); - Map> activeCosmeticByPlayer = new HashMap<>(); - Map> activeCosmeticByPlayerName = new HashMap<>(); - for (ActiveCosmetic value : activeCosmeticMap.values()) { - CosmeticData cosmeticData = cosmeticDataMap.get(value.getCosmeticData()); - if (cosmeticData != null) { - List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); - cosmeticsByTypeList.add(value); - } - List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(value.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.add(value); - activeCosmetics = activeCosmeticByPlayerName.computeIfAbsent(value.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.add(value); - } - - this.activeCosmeticByPlayerNameLowerCase = activeCosmeticByPlayerName; - this.activeCosmeticByPlayer = activeCosmeticByPlayer; - this.activeCosmeticByType = activeCosmeticByType; - } - - @SubscribeEvent - public void stompConnect(StompConnectedEvent stompConnectedEvent) { - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/topic/cosmetic.set").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/reply/user.perms").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/reply/cosmetic.activelist").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/reply/cosmetic.list").build()); - - requestCosmeticsList(); - requestActiveCosmetics(); - requestPerms(); - } - @Getter @Setter - private static List iChatReplacers = new ArrayList<>(); - static { - iChatReplacers.add(new ChatReplacerViewProfile()); - iChatReplacers.add(new ChatReplacerPV()); - iChatReplacers.add(new ChatReplacerSocialOptions()); - iChatReplacers.add(new ChatReplacerCoop()); - iChatReplacers.add(new ChatReplacerMessage()); - iChatReplacers.add(new ChatReplacerChatByMe()); - } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - try { - if (clientChatReceivedEvent.type == 2) return; - for (IChatReplacer iChatReplacer : iChatReplacers) { - if (iChatReplacer.isAcceptable(clientChatReceivedEvent)) { - iChatReplacer.translate(clientChatReceivedEvent, this); - return; - } - } - } catch (Throwable t) { - System.out.println(clientChatReceivedEvent.message); - t.printStackTrace(); - } - } - - - @SubscribeEvent - public void onTabList(PlayerListItemPacketEvent packetPlayerListItem) { - S38PacketPlayerListItem asd = packetPlayerListItem.getPacketPlayerListItem(); - if (asd.getAction() == S38PacketPlayerListItem.Action.ADD_PLAYER) { - if (Minecraft.getMinecraft().getNetHandler() == null) return; - - Map playerInfoMap = ReflectionHelper.getPrivateValue(NetHandlerPlayClient.class, Minecraft.getMinecraft().getNetHandler(), "playerInfoMap", "field_147310_i","i"); - for (S38PacketPlayerListItem.AddPlayerData entry : asd.getEntries()) { - playerInfoMap.remove(entry.getProfile().getId()); - playerInfoMap.put(entry.getProfile().getId(), new CustomNetworkPlayerInfo(entry)); - } - } - } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void nameFormat(PlayerEvent.NameFormat nameFormat) { - List activeCosmetics = activeCosmeticByPlayer.get(nameFormat.entityPlayer.getGameProfile().getId()); - if (activeCosmetics == null) return; - CosmeticData color=null, prefix=null; - for (ActiveCosmetic activeCosmetic : activeCosmetics) { - CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); - if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { - color = cosmeticData; - } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { - prefix = cosmeticData; - } - } - - - if (color != null) - nameFormat.displayname = color.getData().replace("&","ยง")+nameFormat.username; - - if (prefix != null) - nameFormat.displayname = prefix.getData().replace("&","ยง")+" "+nameFormat.displayname; - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java deleted file mode 100644 index cfbf1fc0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.cosmetics; - -import com.mojang.authlib.GameProfile; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.network.play.server.S38PacketPlayerListItem; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; - -import java.util.List; - -public class CustomNetworkPlayerInfo extends NetworkPlayerInfo { - public CustomNetworkPlayerInfo(GameProfile p_i46294_1_) { - super(p_i46294_1_); - } - - public CustomNetworkPlayerInfo(S38PacketPlayerListItem.AddPlayerData p_i46295_1_) { - super(p_i46295_1_); - setDisplayName(super.getDisplayName()); - } - - - private IChatComponent displayName; - private String playernameLowercase; - private String unformatted; - private String actualName; - @Override - public void setDisplayName(IChatComponent displayNameIn) { - displayName = displayNameIn; - if (displayName == null) { - playernameLowercase = null; - unformatted = null; - return; - } - - unformatted = displayName.getUnformattedText(); - - - actualName = ""; - for (String s : unformatted.split(" ")) { - String strippped = TextUtils.stripColor(s); - if (strippped.startsWith("[")) continue; - actualName = strippped; - break; - } - playernameLowercase = actualName.toLowerCase(); - } - - public IChatComponent getDisplayName() - { - - String semi_name; - String actualName; - List activeCosmetics; - if (playernameLowercase != null) { - activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(playernameLowercase); - semi_name = unformatted; - actualName = this.actualName; - } else { - semi_name = ScorePlayerTeam.formatPlayerName(super.getPlayerTeam(), super.getGameProfile().getName()); - actualName = ""; - for (String s : semi_name.split(" ")) { - String strippped = TextUtils.stripColor(s); - if (strippped.startsWith("[")) continue; - actualName = strippped; - break; - } - activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(actualName.toLowerCase()); - } - - - if (activeCosmetics == null) return displayName; - CosmeticData color=null; - for (ActiveCosmetic activeCosmetic : activeCosmetics) { - CosmeticData cosmeticData = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData.getCosmeticType().equals("color")) color = cosmeticData; - } - - if (color != null) semi_name = semi_name.replace(actualName, color.getData()+actualName); - - return new ChatComponentText(semi_name); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java deleted file mode 100644 index 2f957c42..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.cosmetics; - -import kr.syeyoung.dungeonsguide.events.PlayerListItemPacketEvent; -import net.minecraft.network.Packet; -import net.minecraft.network.play.INetHandlerPlayClient; -import net.minecraft.network.play.server.S38PacketPlayerListItem; -import net.minecraftforge.common.MinecraftForge; - -public class CustomPacketPlayerListItem extends S38PacketPlayerListItem { - public CustomPacketPlayerListItem(S38PacketPlayerListItem packet) { - super(packet.getAction()); - getEntries().addAll(packet.getEntries()); - } - - @Override - public void processPacket(INetHandlerPlayClient handler) { - super.processPacket(handler); - - MinecraftForge.EVENT_BUS.post(new PlayerListItemPacketEvent(this)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java deleted file mode 100644 index b2bcfc0e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.cosmetics; - -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -public interface IChatReplacer { - boolean isAcceptable(ClientChatReceivedEvent event); - void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java deleted file mode 100644 index 8c99847a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; - -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.Tuple; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.List; - -public class ChatReplacerChatByMe implements IChatReplacer { - @Override - public boolean isAcceptable(ClientChatReceivedEvent event) { - for (IChatComponent sibling : event.message.getSiblings()) { - if (sibling.getUnformattedTextForChat().startsWith(": ")) return true; - } - return false; - } - - @Override - public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { - List> replaceMents = new ArrayList<>(); - List iChatComponents = new ArrayList<>( event.message.getSiblings() ); - List hasMsg = new ArrayList<>(); - for (IChatComponent sibling : iChatComponents) { - if (sibling.getUnformattedTextForChat().startsWith(": ")) break; - hasMsg.add(sibling); - } - iChatComponents.removeAll(hasMsg); - - ChatComponentText chatComponents = new ChatComponentText(""); - chatComponents.getSiblings().addAll(hasMsg); - ChatStyle origStyle = hasMsg.get(0).getChatStyle(); - String name = chatComponents.getFormattedText(); - - String[] splited = name.split(" "); - String actualName = splited[splited.length-1]; - - List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(actualName).toLowerCase()); - if (cDatas == null) return; - CosmeticData color=null, prefix=null; - for (ActiveCosmetic activeCosmetic : cDatas) { - CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { - color = cosmeticData; - } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { - prefix = cosmeticData; - } - } - - String building = ""; - if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; - for (int i = 0; i < splited.length-1; i++) { - building += splited[i] +" "; - } - - if (color != null) { - String nick = splited[splited.length-1]; - building += color.getData().replace("&","ยง"); - boolean foundLegitChar = false; - boolean foundColor = false; - for (char c : nick.toCharArray()) { - if (foundColor) { - foundColor = false; continue; - } - if (c == 'ยง' && !foundLegitChar) foundColor = true; - else { - foundLegitChar = true; - building += c; - } - } - } else { - building += splited[splited.length-1] ; - } - - ChatComponentText chatComponents1 = new ChatComponentText(building); - chatComponents1.setChatStyle(origStyle); - event.message.getSiblings().clear(); - event.message.getSiblings().add(chatComponents1); - event.message.getSiblings().addAll(iChatComponents); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java deleted file mode 100644 index 91bb58b6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; - -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.Tuple; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class ChatReplacerCoop implements IChatReplacer { - @Override - public boolean isAcceptable(ClientChatReceivedEvent event) { - for (IChatComponent sibling : event.message.getSiblings()) { - if (sibling.getUnformattedTextForChat().startsWith("ยงbCo-op > ")) return true; - } - return false; - } - - @Override - public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { - List> replaceMents = new ArrayList<>(); - List iChatComponents = new ArrayList<>( event.message.getSiblings() ); - IChatComponent sibling = iChatComponents.get(0); iChatComponents.remove(sibling); - - - String[] splitInto = sibling.getUnformattedTextForChat().split(" "); - int lastValidNickname = -1; - int lastprefix = -1; - for (int i = 0; i < splitInto.length; i++) { - String s = TextUtils.stripColor(splitInto[i]); - char c = s.charAt(0); - if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { - lastValidNickname = i; - } - } - if (lastValidNickname == -1) return; - - if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; - else lastprefix = lastValidNickname; - - - List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(splitInto[lastValidNickname].substring(0, splitInto[lastValidNickname].length()-1)).toLowerCase()); - - if (cDatas == null) return; - - CosmeticData color = null, prefix = null; - for (ActiveCosmetic activeCosmetic : cDatas) { - CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData != null && cosmeticData.getCosmeticType().equals("color")) { - color = cosmeticData; - } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { - prefix = cosmeticData; - } - } - - String building = ""; - for (int i = 0; i < lastprefix; i++) { - building += splitInto[i] +" "; - } - if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; - for (int i = lastprefix; i < lastValidNickname; i++) { - building += splitInto[i] +" "; - } - if (color != null) { - String nick = splitInto[lastValidNickname]; - building += color.getData().replace("&","ยง"); - boolean foundLegitChar = false; - boolean foundColor = false; - for (char c : nick.toCharArray()) { - if (foundColor) { - foundColor = false; continue; - } - if (c == 'ยง' && !foundLegitChar) foundColor = true; - else { - foundLegitChar = true; - building += c; - } - } - building += " "; - } else { - building += splitInto[lastValidNickname] + " "; - } - for (int i = lastValidNickname+1; i. - */ - -package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; - -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.Tuple; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class ChatReplacerMessage implements IChatReplacer { - @Override - public boolean isAcceptable(ClientChatReceivedEvent event) { - for (IChatComponent sibling : event.message.getSiblings()) { - if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/msg")) return true; - } - return false; - } - - @Override - public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { - List> replaceMents = new ArrayList<>(); - List iChatComponents = new ArrayList<>( event.message.getSiblings() ); - List hasMsg = new ArrayList<>(); - for (IChatComponent sibling : iChatComponents) { - if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/msg")) { - hasMsg.add(sibling); - } - } - iChatComponents.removeAll(hasMsg); - - ChatComponentText chatComponents = new ChatComponentText(""); - chatComponents.getSiblings().addAll(hasMsg); - ChatStyle origStyle = hasMsg.get(0).getChatStyle(); - String name = chatComponents.getFormattedText(); - - - String[] splited = name.split(" "); - String actualName = splited[splited.length-1]; - - List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(actualName).toLowerCase()); - if (cDatas == null || splited.length > 2) return; - CosmeticData color=null, prefix=null; - for (ActiveCosmetic activeCosmetic : cDatas) { - CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { - color = cosmeticData; - } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { - prefix = cosmeticData; - } - } - - String building = ""; - if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; - if (splited.length == 2) building += splited[0] +" "; - - if (color != null) { - String nick = splited[1]; - building += color.getData().replace("&","ยง"); - boolean foundLegitChar = false; - boolean foundColor = false; - for (char c : nick.toCharArray()) { - if (foundColor) { - foundColor = false; continue; - } - if (c == 'ยง' && !foundLegitChar) foundColor = true; - else { - foundLegitChar = true; - building += c; - } - } - } else { - building += splited[1] ; - } - - ChatComponentText chatComponents1 = new ChatComponentText(building); - chatComponents1.setChatStyle(origStyle); - event.message.getSiblings().clear(); - event.message.getSiblings().add(chatComponents1); - event.message.getSiblings().addAll(iChatComponents); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java deleted file mode 100644 index e5e4053f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; - -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.List; - - -// Bug 289 - mod conflict with NEU (Replaces /socialoptions with /pv) -public class ChatReplacerPV implements IChatReplacer { - @Override - public boolean isAcceptable(ClientChatReceivedEvent event) { - if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/pv")) return true; - return false; - } - - @Override - public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { - if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/pv")) { - String username = event.message.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; - List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(username.toLowerCase()); - - if (cDatas != null) { - CosmeticData color=null, prefix=null; - for (ActiveCosmetic activeCosmetic : cDatas) { - CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { - color = cosmeticData; - } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { - prefix = cosmeticData; - } - } - - String[] splitInto = event.message.getUnformattedTextForChat().split(" "); - int lastValidNickname = -1; - int lastprefix = -1; - for (int i = 0; i < splitInto.length; i++) { - String s = splitInto[i]; - if (s.startsWith("ยง7")) s = s.substring(2); - char c = s.charAt(0); - if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { - lastValidNickname = i; - if (i >= 1) { - String str = TextUtils.stripColor(splitInto[i-1]); - if (str.startsWith("[") && str.endsWith("]"))break; - } - } - } - if (lastValidNickname == -1) return; - - if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; - else lastprefix = lastValidNickname; - - String building = ""; - for (int i = 0; i < lastprefix; i++) { - building += splitInto[i] +" "; - } - if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; - for (int i = lastprefix; i < lastValidNickname; i++) { - building += splitInto[i] +" "; - } - if (color != null) { - String nick = splitInto[lastValidNickname]; - building += color.getData().replace("&","ยง"); - boolean foundLegitChar = false; - boolean foundColor = false; - for (char c : nick.toCharArray()) { - if (foundColor) { - foundColor = false; continue; - } - if (c == 'ยง' && !foundLegitChar) foundColor = true; - else { - foundLegitChar = true; - building += c; - } - } - building += " "; - } else { - building += splitInto[lastValidNickname] + " "; - } - for (int i = lastValidNickname+1; i. - */ - -package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; - -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.Tuple; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class ChatReplacerSocialOptions implements IChatReplacer { - @Override - public boolean isAcceptable(ClientChatReceivedEvent event) { - if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) return true; - return false; - } - - @Override - public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { - if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) { - String username = event.message.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; - List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(username.toLowerCase()); - - if (cDatas != null) { - CosmeticData color=null, prefix=null; - for (ActiveCosmetic activeCosmetic : cDatas) { - CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { - color = cosmeticData; - } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { - prefix = cosmeticData; - } - } - - String[] splitInto = event.message.getUnformattedTextForChat().split(" "); - int lastValidNickname = -1; - int lastprefix = -1; - for (int i = 0; i < splitInto.length; i++) { - String s = splitInto[i]; - if (s.startsWith("ยง7")) s = s.substring(2); - char c = s.charAt(0); - if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { - lastValidNickname = i; - if (i >= 1) { - String str = TextUtils.stripColor(splitInto[i-1]); - if (str.startsWith("[") && str.endsWith("]"))break; - } - } - } - if (lastValidNickname == -1) return; - - if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; - else lastprefix = lastValidNickname; - - String building = ""; - for (int i = 0; i < lastprefix; i++) { - building += splitInto[i] +" "; - } - if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; - for (int i = lastprefix; i < lastValidNickname; i++) { - building += splitInto[i] +" "; - } - if (color != null) { - String nick = splitInto[lastValidNickname]; - building += color.getData().replace("&","ยง"); - boolean foundLegitChar = false; - boolean foundColor = false; - for (char c : nick.toCharArray()) { - if (foundColor) { - foundColor = false; continue; - } - if (c == 'ยง' && !foundLegitChar) foundColor = true; - else { - foundLegitChar = true; - building += c; - } - } - building += " "; - } else { - building += splitInto[lastValidNickname] + " "; - } - for (int i = lastValidNickname+1; i. - */ - -package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; - -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.Tuple; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class ChatReplacerViewProfile implements IChatReplacer { - @Override - public boolean isAcceptable(ClientChatReceivedEvent event) { - for (IChatComponent sibling : event.message.getSiblings()) { - if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/viewprofile ")) return true; - } - return false; - } - - @Override - public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { - List> replaceMents = new ArrayList<>(); - for (IChatComponent sibling : event.message.getSiblings()) { - if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/viewprofile ")) { - String uid = sibling.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; - List cDatas = cosmeticsManager.getActiveCosmeticByPlayer().get(UUID.fromString(uid)); - - if (cDatas != null) { - CosmeticData color=null, prefix=null; - for (ActiveCosmetic activeCosmetic : cDatas) { - CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { - color = cosmeticData; - } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { - prefix = cosmeticData; - } - } - - String[] splitInto = sibling.getUnformattedTextForChat().split(" "); - int lastValidNickname = -1; - int lastprefix = -1; - for (int i = 0; i < splitInto.length; i++) { - String s = TextUtils.stripColor(splitInto[i]); - char c = s.charAt(0); - if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { - lastValidNickname = i; - if (i >= 1) { - String str = TextUtils.stripColor(splitInto[i-1]); - if (str.startsWith("[") && str.endsWith("]"))break; - } - } - } - if (lastValidNickname == -1) continue; - - if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; - else lastprefix = lastValidNickname; - - String building = ""; - for (int i = 0; i < lastprefix; i++) { - building += splitInto[i] +" "; - } - if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; - for (int i = lastprefix; i < lastValidNickname; i++) { - building += splitInto[i] +" "; - } - if (color != null) { - String nick = splitInto[lastValidNickname]; - building += color.getData().replace("&","ยง"); - boolean foundLegitChar = false; - boolean foundColor = false; - for (char c : nick.toCharArray()) { - if (foundColor) { - foundColor = false; continue; - } - if (c == 'ยง' && !foundLegitChar) foundColor = true; - else { - foundLegitChar = true; - building += c; - } - } - building += " "; - } else { - building += splitInto[lastValidNickname] + " "; - } - for (int i = lastValidNickname+1; i(sibling, newChatCompText)); - break; - } - } - } - - for (Tuple replaceMent : replaceMents) { - int index = event.message.getSiblings().indexOf(replaceMent.getFirst()); - event.message.getSiblings().set(index, replaceMent.getSecond()); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonActionManager.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonActionManager.java deleted file mode 100644 index 667f329c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonActionManager.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon; - -import lombok.Getter; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DungeonActionManager { - @Getter - private static final Map spawnLocation = new HashMap(); - - @Getter - private static final List killeds = new ArrayList(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java deleted file mode 100755 index bd04d7a9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProvider; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProviderRegistry; -import kr.syeyoung.dungeonsguide.dungeon.events.*; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.BossroomEnterEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.dungeon.FeatureDungeonMap; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessor; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.World; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.common.MinecraftForge; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class DungeonContext { - @Getter - private final World world; - @Getter - private final MapProcessor mapProcessor; - - @Getter - @Setter - private BlockPos dungeonMin; - - @Getter - private final Map roomMapper = new HashMap(); - @Getter - private final List dungeonRoomList = new ArrayList(); - - @Getter - private final List globalRoomProcessors = new ArrayList(); - - @Getter - private final Map deaths = new HashMap(); - @Getter - private final List milestoneReached = new ArrayList(); - @Getter - @Setter - private long BossRoomEnterSeconds = -1; - @Getter - @Setter - private long init = -1; - @Getter - @Setter - private BlockPos bossroomSpawnPos = null; - - @Getter - @Setter - private boolean trapRoomGen = false; - - @Getter - private boolean gotMimic = false; - - private int latestSecretCnt = 0; - private int latestTotalSecret = 0; - private int latestCrypts = 0; - - @Getter - private int maxSpeed = 600; - @Getter - private double secretPercentage = 1.0; - - public void setGotMimic(boolean gotMimic) { - this.gotMimic = gotMimic; - createEvent(new DungeonNodataEvent("MIMIC_KILLED")); - } - - @Getter - @Setter - private BossfightProcessor bossfightProcessor; - - @Getter - private final Set players = new HashSet(); - - @Getter - private final List events = new ArrayList(); - - public DungeonContext(World world) { - this.world = world; - createEvent(new DungeonNodataEvent("DUNGEON_CONTEXT_CREATION")); - mapProcessor = new MapProcessor(this); - DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - if (doorFinder != null) { - trapRoomGen = doorFinder.isTrapSpawn(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - - secretPercentage = doorFinder.secretPercentage(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - maxSpeed = doorFinder.speedSecond(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - } else mapProcessor.setBugged(true); - init = System.currentTimeMillis(); - } - - public void createEvent(DungeonEventData eventData) { - events.add(new DungeonEvent(eventData)); - } - - - private final Rectangle roomBoundary = new Rectangle(-10,-10,138,138); - - public void tick() { - mapProcessor.tick(); - - if (mapProcessor.isInitialized() && BossRoomEnterSeconds == -1 && !roomBoundary.contains(mapProcessor.worldPointToMapPoint(Minecraft.getMinecraft().thePlayer.getPositionVector()))) { - BossRoomEnterSeconds = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000; - bossroomSpawnPos = Minecraft.getMinecraft().thePlayer.getPosition(); - MinecraftForge.EVENT_BUS.post(new BossroomEnterEvent()); - createEvent(new DungeonNodataEvent("BOSSROOM_ENTER")); - DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - if (doorFinder != null) { - bossfightProcessor = doorFinder.createBossfightProcessor(world, DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - } else { - DungeonsGuide.sendDebugChat(new ChatComponentText("Error:: Null Data Providier")); - } - } - List list = FeatureDungeonMap.field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); - try { - for (int i = 1; i < 20; i++) { - NetworkPlayerInfo networkPlayerInfo = list.get(i); - String name = networkPlayerInfo.getDisplayName() != null ? networkPlayerInfo.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName()); - if (name.trim().equals("ยงr") || name.startsWith("ยงr ")) continue; - players.add(TextUtils.stripColor(name).trim().split(" ")[0]); - } - } catch (Exception e) {} - - if (latestSecretCnt != FeatureRegistry.DUNGEON_SECRETS.getSecretsFound()) { - int newSecretCnt = FeatureRegistry.DUNGEON_SECRETS.getSecretsFound(); - createEvent(new DungeonSecretCountChangeEvent(latestSecretCnt, newSecretCnt, latestTotalSecret, FeatureRegistry.DUNGEON_SECRETS.sureOfTotalSecrets())); - latestSecretCnt = newSecretCnt; - } - if (latestTotalSecret != FeatureRegistry.DUNGEON_SECRETS.getTotalSecretsInt()) { - latestTotalSecret = FeatureRegistry.DUNGEON_SECRETS.getTotalSecretsInt(); - createEvent(new DungeonSecretCountChangeEvent(latestSecretCnt, latestSecretCnt, latestTotalSecret, FeatureRegistry.DUNGEON_SECRETS.sureOfTotalSecrets())); - } - if (latestCrypts != FeatureRegistry.DUNGEON_TOMBS.getTombsFound()) { - int newlatestCrypts = FeatureRegistry.DUNGEON_TOMBS.getTombsFound(); - createEvent(new DungeonCryptBrokenEvent(latestCrypts, newlatestCrypts)); - this.latestCrypts = newlatestCrypts; - } - } - - @Getter - private boolean ended = false; - @Getter - private boolean defeated = false; - public void onChat(ClientChatReceivedEvent event) { - IChatComponent component = event.message; - String formatted = component.getFormattedText(); - if (formatted.contains("$DG-Comm")) { - event.setCanceled(true); - String data = component.getFormattedText().substring(component.getFormattedText().indexOf("$DG-Comm")); - String actual = TextUtils.stripColor(data); - String coords = actual.split(" ")[1]; - String secrets = actual.split(" ")[2]; - int x = Integer.parseInt(coords.split("/")[0]); - int z = Integer.parseInt(coords.split("/")[1]); - int secrets2 = Integer.parseInt(secrets); - Point roomPt = mapProcessor.worldPointToRoomPoint(new BlockPos(x,70,z)); - DungeonsGuide.sendDebugChat(new ChatComponentText("Message from Other dungeons guide :: "+roomPt.x+" / " + roomPt.y + " total secrets "+secrets2)); - DungeonRoom dr = roomMapper.get(roomPt); - if (dr != null) { - dr.setTotalSecrets(secrets2); - } - } else if (formatted.contains("$DG-Mimic")) { - setGotMimic(true); - } else if (formatted.startsWith("ยงrยงcยงlPUZZLE FAIL! ") && formatted.endsWith(" ยงrยง4Yยงrยงciยงrยง6kยงrยงeeยงrยงasยงrยง2!ยงr")) { - createEvent(new DungeonPuzzleFailureEvent(TextUtils.stripColor(formatted.split(" ")[2]), formatted)); - } else if (formatted.contains("ยง6> ยงeยงlEXTRA STATS ยง6<")) { - createEvent(new DungeonNodataEvent("DUNGEON_END")); - ended = true; - } else if (formatted.contains("ยงrยงcโ˜  ยงrยงeDefeated ")) { - defeated = true; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java deleted file mode 100755 index 8f9ae312..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java +++ /dev/null @@ -1,504 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProvider; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProviderRegistry; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.EDungeonDoorType; -import kr.syeyoung.dungeonsguide.dungeon.events.DungeonMapUpdateEvent; -import kr.syeyoung.dungeonsguide.dungeon.events.DungeonNodataEvent; -import kr.syeyoung.dungeonsguide.dungeon.events.DungeonRoomDiscoverEvent; -import kr.syeyoung.dungeonsguide.dungeon.events.SerializableBlockPos; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.DungeonContextInitializationEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.stomp.StompPayload; -import kr.syeyoung.dungeonsguide.utils.MapUtils; -import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemMap; -import net.minecraft.item.ItemStack; -import net.minecraft.util.*; -import net.minecraft.world.storage.MapData; -import net.minecraftforge.common.MinecraftForge; -import org.json.JSONObject; - -import javax.vecmath.Vector2d; -import java.awt.*; -import java.util.List; -import java.util.Queue; -import java.util.*; - -public class MapProcessor { - - private final DungeonContext context; - - private byte[] lastMapData; - - @Getter - private MapData lastMapData2; - - @Getter - private final BiMap mapIconToPlayerMap = HashBiMap.create(); - - @Getter @Setter - private Dimension unitRoomDimension; - @Getter @Setter - private Dimension doorDimension; // width: width of door, height: gap between rooms - @Getter @Setter - private Point topLeftMapPoint; - - @Setter - private boolean bugged = false; - - private final List roomsFound = new ArrayList(); - - private boolean axisMatch = false; - - @Getter - private boolean initialized = false; - - @Getter - private int undiscoveredRoom = 0; - - public MapProcessor(DungeonContext context) { - this.context = context; - } - - private static final Set directions = Sets.newHashSet(new Vector2d(0,1), new Vector2d(0, -1), new Vector2d(1, 0), new Vector2d(-1 , 0)); - - private int waitCnt = 0; - private void buildMap(final byte[] mapData) { - final Point startroom = MapUtils.findFirstColorWithIn(mapData, (byte) 30, new Rectangle(0,0,128,128)); - if (startroom == null){ - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCouldn't retrieve map data, disabling mod for this dungeon run")); - bugged = true; - return; - } - // Determine room dimension - { - int width = MapUtils.getWidthOfColorAt(mapData, (byte) 30, startroom); - int height = MapUtils.getHeightOfColorAt(mapData, (byte) 30, startroom); - unitRoomDimension = new Dimension(width, height); - } - Vector2d doorDir = null; - // determine the gap - { - Point midStartRoom = new Point(startroom.x + unitRoomDimension.width / 2, startroom.y +unitRoomDimension.height / 2); - final int halfWidth = unitRoomDimension.width / 2 + 2; - for (Vector2d v:directions) { - byte color = MapUtils.getMapColorAt(mapData, (int)(v.x * halfWidth +midStartRoom.x), (int)(v.y *halfWidth +midStartRoom.y)); - if (color != 0) { - doorDir = v; - break; - } - } - - if (doorDir == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCouldn't determine door of the room, disabling mod for this dungeon run")); - bugged = true; - return; - } - Point basePoint = new Point(startroom.x, startroom.y); - if (doorDir.x > 0) basePoint.x += unitRoomDimension.width; - if (doorDir.x < 0) basePoint.x += -1; - if (doorDir.y > 0) basePoint.y += unitRoomDimension.height; - if (doorDir.y < 0) basePoint.y += -1; - int gap = MapUtils.getLengthOfColorExtending(mapData, (byte) 0, basePoint, doorDir); - Point pt = MapUtils.findFirstColorWithInNegate(mapData, (byte)0, new Rectangle(basePoint.x, basePoint.y, (int)Math.abs(doorDir.y) * unitRoomDimension.width + 1, (int)Math.abs(doorDir.x) * unitRoomDimension.height + 1)); - if (pt == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCouldn't determine door of the room, disabling mod for this dungeon run")); - bugged = true; - return; - } - int doorWidth = MapUtils.getLengthOfColorExtending(mapData, MapUtils.getMapColorAt(mapData, pt.x, pt.y), pt, new Vector2d((int)Math.abs(doorDir.y), (int)Math.abs(doorDir.x))); - doorDimension = new Dimension(doorWidth, gap); - } - // Determine Top Left - { - int x = startroom.x; - int y = startroom.y; - while (x >= unitRoomDimension.width + doorDimension.height) x -= unitRoomDimension.width + doorDimension.height; - while (y >= unitRoomDimension.height + doorDimension.height) y -= unitRoomDimension.height + doorDimension.height; - topLeftMapPoint = new Point(x, y); - } - // determine door location based on npc, and determine map min from there - { - DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - if (doorFinder == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCouldn't find door processor for "+ DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName())); - bugged = true; - return; - } - BlockPos door = doorFinder.findDoor(context.getWorld(), DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - if (door == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCouldn't determine door of the room, disabling mod for this dungeon run")); - bugged = true; - return; - } - - DungeonsGuide.sendDebugChat(new ChatComponentText("door Pos:"+door)); - - Point unitPoint = mapPointToRoomPoint(startroom); - unitPoint.translate(unitPoint.x + 1, unitPoint.y + 1); - unitPoint.translate((int)doorDir.x, (int)doorDir.y); - - Vector2d offset = doorFinder.findDoorOffset(context.getWorld(), DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - axisMatch = doorDir.equals(offset); - - int worldX = unitPoint.x * 16; - int worldY = unitPoint.y * 16; - BlockPos worldMin = door.add(-worldX, 0, -worldY); - context.setDungeonMin(worldMin); - - } - - DungeonsGuide.sendDebugChat(new ChatComponentText("Found Green room:"+startroom)); - DungeonsGuide.sendDebugChat(new ChatComponentText("Axis match:"+axisMatch)); - DungeonsGuide.sendDebugChat(new ChatComponentText("World Min:"+context.getDungeonMin())); - DungeonsGuide.sendDebugChat(new ChatComponentText("Dimension:"+unitRoomDimension)); - DungeonsGuide.sendDebugChat(new ChatComponentText("top Left:"+topLeftMapPoint)); - DungeonsGuide.sendDebugChat(new ChatComponentText("door dimension:"+doorDimension)); - context.createEvent(new DungeonNodataEvent("MAP_PROCESSOR_INIT")); - initialized = true; - MinecraftForge.EVENT_BUS.post(new DungeonContextInitializationEvent()); - } - - public Point mapPointToRoomPoint(Point mapPoint) { - int x = (int)((mapPoint.x - topLeftMapPoint.x) / ((double)unitRoomDimension.width + doorDimension.height)); - int y = (int)((mapPoint.y - topLeftMapPoint.y) / ((double)unitRoomDimension.height + doorDimension.height)); - return new Point(x,y); - } - public BlockPos mapPointToWorldPoint(Point mapPoint) { - int x = (int)((mapPoint.x - topLeftMapPoint.x) / ((double)unitRoomDimension.width + doorDimension.height) * 32 + context.getDungeonMin().getX()); - int y = (int)((mapPoint.y - topLeftMapPoint.y) / ((double)unitRoomDimension.height + doorDimension.height) * 32 + context.getDungeonMin().getZ()); - return new BlockPos(x,70,y); - } - public Point roomPointToMapPoint(Point roomPoint) { - return new Point(roomPoint.x * (unitRoomDimension.width +doorDimension.height) + topLeftMapPoint.x, - roomPoint.y *(unitRoomDimension.height + doorDimension.height) + topLeftMapPoint.y); - } - public BlockPos roomPointToWorldPoint(Point roomPoint) { - return new BlockPos(context.getDungeonMin().getX() +(roomPoint.x * 32), context.getDungeonMin().getY(), context.getDungeonMin().getZ() +(roomPoint.y *32)); - } - public Point worldPointToRoomPoint(BlockPos worldPoint) { - if (context.getDungeonMin() == null) return null; - return new Point((worldPoint.getX() - context.getDungeonMin().getX()) / 32, (worldPoint.getZ() - context.getDungeonMin().getZ()) / 32); - } - - public Vector2d worldPointToMapPointFLOAT(Vec3 worldPoint) { - if (context.getDungeonMin() == null) return null; - double x = topLeftMapPoint.x + ((worldPoint.xCoord - context.getDungeonMin().getX()) / 32.0f * (unitRoomDimension.width + doorDimension.height)); - double y = topLeftMapPoint.y + ((worldPoint.zCoord - context.getDungeonMin().getZ()) / 32.0f * (unitRoomDimension.height + doorDimension.height)); - return new Vector2d(x, y); - } - - public Point worldPointToMapPoint(Vec3 worldPoint) { - if (context.getDungeonMin() == null) return null; - return new Point(topLeftMapPoint.x + (int)((worldPoint.xCoord - context.getDungeonMin().getX()) / 32.0f * (unitRoomDimension.width + doorDimension.height)), topLeftMapPoint.y + (int)((worldPoint.zCoord - context.getDungeonMin().getZ()) / 32.0f * (unitRoomDimension.height + doorDimension.height))); - } - - private void processMap(byte[] mapData) { - int height = (int)((128.0 - topLeftMapPoint.y) / (unitRoomDimension.height + doorDimension.height)); - int width = (int) ((128.0 - topLeftMapPoint.x) / (unitRoomDimension.width + doorDimension.height)); - if (MapUtils.getMapColorAt(mapData,0,0) != 0) return; - undiscoveredRoom = 0; - for (int y = 0; y <= height; y++){ - for (int x = 0; x <= width; x++) { - Point mapPoint = roomPointToMapPoint(new Point(x,y)); - byte color = MapUtils.getMapColorAt(mapData, mapPoint.x, mapPoint.y); - MapUtils.record(mapData, mapPoint.x, mapPoint.y, new Color(255,255,0,80)); - if (roomsFound.contains(new Point(x,y))) { - DungeonRoom dungeonRoom = context.getRoomMapper().get(new Point(x,y)); - if (color == 18 && dungeonRoom.getCurrentState() != DungeonRoom.RoomState.FINISHED) { - dungeonRoom.setCurrentState(DungeonRoom.RoomState.COMPLETE_WITHOUT_SECRETS); - dungeonRoom.setTotalSecrets(0); - } else if (color == 30) { - dungeonRoom.setCurrentState(DungeonRoom.RoomState.FINISHED); - dungeonRoom.setTotalSecrets(0); - } else if (dungeonRoom.getCurrentState() != DungeonRoom.RoomState.FINISHED){ - byte centerColor = MapUtils.getMapColorAt(mapData, mapPoint.x + unitRoomDimension.width / 2, mapPoint.y + unitRoomDimension.height / 2); - MapUtils.record(mapData, mapPoint.x + unitRoomDimension.width / 2, mapPoint.y + unitRoomDimension.height / 2, new Color(0,255,0,80)); - if (centerColor == 34) { - dungeonRoom.setCurrentState(DungeonRoom.RoomState.COMPLETE_WITHOUT_SECRETS); - } else if (centerColor == 30) { - dungeonRoom.setCurrentState(DungeonRoom.RoomState.FINISHED); - } else if (centerColor == 18) { // red - dungeonRoom.setCurrentState(DungeonRoom.RoomState.FAILED); - } - } - if (dungeonRoom.getTotalSecrets() == -1) { - if (dungeonRoom.getColor() == 82) dungeonRoom.setTotalSecrets(0); - else if (dungeonRoom.getColor() == 74) dungeonRoom.setTotalSecrets(0); - MapUtils.record(mapData, mapPoint.x, mapPoint.y +1, new Color(0,255,0,80)); - } - continue; - } - - if (color != 0 && color != 85) { - MapUtils.record(mapData, mapPoint.x, mapPoint.y, new Color(0,255,255,80)); - DungeonRoom rooms = buildRoom(mapData, new Point(x,y)); - if (rooms == null) continue; - context.createEvent(new DungeonRoomDiscoverEvent(rooms.getUnitPoints().get(0), rooms.getRoomMatcher().getRotation(), new SerializableBlockPos(rooms.getMin()), new SerializableBlockPos(rooms.getMax()), rooms.getShape(),rooms.getColor(), rooms.getDungeonRoomInfo().getUuid(), rooms.getDungeonRoomInfo().getName(), rooms.getDungeonRoomInfo().getProcessorId())); - DungeonsGuide.sendDebugChat(new ChatComponentText("New Map discovered! shape: "+rooms.getShape()+ " color: "+rooms.getColor()+" unitPos: "+x+","+y)); - DungeonsGuide.sendDebugChat(new ChatComponentText("New Map discovered! mapMin: "+rooms.getMin() + " mapMx: "+rooms.getMax())); - StringBuilder builder = new StringBuilder(); - for (int dy =0;dy<4;dy++) { - builder.append("\n"); - for (int dx = 0; dx < 4; dx ++) { - boolean isSet = ((rooms.getShape() >> (dy * 4 + dx)) & 0x1) != 0; - builder.append(isSet ? "O" : "X"); - } - } - DungeonsGuide.sendDebugChat(new ChatComponentText("Shape visual: "+ builder)); - - context.getDungeonRoomList().add(rooms); - for (Point p:rooms.getUnitPoints()) { - roomsFound.add(p); - context.getRoomMapper().put(p, rooms); - } - if (rooms.getRoomProcessor() != null && rooms.getRoomProcessor().readGlobalChat()) - context.getGlobalRoomProcessors().add(rooms.getRoomProcessor()); - } else if (color == 85){ - undiscoveredRoom++; - } - - } - } - } - - private static final Set door_dirs = Sets.newHashSet(new Vector2d(0,0.5), new Vector2d(0, -0.5), new Vector2d(0.5, 0), new Vector2d(-0.5 , 0)); - private DungeonRoom buildRoom(byte[] mapData, Point unitPoint) { - Queue toCheck = new LinkedList(); - toCheck.add(new Point[] {unitPoint, unitPoint}); // requestor, target - Set checked = new HashSet(); - List ayConnected = new ArrayList(); - - int minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE; - int maxX = 0, maxY = 0; - while(toCheck.peek() != null) { - Point[] check = toCheck.poll(); - if (checked.contains(check[1])) continue; - checked.add(check[1]); - - if (checkIfConnected(mapData, check[0], check[1])) { - ayConnected.add(check[1]); - if (check[1].x < minX) minX = check[1].x; - if (check[1].y < minY) minY = check[1].y; - if (check[1].x > maxX) maxX = check[1].x; - if (check[1].y > maxY) maxY = check[1].y; - for (Vector2d dir: directions) { - Point newPt = new Point(check[1].x + (int)dir.x, check[1].y +(int)dir.y); - toCheck.add(new Point[]{check[1], newPt}); - } - } - } - - short shape = 0; - for (Point p:ayConnected) { - int localX = p.x - minX, localY = p.y - minY; - shape |= 1 <<(localY *4 + localX); - } - Set doors = new HashSet<>(); - for (Point p: ayConnected) { - for (Vector2d v: door_dirs) { - Vector2d v2 = new Vector2d(p.x + v.x , p.y + v.y ); - if (doors.contains(v2)) doors.remove(v2); - else doors.add(v2); - } - } - Point pt2 = roomPointToMapPoint(ayConnected.get(0)); - byte unit1 = MapUtils.getMapColorAt(mapData, pt2.x, pt2.y); - - // 0: none 1: open door door 2. unopen door 3: wither door 4. red door - Set> doorsAndStates = new HashSet<>(); - final int halfWidth = unitRoomDimension.width + 4; - for (Vector2d door : doors) { - int floorX = (int)Math.floor(door.x), floorY = (int)Math.floor(door.y); - Point mapPt = roomPointToMapPoint(new Point(floorX, floorY)); - Point target = new Point(mapPt.x+ unitRoomDimension.width/2 + (int)(halfWidth*(door.x - floorX)), mapPt.y + unitRoomDimension.height/2 + (int)(halfWidth*(door.y - floorY)) ); - MapUtils.record(mapData, target.x, target.y, Color.green); - byte color = MapUtils.getMapColorAt(mapData, target.x, target.y); - - Vector2d vector2d = new Vector2d(door.x - minX, door.y - minY); - if (color == 0) { - doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.NONE)); - } else if (color == 85) { - doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.UNOPEN)); - } else if (color == 119) { - doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.WITHER)); - } else if (color == 18 && unit1 != 18) { - doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.BLOOD)); - } else { - doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.ENTRANCE)); - } - } - - - try{ - return new DungeonRoom(ayConnected, shape, unit1, roomPointToWorldPoint(new Point(minX, minY)), roomPointToWorldPoint(new Point(maxX+1, maxY+1)).add(-1, 0, -1), context, doorsAndStates); - } catch (IllegalStateException ex) { - DungeonsGuide.sendDebugChat(new ChatComponentText("Failed to load room, retrying later :: "+ex.getLocalizedMessage())); - return null; - } - } - - private boolean checkIfConnected(byte[] mapData, Point unitPoint1, Point unitPoint2) { - if (unitPoint1 == unitPoint2) return true; - if (unitPoint1.equals(unitPoint2)) return true; - - - Point high = (unitPoint2.y > unitPoint1.y) ? unitPoint2 :(unitPoint2.x > unitPoint1.x) ? unitPoint2 : unitPoint1; - Point low = high == unitPoint2 ? unitPoint1 : unitPoint2; - - int xOff = low.x - high.x; - int yOff = low.y - high.y; - Point pt = roomPointToMapPoint(high); - Point pt2 = roomPointToMapPoint(low); - byte unit1 = MapUtils.getMapColorAt(mapData, pt.x, pt.y); - byte unit2 = MapUtils.getMapColorAt(mapData, pt2.x, pt2.y); - pt.translate(xOff, yOff); - byte unit3 = MapUtils.getMapColorAt(mapData, pt.x, pt.y); - - return unit1 == unit2 && unit2 == unit3 && unit1 != 0; - } - - public boolean isThereDifference(byte[] colors1, byte[] colors) { - if (colors1 == null || colors == null) return true; - for (int i =0; i < colors.length; i++) - if (colors[i] != colors1[i]) return true; - return false; - } - private int stabilizationTick = 0; - - private boolean processed = false; - private void processFinishedMap(byte[] mapData) { - if (MapUtils.getMapColorAt(mapData, 0, 0) == 0) return; - if (processed) return; - processed = true; - MapUtils.clearMap(); - MapUtils.record(mapData, 0, 0, Color.GREEN); - - int skill = MapUtils.readNumber(mapData, 51, 35, 9); - int exp = MapUtils.readNumber(mapData, 51, 54, 9); - int time = MapUtils.readNumber(mapData, 51, 73, 9); - int bonus = MapUtils.readNumber(mapData, 51, 92, 9); - DungeonsGuide.sendDebugChat(new ChatComponentText(("skill: " + skill + " / exp: " + exp + " / time: " + time + " / bonus : " + bonus))); - JSONObject payload = new JSONObject().put("timeSB", FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed()) - .put("timeR", FeatureRegistry.DUNGEON_REALTIME.getTimeElapsed()) - .put("timeScore", time) - .put("completionStage", context.getBossRoomEnterSeconds() == -1 ? 0 : - context.isDefeated() ? 2 : 1) - .put("percentage", DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getPercentage() / 100.0) - .put("floor", DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - DungeonsGuide.sendDebugChat(new ChatComponentText(payload.toString())); - - try { - String target = StaticResourceCache.INSTANCE.getResource(StaticResourceCache.DATA_COLLECTION).get().getValue(); - if (FeatureRegistry.ETC_COLLECT_SCORE.isEnabled() && !target.contains("falsefalsefalsefalse")) { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().payload(payload.toString()).header("destination", target.replace("false", "").trim())); - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - - public void tick() { - if (waitCnt < 5) { - waitCnt++; - return; - } - if (bugged) return; - ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(8); - byte[] mapData; - if (stack == null || !(stack.getItem() instanceof ItemMap)) { - mapData = lastMapData; - } else { - MapData mapData1 = ((ItemMap)stack.getItem()).getMapData(stack, context.getWorld()); - if (mapData1 == null) mapData = lastMapData; - else { - mapData = mapData1.colors; - lastMapData2 = mapData1; - - if (isThereDifference(lastMapData, mapData)) { - stabilizationTick =0; - context.createEvent(new DungeonMapUpdateEvent(mapData)); - } else { - stabilizationTick++; - } - - if (stabilizationTick > 20) { - if (doorDimension == null) buildMap(mapData); - else processMap(mapData); - - if (context.isEnded()) { - processFinishedMap(mapData); - } - } - lastMapData = mapData; - } - - } - - - if (lastMapData2 != null && mapIconToPlayerMap.size() < context.getPlayers().size() && initialized) { - label: for (Map.Entry stringVec4bEntry : lastMapData2.mapDecorations.entrySet()) { - if (mapIconToPlayerMap.containsValue(stringVec4bEntry.getKey())) continue; - int x = stringVec4bEntry.getValue().func_176112_b() /2 + 64; - int y = stringVec4bEntry.getValue().func_176113_c() /2 + 64; - BlockPos mapPos = mapPointToWorldPoint(new Point(x, y)); - String potentialPlayer = null; - for (String player : context.getPlayers()) { // check nearby players - if (mapIconToPlayerMap.containsKey(player)) continue; - EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(player); - if (entityPlayer == null || entityPlayer.isInvisible()) continue; - BlockPos pos = entityPlayer.getPosition(); - int dx = mapPos.getX() - pos.getX(); - int dz = mapPos.getZ() - pos.getZ(); - if (dx * dx + dz * dz < 100) { - if (potentialPlayer != null) continue label; - potentialPlayer = player; - } - } - if (potentialPlayer == null) continue; - - for (Map.Entry stringVec4bEntry2 : lastMapData2.mapDecorations.entrySet()) { // check nearby markers - if (mapIconToPlayerMap.containsValue(stringVec4bEntry.getKey())) continue; - if (stringVec4bEntry.getKey().equals(stringVec4bEntry2.getKey())) continue; - int x2 = stringVec4bEntry2.getValue().func_176112_b() /2 + 64; - int y2 = stringVec4bEntry2.getValue().func_176113_c() /2 + 64; - int dx = x2 - x; - int dy = y2 - y; - if (dx * dx + dy * dy < 100) { - continue label; - } - } - mapIconToPlayerMap.put(potentialPlayer, stringVec4bEntry.getKey()); - } - } - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java deleted file mode 100644 index 4fd4056d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -public abstract class AbstractAction implements Action { - @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - - } - - @Override - public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } - - @Override - public void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } - - @Override - public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } - - @Override - public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java deleted file mode 100755 index 1a4ad682..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.util.Set; - -public interface Action { - Set getPreRequisites(DungeonRoom dungeonRoom); - - void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); - void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); - void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); - void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag); - void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties); - void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties); - - boolean isComplete(DungeonRoom dungeonRoom); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java deleted file mode 100755 index 39d3e7ef..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionBreakWithSuperBoom extends AbstractAction { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - - public ActionBreakWithSuperBoom(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return target.getBlock(dungeonRoom) == Blocks.air; - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - - BlockPos blockpos = target.getBlockPos(dungeonRoom); - - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - GlStateManager.disableLighting(); - GlStateManager.enableAlpha(); - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - GlStateManager.enableBlend(); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer vertexbuffer = tessellator.getWorldRenderer(); - vertexbuffer.begin(7, DefaultVertexFormats.BLOCK); - - BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); - blockrendererdispatcher.getBlockModelRenderer().renderModel(Minecraft.getMinecraft().theWorld, - blockrendererdispatcher.getBlockModelShapes().getModelForState(Blocks.tnt.getDefaultState()), - Blocks.tnt.getDefaultState(), blockpos, vertexbuffer, false); - tessellator.draw(); - - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - RenderUtils.highlightBlock(blockpos, new Color(0, 255,255,50), partialTicks, true); - RenderUtils.drawTextAtWorld("Superboom", blockpos.getX() + 0.5f, blockpos.getY() + 0.5f, blockpos.getZ() + 0.5f, 0xFFFFFF00, 0.03f, false, false, partialTicks); - } - - @Override - public String toString() { - return "BreakWithSuperboom\n- target: "+target.toString(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java deleted file mode 100755 index 56b27528..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDummy; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionChangeState extends AbstractAction{ - @EqualsAndHashCode.Exclude - private Set preRequisite2 = new HashSet(); - - private String mechanicName; - private String state; - - public ActionChangeState(String mechanicName, String state) { - this.mechanicName = mechanicName; - this.state = state; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - Set set = new HashSet(); - set.addAll(preRequisite2); - DungeonMechanic mechanic = dungeonRoom.getMechanics().get(mechanicName); - if (mechanic!= null) - set.addAll(mechanic.getAction(state, dungeonRoom)); - return set; - } - @Override - public String toString() { - return "ChangeState\n- target: "+mechanicName+"\n- state: "+state; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - DungeonMechanic mechanic = dungeonRoom.getMechanics().get(mechanicName); - if (state.equalsIgnoreCase("navigate")) - return true; - if (mechanic== null) - return false; - if (mechanic instanceof DungeonSecret && ((DungeonSecret) mechanic).getSecretType() != DungeonSecret.SecretType.CHEST) - return true; - if (mechanic instanceof DungeonDummy) - return true; - return mechanic.getCurrentState(dungeonRoom).equalsIgnoreCase(state); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java deleted file mode 100755 index 1b463f2e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionClick extends AbstractAction { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - private Predicate predicate = Predicates.alwaysTrue(); - - private boolean clicked = false; - - public ActionClick(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return clicked; - } - - @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - if (clicked) return; - if (target.getBlockPos(dungeonRoom).equals(event.pos) && - (predicate == null || predicate.apply(event.entityLiving.getHeldItem()))) { - clicked = true; - } - } - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); - RenderUtils.drawTextAtWorld("Click", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - - @Override - public String toString() { - return "Click\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java deleted file mode 100755 index 975c19e9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionClickSet extends AbstractAction { - private Set preRequisite = new HashSet(); - private OffsetPointSet target; - private Predicate predicate = Predicates.alwaysTrue(); - - public ActionClickSet(OffsetPointSet target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public String toString() { - return "ClickSet\n- targets size: "+target.getOffsetPointList().size()+"\n- predicate: "+predicate.getClass().getSimpleName(); - } - - private boolean clicked = false; - @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - if (clicked) return; - for (OffsetPoint pt2: target.getOffsetPointList()) { - if (pt2.getBlockPos(dungeonRoom).equals(event.pos) && - (predicate == null || predicate.apply(event.entityLiving.getHeldItem()))) { - clicked = true; - } - } - - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - float xAcc = 0; - float yAcc = 0; - float zAcc = 0; - int size = target.getOffsetPointList().size(); - for (OffsetPoint offsetPoint : target.getOffsetPointList()) { - BlockPos pos = offsetPoint.getBlockPos(dungeonRoom); - xAcc += pos.getX() + 0.5f; - yAcc += pos.getY()+ 0.5f; - zAcc += pos.getZ()+ 0.5f; - RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), new Color(0, 255,255,50),partialTicks, true); - } - - RenderUtils.drawTextAtWorld("Click", xAcc / size, yAcc / size, zAcc / size, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return clicked; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionComplete.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionComplete.java deleted file mode 100644 index 3389ed62..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionComplete.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; - -import java.util.Collections; -import java.util.Set; - -public class ActionComplete extends AbstractAction { - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return Collections.emptySet(); - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return false; - } - - @Override - public String toString() { - return "Completed"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java deleted file mode 100755 index 2e90d3a3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; - -import java.awt.*; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -@Data -public class ActionDropItem extends AbstractAction { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - private Predicate predicate = Predicates.alwaysTrue(); - - public ActionDropItem(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - BlockPos pos = target.getBlockPos(dungeonRoom); - List item = dungeonRoom.getContext().getWorld().getEntitiesWithinAABB(EntityItem.class, - AxisAlignedBB.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1, pos.getY() + 1, pos.getZ() + 1)); - if (item.size() == 0) return false; - return (predicate == null || predicate.apply(item.get(0))); - } - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); - RenderUtils.drawTextAtWorld("Drop Item", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - @Override - public String toString() { - return "DropItem\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java deleted file mode 100755 index 3033754c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.entity.Entity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionInteract extends AbstractAction { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - private Predicate predicate = Predicates.alwaysFalse(); - private int radius; - - public ActionInteract(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return interacted; - } - - private boolean interacted = false; - @Override - public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - if (interacted) return; - - Vec3 spawnLoc = DungeonActionManager.getSpawnLocation().get(event.getEntity().getEntityId()); - if (spawnLoc == null) return; - if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) return; - if (!predicate.apply(event.getEntity())) return; - interacted = true; - } - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); - RenderUtils.drawTextAtWorld("Interact", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - @Override - public String toString() { - return "InteractEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java deleted file mode 100755 index a08b81f0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.entity.Entity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; -import net.minecraftforge.event.entity.living.LivingDeathEvent; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionKill extends AbstractAction { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - private Predicate predicate = Predicates.alwaysFalse(); - private int radius; - - public ActionKill(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - Vec3 spawn = new Vec3(target.getBlockPos(dungeonRoom)); - for (Integer killed : DungeonActionManager.getKilleds()) { - if (DungeonActionManager.getSpawnLocation().get(killed) == null) continue; - if (DungeonActionManager.getSpawnLocation().get(killed).squareDistanceTo(spawn) < 100) { - return true; - } - } - - return killed; - } - - private boolean killed = false; - @Override - public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { - if (killed) return; - - Vec3 spawnLoc = DungeonActionManager.getSpawnLocation().get(event.entity.getEntityId()); - if (spawnLoc == null) return; - if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) return; - if (!predicate.apply(event.entity)) return; - killed = true; - } - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); - RenderUtils.drawTextAtWorld("Spawn", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); - } - - @Override - public String toString() { - return "KillEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java deleted file mode 100755 index ec790489..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureTogglePathfind; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; - -import java.util.HashSet; -import java.util.Set; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -@Data -public class ActionMove extends AbstractAction { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - - public ActionMove(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 25; - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - - float distance = MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())); - float multiplier = distance / 120f; //mobs only render ~120 blocks away - if (flag) multiplier *= 2.0f; - float scale = 0.45f * multiplier; - scale *= 25.0 / 6.0; - if (actionRouteProperties.isBeacon()) { - RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), actionRouteProperties.getBeaconBeamColor(), partialTicks); - RenderUtils.highlightBlock(pos, actionRouteProperties.getBeaconColor(), partialTicks); - } - RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); - RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); - - if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !FeatureRegistry.SECRET_TOGGLE_KEY.togglePathfindStatus) { - if (poses != null){ - RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); - } - } - } - - private int tick = -1; - private List poses; - private Future> latestFuture; - - @Override - public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { - tick = (tick+1) % Math.max(1, actionRouteProperties.getLineRefreshRate()); - if (latestFuture != null && latestFuture.isDone()) { - try { - poses = latestFuture.get(); - latestFuture = null; - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - - if (tick == 0 && actionRouteProperties.isPathfind() && latestFuture == null) { - if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() || poses == null) - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); - } - } - - public void forceRefresh(DungeonRoom dungeonRoom) { - try { - if (latestFuture != null) return; - } catch (Exception ignored) {} - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); - } - @Override - public String toString() { - return "Move\n- target: "+target.toString(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java deleted file mode 100755 index 14897147..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -@Data -public class ActionMoveNearestAir extends AbstractAction { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - - public ActionMoveNearestAir(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 25; - } - - @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { - BlockPos pos = target.getBlockPos(dungeonRoom); - - float distance = MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())); - float multiplier = distance / 120f; //mobs only render ~120 blocks away - if (flag) multiplier *= 2.0f; - float scale = 0.45f * multiplier; - scale *= 25.0 / 6.0; - if (actionRouteProperties.isBeacon()) { - RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), actionRouteProperties.getBeaconBeamColor(), partialTicks); - RenderUtils.highlightBlock(pos, actionRouteProperties.getBeaconColor(), partialTicks); - } - RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); - RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); - - if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !FeatureRegistry.SECRET_TOGGLE_KEY.togglePathfindStatus) { - if (poses != null){ - RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); - } - } - } - - private int tick = -1; - private List poses; - private Future> latestFuture; - @Override - public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { - tick = (tick+1) % Math.max(1, actionRouteProperties.getLineRefreshRate()); - if (latestFuture != null && latestFuture.isDone()) { - try { - poses = latestFuture.get(); - latestFuture = null; - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - - if (tick == 0 && actionRouteProperties.isPathfind() && latestFuture == null) { - if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() || poses == null) - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); - } - } - - - public void forceRefresh(DungeonRoom dungeonRoom) { - try { - if (latestFuture != null) return; - } catch (Exception ignored) {} - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); - } - @Override - public String toString() { - return "MoveNearestAir\n- target: "+target.toString(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java deleted file mode 100755 index 39c7fa6c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionRoot extends AbstractAction { - private Set preRequisite = new HashSet(); - - public ActionRoot() { - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } - - @Override - public boolean isComplete(DungeonRoom dungeonRoom) { - return true; - } - - @Override - public String toString() { - return "Action Root"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java deleted file mode 100644 index 3580dd03..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions.tree; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import lombok.Data; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.util.List; - -public class ActionRoute { - @Getter - private final String mechanic; - @Getter - private final String state; - - @Getter - private int current; - @Getter - private final List actions; - - private final DungeonRoom dungeonRoom; - - @Getter - private final ActionRouteProperties actionRouteProperties; - - public ActionRoute(DungeonRoom dungeonRoom, String mechanic, String state, ActionRouteProperties actionRouteProperties) { - this.mechanic = mechanic; - this.state = state; - this.actionRouteProperties = actionRouteProperties; - - ActionChangeState actionChangeState = new ActionChangeState(mechanic, state); - ActionTree tree= ActionTree.buildActionTree(actionChangeState, dungeonRoom); - actions = ActionTreeUtil.linearifyActionTree(tree); - actions.add(new ActionComplete()); - current = 0; - this.dungeonRoom = dungeonRoom; - } - - public Action next() { - current ++; - if (current >= actions.size()) current = actions.size() - 1; - return actions.get(current); - } - - public Action prev() { - current --; - if (current < 0) current = 0; - return actions.get(current); - } - - public Action getCurrentAction() { - return actions.get(current); - } - - - - public void onPlayerInteract(PlayerInteractEvent event) { - getCurrentAction().onPlayerInteract(dungeonRoom, event, actionRouteProperties ); - } - public void onLivingDeath(LivingDeathEvent event) { - getCurrentAction().onLivingDeath(dungeonRoom, event, actionRouteProperties ); - } - public void onRenderWorld(float partialTicks, boolean flag) { - if (current -1 >= 0 && ( - (actions.get(current-1) instanceof ActionMove && ((ActionMove) actions.get(current-1)).getTarget().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) >= 25) - || (actions.get(current-1) instanceof ActionMoveNearestAir && ((ActionMoveNearestAir) actions.get(current-1)).getTarget().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) >= 25))) actions.get(current-1).onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag ); - getCurrentAction().onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag); - } - - public void onRenderScreen(float partialTicks) { - getCurrentAction().onRenderScreen(dungeonRoom, partialTicks, actionRouteProperties); - } - - public void onTick() { - Action current = getCurrentAction(); - - current.onTick(dungeonRoom, actionRouteProperties); - if (this.current -1 >= 0 && (actions.get(this.current-1) instanceof ActionMove || actions.get(this.current-1) instanceof ActionMoveNearestAir)) actions.get(this.current-1).onTick(dungeonRoom, actionRouteProperties ); - - if (dungeonRoom.getMechanics().get(mechanic).getCurrentState(dungeonRoom).equals(state)) { - this.current = actions.size() - 1; - } - - if (current.isComplete(dungeonRoom)) - next(); - } - - public void onLivingInteract(PlayerInteractEntityEvent event) { getCurrentAction().onLivingInteract(dungeonRoom, event, actionRouteProperties ); } - - @Data - public static class ActionRouteProperties { - private boolean pathfind; - private int lineRefreshRate; - private AColor lineColor; - private float lineWidth; - - private boolean beacon; - private AColor beaconColor; - private AColor beaconBeamColor; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java deleted file mode 100755 index 3139ce73..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions.tree; - -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionRoot; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@Data -public class ActionTree implements Cloneable { - @EqualsAndHashCode.Exclude - private Set parent; - private Action current; - private Set children; - - @Override - public int hashCode() { return current == null ? 0 : current.hashCode(); } - - - public static ActionTree buildActionTree(Set actions, DungeonRoom dungeonRoom) { - ActionRoot root = new ActionRoot(); - root.setPreRequisite(actions); - ActionTree tree = new ActionTree(); - tree.setParent(new HashSet()); - tree.setCurrent(root); - HashSet set = new HashSet(); - for (Action action : actions) { - set.add(buildActionTree(tree, action, dungeonRoom, new HashMap())); - } - tree.setChildren(set); - return tree; - } - public static ActionTree buildActionTree(Action actions, DungeonRoom dungeonRoom) { - return buildActionTree(null, actions, dungeonRoom, new HashMap()); - } - - - - private static ActionTree buildActionTree(ActionTree parent, Action action, DungeonRoom dungeonRoom, Map alreadyBuilt) { - if (action == null) return null; - if (alreadyBuilt.containsKey(action)) { - ActionTree tree = alreadyBuilt.get(action); - tree.getParent().add(parent); - return tree; - } - - ActionTree tree = new ActionTree(); - alreadyBuilt.put(action, tree); - tree.setParent(new HashSet()); - if (parent != null) - tree.getParent().add(parent); - tree.setCurrent(action); - HashSet set = new HashSet(); - for (Action action2 : action.getPreRequisites(dungeonRoom)) { - set.add(buildActionTree(tree, action2, dungeonRoom, alreadyBuilt)); - } - tree.setChildren(set); - return tree; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java deleted file mode 100644 index b0ffd2dc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.actions.tree; - -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; - -import java.util.*; - -public class ActionTreeUtil { - public static List linearifyActionTree(ActionTree input) { - ActionTree tree = copyActionTree(input); - - List actions = new ArrayList(); - - int plsHalt = 0; - while (tree.getChildren().size() != 0) { - plsHalt ++; - if (plsHalt > 1000000) throw new IllegalStateException("Linearifying process ran for 1 million cycle"); - Set visited = new HashSet(); - ActionTree curr = tree; - - int plsHalt2 = 0; - while (curr.getChildren().size() != 0) { - plsHalt2 ++; - if (plsHalt2 > 1000000) throw new IllegalStateException("Finding the leaf of tree ran for 1 million cycles"); - if (visited.contains(curr)) throw new IllegalStateException("Circular Reference Detected"); - visited.add(curr); - curr = curr.getChildren().iterator().next(); - } - - plsHalt2 =0; - while(curr.getChildren().size() == 0) { - plsHalt2 ++; - if (plsHalt2 > 1000000) throw new IllegalStateException("Building of array ran for 1 million cycles"); - - actions.add(curr.getCurrent()); - if (curr.getParent().size() == 0) break; - for (ActionTree parentTree:curr.getParent()) - parentTree.getChildren().remove(curr); - curr = curr.getParent().iterator().next(); - } - } - return actions; - } - - public static ActionTree copyActionTree(ActionTree tree) { - Map built = new HashMap(); - if (tree.getParent().size() != 0) throw new IllegalArgumentException("that is not head of tree"); - return copyActionTree(tree, built); - } - private static ActionTree copyActionTree(ActionTree tree, Map preBuilts) { - if (preBuilts.containsKey(tree)) return preBuilts.get(tree); - - ActionTree clone = new ActionTree(); - preBuilts.put(tree, clone); - - clone.setCurrent(tree.getCurrent()); - clone.setParent(new HashSet()); - clone.setChildren(new HashSet()); - for (ActionTree tree3 : tree.getChildren()) { - ActionTree clone3 = copyActionTree(tree3, preBuilts); - clone3.getParent().add(clone); - clone.getChildren().add(clone3); - } - return clone; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java index 0df1f15a..8c430e4c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java @@ -18,7 +18,7 @@ package kr.syeyoung.dungeonsguide.dungeon.data; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; import lombok.Getter; import lombok.Setter; @@ -53,8 +53,8 @@ public class DungeonRoomInfo implements Serializable { private String processorId = "default"; - private Map properties = new HashMap(); + private Map properties = new HashMap<>(); - private Map mechanics = new HashMap(); + private Map mechanics = new HashMap<>(); private int totalSecrets = -1; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java index 36317878..f5baa2ca 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPoint.java @@ -18,8 +18,8 @@ package kr.syeyoung.dungeonsguide.dungeon.data; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.VectorUtils; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.VectorUtils; import lombok.AllArgsConstructor; import lombok.Data; import net.minecraft.block.Block; @@ -63,25 +63,23 @@ public class OffsetPoint implements Cloneable, Serializable { } public BlockPos toRotatedRelBlockPos(DungeonRoom dungeonRoom) { - int rot = dungeonRoom.getRoomMatcher().getRotation(); - Vector2d rot2 = new Vector2d(x,z); + Vector2d rot = new Vector2d(x,z); for (int i = 0; i < dungeonRoom.getRoomMatcher().getRotation(); i++) { - rot2 = VectorUtils.rotateCounterClockwise(rot2); + rot = VectorUtils.rotateCounterClockwise(rot); if (i % 2 == 0) { - rot2.y += dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 1; // + Z + rot.y += dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 1; // + Z } else { - rot2.y += dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 1; // + X + rot.y += dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 1; // + X } } - return new BlockPos(rot2.x, y, rot2.y); + return new BlockPos(rot.x, y, rot.y); } public Block getBlock(DungeonRoom dungeonRoom) { BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); - Block b = dungeonRoom.getRelativeBlockAt(relBp.getX(), relBp.getY(), relBp.getZ()); - return b; + return dungeonRoom.getRelativeBlockAt(relBp.getX(), relBp.getY(), relBp.getZ()); } public BlockPos getBlockPos(DungeonRoom dungeonRoom) { BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); @@ -91,8 +89,7 @@ public class OffsetPoint implements Cloneable, Serializable { public int getData(DungeonRoom dungeonRoom) { BlockPos relBp = toRotatedRelBlockPos(dungeonRoom); - int b = dungeonRoom.getRelativeBlockDataAt(relBp.getX(), relBp.getY(), relBp.getZ()); - return b; + return dungeonRoom.getRelativeBlockDataAt(relBp.getX(), relBp.getY(), relBp.getZ()); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java index 6e8e5ee7..0fc21dc2 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/OffsetPointSet.java @@ -26,7 +26,7 @@ import java.util.List; @Data public class OffsetPointSet implements Cloneable, Serializable { - private List offsetPointList = new ArrayList(); + private List offsetPointList = new ArrayList<>(); @Override public Object clone() throws CloneNotSupportedException { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java deleted file mode 100755 index ef7f076e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.doorfinder; - -import com.google.common.base.Predicate; -import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.*; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.world.World; - -import javax.vecmath.Vector2d; -import java.util.Collection; -import java.util.Set; - -public class CatacombDataProvider implements DungeonSpecificDataProvider { - - private static final Set directions = Sets.newHashSet(new Vector2d(0,1), new Vector2d(0, -1), new Vector2d(1, 0), new Vector2d(-1 , 0)); - - @Override - public BlockPos findDoor(World w, String dungeonName) { - Collection armorStand = w.getEntities(EntityArmorStand.class, new Predicate() { - @Override - public boolean apply(EntityArmorStand input) { - return input.getName().equals("ยงbMort"); - } - }); - - if (armorStand.size() != 0) { - EntityArmorStand mort = armorStand.iterator().next(); - BlockPos pos = mort.getPosition(); - pos = pos.add(0, 3, 0); - for (int i = 0; i < 5; i++) { - for (Vector2d vector2d:directions) { - BlockPos test = pos.add(vector2d.x * i, 0, vector2d.y * i); - if (w.getChunkFromBlockCoords(test).getBlock(test) == Blocks.iron_bars) { - return pos.add(vector2d.x * (i + 2), -2, vector2d.y * (i+2)); - } - } - } - } - return null; - } - - @Override - public Vector2d findDoorOffset(World w, String dungeonName) { - Collection armorStand = w.getEntities(EntityArmorStand.class, new Predicate() { - @Override - public boolean apply(EntityArmorStand input) { - return input.getName().equals("ยงbMort"); - } - }); - - if (armorStand.size() != 0) { - EntityArmorStand mort = armorStand.iterator().next(); - BlockPos pos = mort.getPosition(); - pos = pos.add(0, 3, 0); - for (int i = 0; i < 5; i++) { - for (Vector2d vector2d:directions) { - BlockPos test = pos.add(vector2d.x * i, 0, vector2d.y * i); - if (w.getChunkFromBlockCoords(test).getBlock(test) == Blocks.iron_bars) { - return vector2d; - } - } - } - } - return null; - } - /* - * - * */ - - @Override - public BossfightProcessor createBossfightProcessor(World w, String dungeonName) { - String floor = dungeonName.substring(14).trim(); - DungeonsGuide.sendDebugChat(new ChatComponentText("Floor: "+floor+ " Building bossfight processor")); - if (floor.equals("F1")) { - return new BossfightProcessorBonzo(); - } else if (floor.equals("F2")) { - return new BossfightProcessorScarf(); - } else if (floor.equals("F3")) { - return new BossfightProcessorProf(); - } else if (floor.equals("F4")) { - return new BossfightProcessorThorn(); - } else if (floor.equals("F5")) { - return new BossfightProcessorLivid(false); - } else if (floor.equals("F6")) { - return new BossfightProcessorSadan(); - } else if (floor.equals("F7")) { - return new BossfightProcessorNecron(); - } - return null; - } - - @Override - public boolean isTrapSpawn(String dungeonName) { - String floor = dungeonName.substring(14).trim(); - if (floor.equals("F3")) { - return true; - } else if (floor.equals("F4")) { - return true; - } else if (floor.equals("F5")) { - return true; - } else if (floor.equals("F6")) { - return true; - } else return floor.equals("F7"); - } - - @Override - public double secretPercentage(String dungeonName) { - String floor = dungeonName.substring(14).trim(); - if (floor.equals("F1")) { - return 0.3; - } else if (floor.equals("F2")) { - return 0.4; - } else if (floor.equals("F3")) { - return 0.5; - } else if (floor.equals("F4")) { - return 0.6; - } else if (floor.equals("F5")) { - return 0.7; - } else if (floor.equals("F6")) { - return 0.85; - } else if (floor.equals("F7")) { - return 1.0; - } else if (floor.equals("E")) { - return 0.3; - } - return 1.0; - } - - @Override - public int speedSecond(String dungeonName) { - String floor = dungeonName.substring(14).trim(); - if (floor.equals("F1")) { - return 600; - } else if (floor.equals("F2")) { - return 600; - } else if (floor.equals("F3")) { - return 600; - } else if (floor.equals("F4")) { - return 600; - } else if (floor.equals("F5")) { - return 720; - } else if (floor.equals("F6")) { - return 600; - } else if (floor.equals("F7")) { - return 720; - } - return 600; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombMasterDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombMasterDataProvider.java deleted file mode 100755 index 921efa63..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombMasterDataProvider.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.doorfinder; - -import com.google.common.base.Predicate; -import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.*; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.world.World; - -import javax.vecmath.Vector2d; -import java.util.Collection; -import java.util.Set; - -public class CatacombMasterDataProvider implements DungeonSpecificDataProvider { - - private static final Set directions = Sets.newHashSet(new Vector2d(0,1), new Vector2d(0, -1), new Vector2d(1, 0), new Vector2d(-1 , 0)); - - @Override - public BlockPos findDoor(World w, String dungeonName) { - Collection armorStand = w.getEntities(EntityArmorStand.class, new Predicate() { - @Override - public boolean apply(EntityArmorStand input) { - return input.getName().equals("ยงbMort"); - } - }); - - if (armorStand.size() != 0) { - EntityArmorStand mort = armorStand.iterator().next(); - BlockPos pos = mort.getPosition(); - pos = pos.add(0, 3, 0); - for (int i = 0; i < 5; i++) { - for (Vector2d vector2d:directions) { - BlockPos test = pos.add(vector2d.x * i, 0, vector2d.y * i); - if (w.getChunkFromBlockCoords(test).getBlock(test) == Blocks.iron_bars) { - return pos.add(vector2d.x * (i + 2), -2, vector2d.y * (i+2)); - } - } - } - } - return null; - } - - @Override - public Vector2d findDoorOffset(World w, String dungeonName) { - Collection armorStand = w.getEntities(EntityArmorStand.class, new Predicate() { - @Override - public boolean apply(EntityArmorStand input) { - return input.getName().equals("ยงbMort"); - } - }); - - if (armorStand.size() != 0) { - EntityArmorStand mort = armorStand.iterator().next(); - BlockPos pos = mort.getPosition(); - pos = pos.add(0, 3, 0); - for (int i = 0; i < 5; i++) { - for (Vector2d vector2d:directions) { - BlockPos test = pos.add(vector2d.x * i, 0, vector2d.y * i); - if (w.getChunkFromBlockCoords(test).getBlock(test) == Blocks.iron_bars) { - return vector2d; - } - } - } - } - return null; - } - /* - * - * */ - - @Override - public BossfightProcessor createBossfightProcessor(World w, String dungeonName) { - String floor = dungeonName.substring(14).trim(); - DungeonsGuide.sendDebugChat(new ChatComponentText("Floor: Master mode "+floor+ " Building bossfight processor")); - if (floor.equals("M5")) { - return new BossfightProcessorLivid(true); - } - return null; - } - - @Override - public boolean isTrapSpawn(String dungeonName) { - String floor = dungeonName.substring(14).trim(); - if (floor.equals("M3")) { - return true; - } else if (floor.equals("M4")) { - return true; - } else if (floor.equals("M5")) { - return true; - } else if (floor.equals("M6")) { - return true; - } else return floor.equals("M7"); - } - - @Override - public double secretPercentage(String dungeonName) { - return 1.0; - } - - @Override - public int speedSecond(String dungeonName) { - return 480; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java deleted file mode 100755 index 9a52dad8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.doorfinder; - -import com.google.common.collect.Sets; -import lombok.Getter; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -import java.util.Set; - -@Getter -public class DungeonDoor { - private final World w; - private final BlockPos position; - private EDungeonDoorType type; - private boolean isZDir; - - private static final Set legalBlocks = Sets.newHashSet(Blocks.coal_block, Blocks.barrier, Blocks.monster_egg, Blocks.air, Blocks.stained_hardened_clay); - - public DungeonDoor(World world, BlockPos pos, EDungeonDoorType type) { - this.w = world; - this.position = pos; - Block itshouldbeall = world.getChunkFromBlockCoords(pos).getBlock(pos); - - if (type == EDungeonDoorType.WITHER && itshouldbeall == Blocks.air) type = EDungeonDoorType.WITHER_FAIRY; - this.type = type; - boolean exist = type.isExist(); - - for (int x = -1; x<=1; x++) - for (int y = -1; y<=1; y++) - for (int z = -1; z<=1; z++) { - BlockPos pos2 = pos.add(x,y,z); - Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); - if (itshouldbeall != block) exist = false; - } - if (exist) { - BlockPos ZCheck = pos.add(0,0,2); - isZDir = world.getChunkFromBlockCoords(ZCheck).getBlock(ZCheck) == Blocks.air; - - if (isZDir) { - for (int x = -1; x<=1; x++) - for (int y = -1; y<=1; y++) - for (int z = -2; z<=2; z+=4) { - BlockPos pos2 = pos.add(x,y,z); - Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); - if (block != Blocks.air) exist = false; - } - } else { - for (int x = -2; x<=2; x+=4) - for (int y = -1; y<=1; y++) - for (int z = -1; z<=1; z++) { - BlockPos pos2 = pos.add(x,y,z); - Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); - if (block != Blocks.air) exist = false; - } - } - } - if (!exist) { - isZDir = false; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProvider.java deleted file mode 100755 index dfdd0e3e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.doorfinder; - -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessor; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -import javax.vecmath.Vector2d; - -public interface DungeonSpecificDataProvider { - BlockPos findDoor(World w, String dungeonName); - Vector2d findDoorOffset(World w, String dungeonName); - - BossfightProcessor createBossfightProcessor(World w, String dungeonName); - - boolean isTrapSpawn(String dungeonName); - - double secretPercentage(String dungeonName); - - int speedSecond(String dungeonName); -} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java deleted file mode 100755 index 3753e6ca..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.doorfinder; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - -public class DungeonSpecificDataProviderRegistry { - public static final Map doorFinders = new HashMap(); - - static { - doorFinders.put(Pattern.compile("The Catacombs (?:F[0-9]|E)"), new CatacombDataProvider()); - doorFinders.put(Pattern.compile("The Catacombs (?:M[0-9])"), new CatacombMasterDataProvider()); - } - - public static DungeonSpecificDataProvider getDoorFinder(String dungeonName) { - for (Map.Entry doorFinderEntry :doorFinders.entrySet()){ - if (doorFinderEntry.getKey().matcher(dungeonName).matches()) return doorFinderEntry.getValue(); - } - return null; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/EDungeonDoorType.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/EDungeonDoorType.java deleted file mode 100644 index 3a07629e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/EDungeonDoorType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.doorfinder; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@AllArgsConstructor -@Getter -public enum EDungeonDoorType { - NONE(false, false, false,"?"), ENTRANCE(true, false, false, "entrance"), WITHER(true, true,true,"withergate"),WITHER_FAIRY(true, false,true,"wither-fairy-gate"), BLOOD(true, true,true, "bloodgate"), UNOPEN(true, false, false,"gate"); - - private boolean exist; - private boolean keyRequired; - private boolean headToBlood; - private String name; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonCryptBrokenEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonCryptBrokenEvent.java deleted file mode 100644 index 6c4b02b8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonCryptBrokenEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.AllArgsConstructor; -import lombok.Data; - -import java.awt.*; - -@Data -@AllArgsConstructor -public class DungeonCryptBrokenEvent implements DungeonEventData { - private int prevCrypts; - private int newCrypts; - - @Override - public String getEventName() { - return "CRYPTS_CHANGE"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonDeathEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonDeathEvent.java deleted file mode 100644 index 7e1dea89..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonDeathEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.AllArgsConstructor; -import lombok.Data; - -import java.awt.*; - -@Data -@AllArgsConstructor -public class DungeonDeathEvent implements DungeonEventData { - private String playerName; - private String message; - private int cnt; - - @Override - public String getEventName() { - return "PLAYER_DEATH"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEvent.java deleted file mode 100644 index 3ba6a2e8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import lombok.Data; - -import java.io.Serializable; - -@Data -public class DungeonEvent implements Serializable { - private long UTCTime = System.currentTimeMillis(); - private long realTimeElapsed; - private long skyblockTimeElapsed; - - private String eventName; - private DungeonEventData data; - - public DungeonEvent(DungeonEventData eventData){ - this.data = eventData; - this.realTimeElapsed = FeatureRegistry.DUNGEON_REALTIME.getTimeElapsed(); - this.skyblockTimeElapsed = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed(); - this.eventName = eventData.getEventName(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventData.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventData.java deleted file mode 100644 index 8883380a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventData.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import java.io.Serializable; - -public interface DungeonEventData extends Serializable { - String getEventName(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventHolder.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventHolder.java deleted file mode 100644 index 4216e11b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventHolder.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import lombok.Data; - -import java.io.Serializable; -import java.util.List; -import java.util.Set; - -@Data -public class DungeonEventHolder implements Serializable { - private long date; - private Set players; - private List eventDataList; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonMapUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonMapUpdateEvent.java deleted file mode 100644 index 27969582..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonMapUpdateEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class DungeonMapUpdateEvent implements DungeonEventData { - private byte[] map; - - @Override - public String getEventName() { - return "MAP_UPDATE"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonNodataEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonNodataEvent.java deleted file mode 100644 index 4a355498..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonNodataEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class DungeonNodataEvent implements DungeonEventData { - private String eventName; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonPuzzleFailureEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonPuzzleFailureEvent.java deleted file mode 100644 index 44fa40c1..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonPuzzleFailureEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class DungeonPuzzleFailureEvent implements DungeonEventData { - private String playerName; - private String message; - @Override - public String getEventName() { - return "PUZZLE_FAILURE"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonRoomDiscoverEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonRoomDiscoverEvent.java deleted file mode 100644 index 9e8b74ce..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonRoomDiscoverEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.util.BlockPos; - -import java.awt.*; -import java.util.UUID; - -@Data -@AllArgsConstructor -public class DungeonRoomDiscoverEvent implements DungeonEventData { - private Point unitPt; - private int rotation; - private SerializableBlockPos min; - private SerializableBlockPos max; - private int shape; - private int color; - private UUID roomUID; - private String roomName; - private String roomProc; - - @Override - public String getEventName() { - return "ROOM_DISCOVER"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonSecretCountChangeEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonSecretCountChangeEvent.java deleted file mode 100644 index fd96e261..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonSecretCountChangeEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.AllArgsConstructor; -import lombok.Data; - -import java.awt.*; - -@Data -@AllArgsConstructor -public class DungeonSecretCountChangeEvent implements DungeonEventData { - private int prevCount; - private int newCount; - private int totalSecret; - private boolean sureTotalSecret; - - @Override - public String getEventName() { - return "SECRET_CNT_CHANGE"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonStateChangeEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonStateChangeEvent.java deleted file mode 100644 index 34676e02..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonStateChangeEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.util.BlockPos; - -import java.awt.*; -import java.util.UUID; - -@Data -@AllArgsConstructor -public class DungeonStateChangeEvent implements DungeonEventData { - private Point unitPt; - private String roomName; - private DungeonRoom.RoomState from; - private DungeonRoom.RoomState to; - - @Override - public String getEventName() { - return "ROOM_STATE_CHANGE"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/SerializableBlockPos.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/SerializableBlockPos.java deleted file mode 100644 index ab1031e7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/SerializableBlockPos.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.events; - -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.util.BlockPos; - -import java.io.Serializable; - -@Data @AllArgsConstructor -public class SerializableBlockPos implements Serializable { - private int x, y, z; - - public SerializableBlockPos(BlockPos pos) { - this.x = pos.getX(); - this.y = pos.getY(); - this.z = pos.getZ(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java index dc201fdb..64d4dc0b 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java @@ -19,11 +19,13 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.RouteBlocker; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -41,10 +43,10 @@ public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker { @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (state.equalsIgnoreCase("navigate")) { - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); int leastY = Integer.MAX_VALUE; OffsetPoint thatPt = null; @@ -69,8 +71,8 @@ public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker { if (!isBlocking(dungeonRoom)) { return Collections.emptySet(); } - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); { ActionBreakWithSuperBoom actionClick; preRequisites.add(actionClick = new ActionBreakWithSuperBoom(getRepresentingPoint(dungeonRoom))); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java index e31cc78e..fc5abe45 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java @@ -19,12 +19,14 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.RouteBlocker; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; @@ -42,11 +44,11 @@ public class DungeonDoor implements DungeonMechanic, RouteBlocker { @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (!("open".equalsIgnoreCase(state) || "closed".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for door"); if (state.equalsIgnoreCase(getCurrentState(dungeonRoom))) return Collections.emptySet(); - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); { if (state.equalsIgnoreCase("open")) { for (String str : openPreRequisite) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDummy.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDummy.java index 876764be..60ca1b3a 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDummy.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDummy.java @@ -19,10 +19,11 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.util.BlockPos; @@ -40,10 +41,10 @@ public class DungeonDummy implements DungeonMechanic { @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { // if (!"navigate".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); if (state.equalsIgnoreCase("navigate")){ ActionMove actionMove = new ActionMove(secretPoint); preRequisites.add(actionMove); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonFairySoul.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonFairySoul.java index c5270a9c..0bbecfbd 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonFairySoul.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonFairySoul.java @@ -19,17 +19,25 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionInteract; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateArmorStand; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; +import net.minecraft.entity.Entity; import net.minecraft.util.BlockPos; import java.awt.*; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; -import java.util.*; +import java.util.Set; +import java.util.function.Predicate; @Data public class DungeonFairySoul implements DungeonMechanic { @@ -39,27 +47,25 @@ public class DungeonFairySoul implements DungeonMechanic { @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { - if (!"navigate".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); - Set base; - Set preRequisites = base = new HashSet(); - { - ActionInteract actionClick= new ActionInteract(secretPoint); - actionClick.setPredicate(PredicateArmorStand.INSTANCE); - actionClick.setRadius(3); - preRequisites.add(actionClick); - preRequisites = actionClick.getPreRequisite(); - } - { - ActionMove actionMove = new ActionMove(secretPoint); - preRequisites.add(actionMove); - preRequisites = actionMove.getPreRequisite(); - } - { - for (String str : preRequisite) { - if (str.isEmpty()) continue; - ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); - preRequisites.add(actionChangeState); + public Set getAction(String state, DungeonRoom dungeonRoom) { + if (!"navigate".equalsIgnoreCase(state)) + throw new IllegalArgumentException(state + " is not valid state for secret"); + + Set base = new HashSet<>(); + ActionInteract actionClick = new ActionInteract(secretPoint); + actionClick.setPredicate((Predicate) PredicateArmorStand.INSTANCE); + actionClick.setRadius(3); + base.add(actionClick); + + base = actionClick.getPreRequisite(); + ActionMove actionMove = new ActionMove(secretPoint); + base.add(actionMove); + base = actionMove.getPreRequisite(); + + for (String str : preRequisite) { + if (!str.isEmpty()) { + String[] split = str.split(":"); + base.add(new ActionChangeState(split[0], split[1])); } } return base; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonJournal.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonJournal.java index 8796bccb..1edf51ef 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonJournal.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonJournal.java @@ -19,12 +19,13 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.util.BlockPos; @@ -42,10 +43,10 @@ public class DungeonJournal implements DungeonMechanic { @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (!"navigate".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); { ActionMove actionMove = new ActionMove(secretPoint); preRequisites.add(actionMove); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java index 6d50ae78..637c9c2d 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java @@ -19,10 +19,11 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.util.BlockPos; @@ -37,11 +38,11 @@ public class DungeonLever implements DungeonMechanic { private String triggering = ""; @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (state.equals(getCurrentState(dungeonRoom))) return Collections.emptySet(); if (state.equalsIgnoreCase("navigate")) { - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint(dungeonRoom)); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); @@ -54,8 +55,8 @@ public class DungeonLever implements DungeonMechanic { } if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); if (!state.equalsIgnoreCase(getCurrentState(dungeonRoom))){ ActionClick actionClick; preRequisites.add(actionClick = new ActionClick(leverPoint)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java deleted file mode 100755 index 54cac356..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.mechanics; - -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; - -import java.awt.*; -import java.io.Serializable; -import java.util.Set; - -public interface DungeonMechanic extends Serializable { - Set getAction(String state, DungeonRoom dungeonRoom); - - void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks); - - String getCurrentState(DungeonRoom dungeonRoom); - - Set getPossibleStates(DungeonRoom dungeonRoom); - Set getTotalPossibleStates(DungeonRoom dungeonRoom); - - OffsetPoint getRepresentingPoint(DungeonRoom dungeonRoom); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonNPC.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonNPC.java index 6007421f..9785cb62 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonNPC.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonNPC.java @@ -19,15 +19,17 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionInteract; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionInteract; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateArmorStand; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; +import net.minecraft.entity.Entity; import net.minecraft.util.BlockPos; import java.awt.*; @@ -35,36 +37,35 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Predicate; @Data public class DungeonNPC implements DungeonMechanic { private static final long serialVersionUID = -89487601113028763L; - private OffsetPoint secretPoint = new OffsetPoint(0,0,0); + private OffsetPoint secretPoint = new OffsetPoint(0, 0, 0); private List preRequisite = new ArrayList(); @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { - if (!"navigate".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); - Set base; - Set preRequisites = base = new HashSet(); - { - ActionInteract actionClick= new ActionInteract(secretPoint); - actionClick.setPredicate(PredicateArmorStand.INSTANCE); - actionClick.setRadius(3); - preRequisites.add(actionClick); - preRequisites = actionClick.getPreRequisite(); - } - { - ActionMove actionMove = new ActionMove(secretPoint); - preRequisites.add(actionMove); - preRequisites = actionMove.getPreRequisite(); - } - { - for (String str : preRequisite) { - if (str.isEmpty()) continue; - ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); - preRequisites.add(actionChangeState); + public Set getAction(String state, DungeonRoom dungeonRoom) { + if (!"navigate".equalsIgnoreCase(state)) + throw new IllegalArgumentException(state + " is not valid state for secret"); + + Set base = new HashSet<>(); + ActionInteract actionClick = new ActionInteract(secretPoint); + actionClick.setPredicate((Predicate) PredicateArmorStand.INSTANCE); + actionClick.setRadius(3); + base.add(actionClick); + + base = actionClick.getPreRequisite(); + ActionMove actionMove = new ActionMove(secretPoint); + base.add(actionMove); + base = actionMove.getPreRequisite(); + + for (String str : preRequisite) { + if (!str.isEmpty()) { + String[] split = str.split(":"); + base.add(new ActionChangeState(split[0], split[1])); } } return base; @@ -73,9 +74,9 @@ public class DungeonNPC implements DungeonMechanic { @Override public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { BlockPos pos = getSecretPoint().getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, color,partialTicks); - RenderUtils.drawTextAtWorld("F-"+name, pos.getX() +0.5f, pos.getY()+0.375f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); - RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.highlightBlock(pos, color, partialTicks); + RenderUtils.drawTextAtWorld("F-" + name, pos.getX() + 0.5f, pos.getY() + 0.375f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() + 0.5f, pos.getY() + 0f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); } @@ -96,10 +97,12 @@ public class DungeonNPC implements DungeonMechanic { public Set getPossibleStates(DungeonRoom dungeonRoom) { return Sets.newHashSet("navigate"); } + @Override public Set getTotalPossibleStates(DungeonRoom dungeonRoom) { - return Sets.newHashSet("no-state","navigate"); + return Sets.newHashSet("no-state", "navigate"); } + @Override public OffsetPoint getRepresentingPoint(DungeonRoom dungeonRoom) { return secretPoint; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java index 92634c00..84201a60 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java @@ -19,13 +19,15 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionMoveNearestAir; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.RouteBlocker; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; @@ -42,10 +44,10 @@ public class DungeonOnewayDoor implements DungeonMechanic, RouteBlocker { @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (state.equalsIgnoreCase("navigate")) { - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint(dungeonRoom)); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); @@ -60,8 +62,8 @@ public class DungeonOnewayDoor implements DungeonMechanic, RouteBlocker { if (!isBlocking(dungeonRoom)) { return Collections.emptySet(); } - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); { for (String str : preRequisite) { if (str.isEmpty()) continue; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java index 00c876c5..d0212380 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java @@ -19,10 +19,11 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.util.BlockPos; @@ -38,11 +39,11 @@ public class DungeonOnewayLever implements DungeonMechanic { private String triggering = ""; @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (state.equals(getCurrentState(dungeonRoom))) return Collections.emptySet(); if (state.equalsIgnoreCase("navigate")) { - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint(dungeonRoom)); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); @@ -54,8 +55,8 @@ public class DungeonOnewayLever implements DungeonMechanic { return base; } if (!("triggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); { ActionClick actionClick; preRequisites.add(actionClick = new ActionClick(leverPoint)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java index 1542513d..1f45e91d 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java @@ -19,10 +19,11 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.util.BlockPos; @@ -33,16 +34,16 @@ import java.util.List; @Data public class DungeonPressurePlate implements DungeonMechanic { private static final long serialVersionUID = 7450034718355390645L; - private OffsetPoint platePoint = new OffsetPoint(0,0,0); + private OffsetPoint platePoint = new OffsetPoint(0, 0, 0); private List preRequisite = new ArrayList(); private String triggering = ""; @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (state.equals(getCurrentState(dungeonRoom))) return Collections.emptySet(); if (state.equalsIgnoreCase("navigate")) { - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint(dungeonRoom)); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); @@ -53,37 +54,35 @@ public class DungeonPressurePlate implements DungeonMechanic { } return base; } - if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); + if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) + throw new IllegalArgumentException(state + " is not valid state for secret"); if (state.equalsIgnoreCase(getCurrentState(dungeonRoom))) return Collections.emptySet(); - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); if ("triggered".equalsIgnoreCase(state)) { ActionDropItem actionClick; preRequisites.add(actionClick = new ActionDropItem(platePoint)); preRequisites = actionClick.getPreRequisite(); } - { - ActionMove actionMove = new ActionMove(platePoint); - preRequisites.add(actionMove); - preRequisites = actionMove.getPreRequisite(); - } - { - for (String str : preRequisite) { - if (str.isEmpty()) continue; - ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); - preRequisites.add(actionChangeState); - } + ActionMove actionMove = new ActionMove(platePoint); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); } + return base; } @Override public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { BlockPos pos = getPlatePoint().getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, color,partialTicks); - RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0.75f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); - RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0.25f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.highlightBlock(pos, color, partialTicks); + RenderUtils.drawTextAtWorld(name, pos.getX() + 0.5f, pos.getY() + 0.75f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() + 0.5f, pos.getY() + 0.25f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); } public DungeonPressurePlate clone() throws CloneNotSupportedException { @@ -99,8 +98,7 @@ public class DungeonPressurePlate implements DungeonMechanic { public String getCurrentState(DungeonRoom dungeonRoom) { if (triggering == null) triggering = "null"; DungeonMechanic mechanic = dungeonRoom.getMechanics().get(triggering); - if (mechanic == null) - { + if (mechanic == null) { return "undeterminable"; } else { String state = mechanic.getCurrentState(dungeonRoom); @@ -121,10 +119,12 @@ public class DungeonPressurePlate implements DungeonMechanic { return Sets.newHashSet("navigate", "triggered"); return Sets.newHashSet("navigate"); } + @Override public Set getTotalPossibleStates(DungeonRoom dungeonRoom) { return Sets.newHashSet("triggered", "untriggered"); } + @Override public OffsetPoint getRepresentingPoint(DungeonRoom dungeonRoom) { return platePoint; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonRoomDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonRoomDoor.java index 5ff85a13..259f438e 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonRoomDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonRoomDoor.java @@ -19,14 +19,14 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Getter; -import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import java.awt.*; @@ -41,15 +41,15 @@ public class DungeonRoomDoor implements DungeonMechanic { public DungeonRoomDoor(DungeonRoom dungeonRoom, DungeonDoor doorfinder) { this.doorfinder = doorfinder; if (doorfinder.isZDir()) { - if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(0,0,2))) - offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(0,0,2)); - else if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(0,0,-2))) - offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(0,0,-2)); + if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(0, 0, 2))) + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(0, 0, 2)); + else if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(0, 0, -2))) + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(0, 0, -2)); } else { - if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(2,0,0))) - offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(2,0,0)); - else if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(-2,0,0))) - offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(-2,0,0)); + if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(2, 0, 0))) + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(2, 0, 0)); + else if (dungeonRoom.canAccessAbsolute(doorfinder.getPosition().add(-2, 0, 0))) + offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition().add(-2, 0, 0)); } if (offsetPoint == null) { offsetPoint = new OffsetPoint(dungeonRoom, doorfinder.getPosition()); @@ -57,24 +57,20 @@ public class DungeonRoomDoor implements DungeonMechanic { } @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { - if (!"navigate".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); - Set base; - Set preRequisites = base = new HashSet(); - { - ActionMove actionMove = new ActionMove(offsetPoint); - preRequisites.add(actionMove); - preRequisites = actionMove.getPreRequisite(); - } - return base; + public Set getAction(String state, DungeonRoom dungeonRoom) { + if (!"navigate".equalsIgnoreCase(state)) + throw new IllegalArgumentException(state + " is not valid state for secret"); + Set preRequisites = new HashSet<>(); + preRequisites.add(new ActionMove(offsetPoint)); + return preRequisites; } @Override public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { BlockPos pos = offsetPoint.getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, color,partialTicks); - RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0.75f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); - RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0.25f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.highlightBlock(pos, color, partialTicks); + RenderUtils.drawTextAtWorld(name, pos.getX() + 0.5f, pos.getY() + 0.75f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() + 0.5f, pos.getY() + 0.25f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java index 5914be15..d806b7c5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -19,52 +19,56 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonActionContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateBat; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.pathfinding.NodeProcessorDungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding.NodeProcessorDungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.AllArgsConstructor; import lombok.Data; import lombok.Getter; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; +import net.minecraft.entity.passive.EntityBat; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.BlockPos; import net.minecraft.util.Vec3; import java.awt.*; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; @Data public class DungeonSecret implements DungeonMechanic { private static final long serialVersionUID = 8784808599222706537L; - private OffsetPoint secretPoint = new OffsetPoint(0,0,0); + private OffsetPoint secretPoint = new OffsetPoint(0, 0, 0); private SecretType secretType = SecretType.CHEST; private List preRequisite = new ArrayList(); public void tick(DungeonRoom dungeonRoom) { if (secretType == SecretType.CHEST) { BlockPos pos = secretPoint.getBlockPos(dungeonRoom); - IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); + IBlockState blockState = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos); if (blockState.getBlock() == Blocks.chest || blockState.getBlock() == Blocks.trapped_chest) { TileEntityChest chest = (TileEntityChest) dungeonRoom.getContext().getWorld().getTileEntity(pos); if (chest.numPlayersUsing > 0) { - dungeonRoom.getRoomContext().put("c-"+pos.toString(), 2); + dungeonRoom.getRoomContext().put("c-" + pos.toString(), 2); } else { - dungeonRoom.getRoomContext().put("c-"+pos.toString(), 1); + dungeonRoom.getRoomContext().put("c-" + pos.toString(), 1); } } } else if (secretType == SecretType.ESSENCE) { BlockPos pos = secretPoint.getBlockPos(dungeonRoom); - IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); + IBlockState blockState = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos); if (blockState.getBlock() == Blocks.skull) { - dungeonRoom.getRoomContext().put("e-"+pos.toString(), true); + dungeonRoom.getRoomContext().put("e-" + pos.toString(), true); } } else if (secretType == SecretType.ITEM_DROP) { Vec3 pos = new Vec3(secretPoint.getBlockPos(dungeonRoom)); @@ -74,7 +78,7 @@ public class DungeonSecret implements DungeonMechanic { for (int i = 0; i < player.distanceTo(pos); i++) { Vec3 vec = player.addVector(vec3.xCoord * i, vec3.yCoord * i, vec3.zCoord * i); BlockPos bpos = new BlockPos(vec); - IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(bpos); + IBlockState blockState = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(bpos); if (!NodeProcessorDungeonRoom.isValidBlock(blockState)) return; } @@ -86,9 +90,9 @@ public class DungeonSecret implements DungeonMechanic { public SecretStatus getSecretStatus(DungeonRoom dungeonRoom) { if (secretType == SecretType.CHEST) { BlockPos pos = secretPoint.getBlockPos(dungeonRoom); - IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); - if (dungeonRoom.getRoomContext().containsKey("c-"+pos.toString())) - return ((int)dungeonRoom.getRoomContext().get("c-"+pos.toString()) == 2 || blockState.getBlock() == Blocks.air) ? SecretStatus.FOUND : SecretStatus.CREATED; + IBlockState blockState = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos); + if (dungeonRoom.getRoomContext().containsKey("c-" + pos.toString())) + return ((int) dungeonRoom.getRoomContext().get("c-" + pos.toString()) == 2 || blockState.getBlock() == Blocks.air) ? SecretStatus.FOUND : SecretStatus.CREATED; if (blockState.getBlock() == Blocks.air) { return SecretStatus.DEFINITELY_NOT; @@ -98,33 +102,33 @@ public class DungeonSecret implements DungeonMechanic { TileEntityChest chest = (TileEntityChest) dungeonRoom.getContext().getWorld().getTileEntity(pos); if (chest.numPlayersUsing > 0) { return SecretStatus.FOUND; - } else{ + } else { return SecretStatus.CREATED; } } } else if (secretType == SecretType.ESSENCE) { BlockPos pos = secretPoint.getBlockPos(dungeonRoom); - IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); + IBlockState blockState = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos); if (blockState.getBlock() == Blocks.skull) { - dungeonRoom.getRoomContext().put("e-"+pos.toString(), true); + dungeonRoom.getRoomContext().put("e-" + pos.toString(), true); return SecretStatus.DEFINITELY_NOT; } else { - if (dungeonRoom.getRoomContext().containsKey("e-"+pos.toString())) + if (dungeonRoom.getRoomContext().containsKey("e-" + pos.toString())) return SecretStatus.FOUND; return SecretStatus.NOT_SURE; } } else if (secretType == SecretType.BAT) { Vec3 spawn = new Vec3(secretPoint.getBlockPos(dungeonRoom)); - for (Integer killed : DungeonActionManager.getKilleds()) { - if (DungeonActionManager.getSpawnLocation().get(killed) == null) continue; - if (DungeonActionManager.getSpawnLocation().get(killed).squareDistanceTo(spawn) < 100) { + for (Integer killed : DungeonActionContext.getKilleds()) { + if (DungeonActionContext.getSpawnLocation().get(killed) == null) continue; + if (DungeonActionContext.getSpawnLocation().get(killed).squareDistanceTo(spawn) < 100) { return SecretStatus.FOUND; } } return SecretStatus.NOT_SURE; } else { Vec3 pos = new Vec3(secretPoint.getBlockPos(dungeonRoom)); - if (dungeonRoom.getRoomContext().containsKey("i-"+ pos)) + if (dungeonRoom.getRoomContext().containsKey("i-" + pos)) return SecretStatus.FOUND; Vec3 player = Minecraft.getMinecraft().thePlayer.getPositionVector(); if (player.squareDistanceTo(pos) < 16) { @@ -132,7 +136,7 @@ public class DungeonSecret implements DungeonMechanic { for (int i = 0; i < player.distanceTo(pos); i++) { Vec3 vec = player.addVector(vec3.xCoord * i, vec3.yCoord * i, vec3.zCoord * i); BlockPos bpos = new BlockPos(vec); - IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(bpos); + IBlockState blockState = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(bpos); if (!NodeProcessorDungeonRoom.isValidBlock(blockState)) return SecretStatus.NOT_SURE; } @@ -143,10 +147,10 @@ public class DungeonSecret implements DungeonMechanic { } @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (state.equalsIgnoreCase("navigate")) { - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint(dungeonRoom)); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); @@ -157,43 +161,43 @@ public class DungeonSecret implements DungeonMechanic { } return base; } - if (!"found".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); + if (!"found".equalsIgnoreCase(state)) + throw new IllegalArgumentException(state + " is not valid state for secret"); if (state.equals("found") && getSecretStatus(dungeonRoom) == SecretStatus.FOUND) return new HashSet<>(); - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet(); if (secretType == SecretType.CHEST || secretType == SecretType.ESSENCE) { ActionClick actionClick; preRequisites.add(actionClick = new ActionClick(secretPoint)); preRequisites = actionClick.getPreRequisite(); } else if (secretType == SecretType.BAT) { - ActionKill actionKill; - preRequisites.add(actionKill = new ActionKill(secretPoint)); - actionKill.setPredicate(PredicateBat.INSTANCE); + ActionKill actionKill = new ActionKill(secretPoint); + preRequisites.add(actionKill); + actionKill.setPredicate(EntityBat.class::isInstance); actionKill.setRadius(10); preRequisites = actionKill.getPreRequisite(); } - { - ActionMove actionMove = new ActionMove(secretPoint); - preRequisites.add(actionMove); - preRequisites = actionMove.getPreRequisite(); - } - { - for (String str : preRequisite) { - if (str.isEmpty()) continue; - ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); - preRequisites.add(actionChangeState); - } + + ActionMove actionMove = new ActionMove(secretPoint); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); } + return base; } @Override public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { BlockPos pos = getSecretPoint().getBlockPos(dungeonRoom); - RenderUtils.highlightBlock(pos, color,partialTicks); - RenderUtils.drawTextAtWorld(getSecretType().name(), pos.getX() +0.5f, pos.getY()+0.75f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); - RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0.375f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); - RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.highlightBlock(pos, color, partialTicks); + RenderUtils.drawTextAtWorld(getSecretType().name(), pos.getX() + 0.5f, pos.getY() + 0.75f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(name, pos.getX() + 0.5f, pos.getY() + 0.375f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() + 0.5f, pos.getY() + 0f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); } public enum SecretType { @@ -228,10 +232,12 @@ public class DungeonSecret implements DungeonMechanic { if (status == SecretStatus.FOUND) return Sets.newHashSet("navigate"); else return Sets.newHashSet("found", "navigate"); } + @Override public Set getTotalPossibleStates(DungeonRoom dungeonRoom) { return Sets.newHashSet("found"/*, "definitely_not", "not_sure", "created", "error"*/); } + @Override public OffsetPoint getRepresentingPoint(DungeonRoom dungeonRoom) { return secretPoint; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java index 24bc0d84..b14ffaf3 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java @@ -19,11 +19,13 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.RouteBlocker; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; import lombok.Data; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -37,14 +39,14 @@ import java.util.List; public class DungeonTomb implements DungeonMechanic, RouteBlocker { private static final long serialVersionUID = -7347076019472222115L; private OffsetPointSet secretPoint = new OffsetPointSet(); - private List preRequisite = new ArrayList(); + private List preRequisite = new ArrayList<>(); @Override - public Set getAction(String state, DungeonRoom dungeonRoom) { + public Set getAction(String state, DungeonRoom dungeonRoom) { if (state.equalsIgnoreCase("navigate")) { - Set base; - Set preRequisites = base = new HashSet(); + Set base; + Set preRequisites = base = new HashSet<>(); ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint(dungeonRoom)); preRequisites.add(actionMove); preRequisites = actionMove.getPreRequisite(); @@ -55,29 +57,28 @@ public class DungeonTomb implements DungeonMechanic, RouteBlocker { } return base; } - if (!"open".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for tomb"); + if (!"open".equalsIgnoreCase(state)) { + throw new IllegalArgumentException(state + " is not valid state for tomb"); + } if (!isBlocking(dungeonRoom)) { return Collections.emptySet(); } - Set base; - Set preRequisites = base = new HashSet(); - { - ActionBreakWithSuperBoom actionClick; - preRequisites.add(actionClick = new ActionBreakWithSuperBoom(secretPoint.getOffsetPointList().get(0))); - preRequisites = actionClick.getPreRequisite(); - } - { - ActionMoveNearestAir actionMove = new ActionMoveNearestAir(secretPoint.getOffsetPointList().get(0)); - preRequisites.add(actionMove); - preRequisites = actionMove.getPreRequisite(); - } - { - for (String str : preRequisite) { - if (str.isEmpty()) continue; - ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); - preRequisites.add(actionChangeState); - } + Set base; + Set preRequisites = base = new HashSet<>(); + + ActionBreakWithSuperBoom actionClick = new ActionBreakWithSuperBoom(secretPoint.getOffsetPointList().get(0)); + preRequisites.add(actionClick); + preRequisites = actionClick.getPreRequisite(); + + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(secretPoint.getOffsetPointList().get(0)); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); } + return base; } @@ -86,11 +87,11 @@ public class DungeonTomb implements DungeonMechanic, RouteBlocker { if (secretPoint.getOffsetPointList().isEmpty()) return; OffsetPoint firstpt = secretPoint.getOffsetPointList().get(0); BlockPos pos = firstpt.getBlockPos(dungeonRoom); - RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0.75f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); - RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0.25f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(name, pos.getX() + 0.5f, pos.getY() + 0.75f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() + 0.5f, pos.getY() + 0.25f, pos.getZ() + 0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { - RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), color,partialTicks); + RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), color, partialTicks); } } @@ -105,7 +106,7 @@ public class DungeonTomb implements DungeonMechanic, RouteBlocker { public DungeonTomb clone() throws CloneNotSupportedException { DungeonTomb dungeonSecret = new DungeonTomb(); dungeonSecret.secretPoint = (OffsetPointSet) secretPoint.clone(); - dungeonSecret.preRequisite = new ArrayList(preRequisite); + dungeonSecret.preRequisite = new ArrayList<>(preRequisite); return dungeonSecret; } @@ -114,13 +115,14 @@ public class DungeonTomb implements DungeonMechanic, RouteBlocker { Block b = Blocks.air; if (!secretPoint.getOffsetPointList().isEmpty()) b = secretPoint.getOffsetPointList().get(0).getBlock(dungeonRoom); - return b == Blocks.air ?"open" :"closed"; + return b == Blocks.air ? "open" : "closed"; } @Override public Set getPossibleStates(DungeonRoom dungeonRoom) { return isBlocking(dungeonRoom) ? Sets.newHashSet("open", "navigate") : Sets.newHashSet("navigate"); } + @Override public Set getTotalPossibleStates(DungeonRoom dungeonRoom) { return Sets.newHashSet("open", "closed"); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/RouteBlocker.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/RouteBlocker.java deleted file mode 100755 index 391bda2e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/RouteBlocker.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.mechanics; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; - -public interface RouteBlocker { - boolean isBlocking(DungeonRoom dungeonRoom); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/dunegonmechanic/DungeonMechanic.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/dunegonmechanic/DungeonMechanic.java new file mode 100755 index 00000000..9aa18701 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/dunegonmechanic/DungeonMechanic.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; + +import java.awt.*; +import java.io.Serializable; +import java.util.Set; + +public interface DungeonMechanic extends Serializable { + Set getAction(String state, DungeonRoom dungeonRoom); + + void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks); + + String getCurrentState(DungeonRoom dungeonRoom); + + Set getPossibleStates(DungeonRoom dungeonRoom); + Set getTotalPossibleStates(DungeonRoom dungeonRoom); + + OffsetPoint getRepresentingPoint(DungeonRoom dungeonRoom); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/dunegonmechanic/RouteBlocker.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/dunegonmechanic/RouteBlocker.java new file mode 100755 index 00000000..faad723a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/dunegonmechanic/RouteBlocker.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; + +public interface RouteBlocker { + boolean isBlocking(DungeonRoom dungeonRoom); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateArmorStand.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateArmorStand.java index 79b20725..8da45b89 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateArmorStand.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateArmorStand.java @@ -21,7 +21,6 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates; import com.google.common.base.Predicate; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.passive.EntityBat; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java deleted file mode 100755 index 2419f50a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.roomfinder; - -import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.MapProcessor; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.EDungeonDoorType; -import kr.syeyoung.dungeonsguide.dungeon.events.DungeonStateChangeEvent; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonRoomDoor; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.secret.FeaturePathfindStrategy; -import kr.syeyoung.dungeonsguide.pathfinding.*; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.pathfinding.PathEntity; -import net.minecraft.pathfinding.PathFinder; -import net.minecraft.pathfinding.PathPoint; -import net.minecraft.util.*; -import net.minecraft.world.ChunkCache; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import javax.vecmath.Vector2d; -import java.awt.*; -import java.util.*; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -@Getter -public class DungeonRoom { - private final List unitPoints; - private final short shape; - private final byte color; - - private final BlockPos min; - private final BlockPos max; - private final Point minRoomPt; - - private final DungeonContext context; - - private final List doors = new ArrayList(); - - private DungeonRoomInfo dungeonRoomInfo; - - private final int unitWidth; // X - private final int unitHeight; // Z - - @Setter - private int totalSecrets = -1; - private RoomState currentState = RoomState.DISCOVERED; - - private Map cached = null; - - @Getter - private World cachedWorld; - public Map getMechanics() { - if (cached == null || EditingContext.getEditingContext() != null) { - cached = new HashMap(dungeonRoomInfo.getMechanics()); - int index = 0; - for (DungeonDoor door : doors) { - if (door.getType().isExist()) cached.put((door.getType().getName())+"-"+(++index), new DungeonRoomDoor(this, door)); - } - } - return cached; - } - - public void setCurrentState(RoomState currentState) { - context.createEvent(new DungeonStateChangeEvent(unitPoints.get(0), dungeonRoomInfo.getName(), this.currentState, currentState)); - this.currentState = currentState; - } - - private Map activeBetterAStar = new HashMap<>(); - private Map activeBetterAStarCornerCut = new HashMap<>(); - private Map activeThetaStar = new HashMap<>(); - - public ScheduledFuture> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist, int timeout) { - FeaturePathfindStrategy.PathfindStrategy pathfindStrategy = FeatureRegistry.SECRET_PATHFIND_STRATEGY.getPathfindStrat(); - if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.JPS_LEGACY) { - ScheduledFuture> sf = asyncPathFinder.schedule(() -> { - BlockPos min = new BlockPos(getMin().getX(), 0, getMin().getZ()); - BlockPos max= new BlockPos(getMax().getX(), 255, getMax().getZ()); - JPSPathfinder pathFinder = new JPSPathfinder(this); - pathFinder.pathfind(entityIn.getPositionVector(), new Vec3(targetPos).addVector(0.5, 0.5, 0.5), 1.5f,timeout); - return pathFinder.getRoute(); - }, 0, TimeUnit.MILLISECONDS); - return sf; - } else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.A_STAR_FINE_GRID) { - ScheduledFuture> sf = asyncPathFinder.schedule(() -> { - AStarFineGrid pathFinder = - activeBetterAStar.computeIfAbsent(targetPos, (pos) -> new AStarFineGrid(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5))); - pathFinder.pathfind(entityIn.getPositionVector(),timeout); - return pathFinder.getRoute(); - }, 0, TimeUnit.MILLISECONDS); - return sf; - }else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.A_STAR_DIAGONAL) { - ScheduledFuture> sf = asyncPathFinder.schedule(() -> { - AStarCornerCut pathFinder = - activeBetterAStarCornerCut.computeIfAbsent(targetPos, (pos) -> new AStarCornerCut(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5))); - pathFinder.pathfind(entityIn.getPositionVector(),timeout); - return pathFinder.getRoute(); - }, 0, TimeUnit.MILLISECONDS); - return sf; - } else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.THETA_STAR) { - ScheduledFuture> sf = asyncPathFinder.schedule(() -> { - ThetaStar pathFinder = - activeThetaStar.computeIfAbsent(targetPos, (pos) -> new ThetaStar(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5))); - pathFinder.pathfind(entityIn.getPositionVector(),timeout); - return pathFinder.getRoute(); - }, 0, TimeUnit.MILLISECONDS); - return sf; - } else { - ScheduledFuture> sf = asyncPathFinder.schedule(() -> { - PathFinder pathFinder = new PathFinder(nodeProcessorDungeonRoom); - PathEntity latest = pathFinder.createEntityPathTo(blockaccess, entityIn, targetPos, dist); - if (latest != null) { - List poses = new ArrayList<>(); - for (int i = 0; i < latest.getCurrentPathLength(); i++) { - PathPoint pathPoint = latest.getPathPointFromIndex(i); - poses.add(new Vec3(getMin().add(pathPoint.xCoord, pathPoint.yCoord, pathPoint.zCoord)).addVector(0.5,0.5,0.5)); - } - return poses; - } - return new ArrayList<>(); - }, 0, TimeUnit.MILLISECONDS); - return sf; - } - } - - private static final ScheduledExecutorService asyncPathFinder = Executors.newScheduledThreadPool(4); - @Getter - private final NodeProcessorDungeonRoom nodeProcessorDungeonRoom; - - @Getter - private final Map roomContext = new HashMap(); - - @AllArgsConstructor - @Getter - public enum RoomState { - DISCOVERED(0), COMPLETE_WITHOUT_SECRETS(0), FINISHED(0), FAILED(-14); - private final int scoreModifier; - } - - private RoomProcessor roomProcessor; - - public DungeonRoom(List points, short shape, byte color, BlockPos min, BlockPos max, DungeonContext context, Set> doorsAndStates) { - this.unitPoints = points; - this.shape = shape; - this.color = color; - this.min = min; - this.max = max; - this.context = context; - - minRoomPt = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); - for (Point pt : unitPoints) { - if (pt.x < minRoomPt.x) minRoomPt.x = pt.x; - if (pt.y < minRoomPt.y) minRoomPt.y = pt.y; - } - unitWidth = (int) Math.ceil(max.getX() - min.getX() / 32.0); - unitHeight = (int) Math.ceil(max.getZ() - min.getZ() / 32.0); - - - ChunkCache chunkCache = new ChunkCache(getContext().getWorld(), min.add(-3, 0, -3), max.add(3,0,3), 0); - this.cachedWorld = new CachedWorld(chunkCache); - - - - minx = min.getX() * 2; miny = 0; minz = min.getZ() * 2; - maxx = max.getX() * 2 + 2; maxy = 255 * 2 + 2; maxz = max.getZ() * 2 + 2; - - lenx = maxx - minx; - leny = maxy - miny; - lenz = maxz - minz; - arr = new long[lenx *leny * lenz * 2 / 8];; - - buildDoors(doorsAndStates); - buildRoom(); - nodeProcessorDungeonRoom = new NodeProcessorDungeonRoom(this); - updateRoomProcessor(); - - - } - - private static final Set directions = Sets.newHashSet(new Vector2d(0,16), new Vector2d(0, -16), new Vector2d(16, 0), new Vector2d(-16 , 0)); - - private void buildDoors(Set> doorsAndStates) { - Set> positions = new HashSet<>(); - BlockPos pos = context.getMapProcessor().roomPointToWorldPoint(minRoomPt).add(16,0,16); - for (Tuple doorsAndState : doorsAndStates) { - Vector2d vector2d = doorsAndState.getFirst(); - BlockPos neu = pos.add(vector2d.x * 32, 0, vector2d.y * 32); - positions.add(new Tuple<>(neu, doorsAndState.getSecond())); - } - - for (Tuple door : positions) { - doors.add(new DungeonDoor(context.getWorld(), door.getFirst(), door.getSecond())); - } - } - - private RoomMatcher roomMatcher = null; - private void buildRoom() { - if (roomMatcher == null) - roomMatcher = new RoomMatcher(this); - DungeonRoomInfo dungeonRoomInfo = roomMatcher.match(); - if (dungeonRoomInfo == null) { - dungeonRoomInfo = roomMatcher.createNew(); - if (color == 18) dungeonRoomInfo.setProcessorId("bossroom"); - } - this.dungeonRoomInfo = dungeonRoomInfo; - totalSecrets = dungeonRoomInfo.getTotalSecrets(); - } - - public void updateRoomProcessor() { - RoomProcessorGenerator roomProcessorGenerator = ProcessorFactory.getRoomProcessorGenerator(dungeonRoomInfo.getProcessorId()); - if (roomProcessorGenerator == null) this.roomProcessor = null; - else this.roomProcessor = roomProcessorGenerator.createNew(this); - } - - public Block getAbsoluteBlockAt(int x, int y, int z) { - // validate x y z's - BlockPos pos = new BlockPos(x,y,z); - if (canAccessAbsolute(pos)) { - return cachedWorld.getBlockState(pos).getBlock(); - } - return null; - } - - public Block getRelativeBlockAt(int x, int y, int z) { - // validate x y z's - if (canAccessRelative(x,z)) { - BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ()); - return cachedWorld.getBlockState(pos).getBlock(); - } - return null; - } - - public BlockPos getRelativeBlockPosAt(int x, int y, int z) { - BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ()); - return pos; - } - - public int getRelativeBlockDataAt(int x, int y, int z) { - // validate x y z's - if (canAccessRelative(x,z)) { - BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ()); - IBlockState iBlockState = cachedWorld.getBlockState(pos); - return iBlockState.getBlock().getMetaFromState(iBlockState); - } - return -1; - } - - public int getAbsoluteBlockDataAt(int x, int y, int z) { - // validate x y z's - BlockPos pos = new BlockPos(x,y,z); - if (canAccessAbsolute(pos)) { - IBlockState iBlockState = cachedWorld.getBlockState(pos); - return iBlockState.getBlock().getMetaFromState(iBlockState); - } - return -1; - } - - public boolean canAccessAbsolute(BlockPos pos) { - MapProcessor mapProcessor = this.context.getMapProcessor(); - Point roomPt = mapProcessor.worldPointToRoomPoint(pos); - roomPt.translate(-minRoomPt.x, -minRoomPt.y); - - return (shape >>(roomPt.y *4 +roomPt.x) & 0x1) > 0; - } - public boolean canAccessRelative(int x, int z) { - return x>= 0 && z >= 0 && (shape >>((z/32) *4 +(x/32)) & 0x1) > 0; - } - - - - long arr[]; - // These values are doubled - private final int minx, miny, minz, maxx, maxy, maxz; - private final int lenx, leny, lenz; - private static final float playerWidth = 0.3f; - public boolean isBlocked(int x,int y, int z) { - if (x < minx || z < minz || x >= maxx || z >= maxz || y < miny || y >= maxy) return true; - int dx = x - minx, dy = y - miny, dz = z - minz; - int bitIdx = dx * leny * lenz + dy * lenz + dz; - int location = bitIdx / 4; - int bitStart = (2 * (bitIdx % 4)); - long theBit = arr[location]; - if (((theBit >> bitStart) & 0x2) > 0) return ((theBit >> bitStart) & 1) > 0; - float wX = x / 2.0f, wY = y / 2.0f, wZ = z / 2.0f; - - - AxisAlignedBB bb = AxisAlignedBB.fromBounds(wX - playerWidth, wY, wZ - playerWidth, wX + playerWidth, wY + 1.9f, wZ + playerWidth); - - int i = MathHelper.floor_double(bb.minX); - int j = MathHelper.floor_double(bb.maxX + 1.0D); - int k = MathHelper.floor_double(bb.minY); - int l = MathHelper.floor_double(bb.maxY + 1.0D); - int i1 = MathHelper.floor_double(bb.minZ); - int j1 = MathHelper.floor_double(bb.maxZ + 1.0D); - BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); - - List list = new ArrayList<>(); - for (int k1 = i; k1 < j; ++k1) { - for (int l1 = i1; l1 < j1; ++l1) { - for (int i2 = k - 1; i2 < l; ++i2) { - blockPos.set(k1, i2, l1); - IBlockState iblockstate1 = cachedWorld.getBlockState(blockPos); - Block b = iblockstate1.getBlock(); - if (!b.getMaterial().blocksMovement())continue; - if (b.isFullCube() && i2 == k-1) continue; - if (iblockstate1.equals( NodeProcessorDungeonRoom.preBuilt)) continue; - if (b.isFullCube()) { - theBit |= (3L << bitStart); - arr[location] = theBit; - return true; - } - try { - b.addCollisionBoxesToList(cachedWorld, blockPos, iblockstate1, bb, list, null); - } catch (Exception e) { - return true; - } - if (list.size() > 0) { - theBit |= (3L << bitStart); - arr[location] = theBit; - return true; - } - } - } - } - theBit |= 2L << bitStart; - arr[location] = theBit; - return false; - } - - - public void resetBlock(BlockPos pos) { - for (int x = -1; x <= 1; x++) { - for (int y = -1; y <= 1; y++) { - for (int z = -1; z <= 1; z++) { - resetBlock(pos.getX()*2 + x, pos.getY()*2 + y, pos.getZ()*2 + z); - } - } - } - } - private void resetBlock(int x, int y, int z) { - if (x < minx || z < minz || x >= maxx || z >= maxz || y < miny || y >= maxy) return; - int dx = x - minx, dy = y - miny, dz = z - minz; - int bitIdx = dx * leny * lenz + dy * lenz + dz; - int location = bitIdx / 4; - arr[location] = 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java deleted file mode 100755 index e336ae21..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.roomfinder; - -import com.google.common.io.Files; -import kr.syeyoung.dungeonsguide.Main; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import org.apache.commons.io.IOUtils; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import java.io.*; -import java.net.URL; -import java.nio.charset.Charset; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.*; - -public class DungeonRoomInfoRegistry { - @Getter - private static final List registered = new ArrayList(); - private static final Map> shapeMap = new HashMap>(); - private static final Map uuidMap = new HashMap(); - - public static void register(DungeonRoomInfo dungeonRoomInfo) { - if (dungeonRoomInfo == null) throw new NullPointerException("what the fak parameter is noll?"); - if (uuidMap.containsKey(dungeonRoomInfo.getUuid())) { - DungeonRoomInfo dri1 = uuidMap.get(dungeonRoomInfo.getUuid()); - registered.remove(dri1); - shapeMap.get(dri1.getShape()).remove(dri1); - uuidMap.remove(dri1.getUuid()); - } - dungeonRoomInfo.setRegistered(true); - registered.add(dungeonRoomInfo); - uuidMap.put(dungeonRoomInfo.getUuid(), dungeonRoomInfo); - List roomInfos = shapeMap.get(dungeonRoomInfo.getShape()); - if (roomInfos == null) roomInfos = new ArrayList(); - roomInfos.add(dungeonRoomInfo); - shapeMap.put(dungeonRoomInfo.getShape(), roomInfos); - } - - - public static List getByShape(Short shape) { - List dungeonRoomInfos = shapeMap.get(shape); - return dungeonRoomInfos == null ? Collections.emptyList() : dungeonRoomInfos; - } - - public static DungeonRoomInfo getByUUID(UUID uid) { - return uuidMap.get(uid); - } - - public static void unregister(DungeonRoomInfo dungeonRoomInfo) { - if (!dungeonRoomInfo.isRegistered()) throw new IllegalStateException("what tha fak? that is not registered one"); - if (!uuidMap.containsKey(dungeonRoomInfo.getUuid())) throw new IllegalStateException("what tha fak? that is not registered one, but you desperately wanted to trick this program"); - dungeonRoomInfo.setRegistered(false); - registered.remove(dungeonRoomInfo); - shapeMap.get(dungeonRoomInfo.getShape()).remove(dungeonRoomInfo); - uuidMap.remove(dungeonRoomInfo.getUuid()); - } - - public static void saveAll(File dir) { - dir.mkdirs(); - boolean isDev = Minecraft.getMinecraft().getSession().getPlayerID().replace("-","").equals("e686fe0aab804a71ac7011dc8c2b534c"); - String nameidstring = "name,uuid,processsor,secrets"; - String ids = ""; - for (DungeonRoomInfo dungeonRoomInfo : registered) { - try { - if (!dungeonRoomInfo.isUserMade() && !isDev) continue; - FileOutputStream fos = new FileOutputStream(new File(dir, dungeonRoomInfo.getUuid().toString() + ".roomdata")); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(dungeonRoomInfo); - oos.flush(); - oos.close(); - - nameidstring += "\n"+dungeonRoomInfo.getName()+","+dungeonRoomInfo.getUuid() +","+dungeonRoomInfo.getProcessorId()+","+dungeonRoomInfo.getTotalSecrets(); - ids += "roomdata/"+dungeonRoomInfo.getUuid() +".roomdata\n"; - } catch (Exception e) {e.printStackTrace();} - } - - try { - Files.write(nameidstring, new File(dir, "roomidmapping.csv"), Charset.defaultCharset()); - Files.write(ids, new File(dir, "datas.txt"), Charset.defaultCharset()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void loadAll(File dir) throws BadPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException { - registered.clear(); - shapeMap.clear(); - uuidMap.clear(); - try { - List lines = IOUtils.readLines(Main.class.getResourceAsStream("/roomdata/datas.txt")); - for (String name : lines) { - if (!name.endsWith(".roomdata")) continue; - try { - InputStream fis = Main.class.getResourceAsStream("/"+name); - ObjectInputStream ois = new ObjectInputStream(fis); - DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); - ois.close(); - fis.close(); - register(dri); - } catch (Exception e) { - System.out.println(name); - e.printStackTrace(); - } - } - } catch (Exception e) {e.printStackTrace();} - for (File f : dir.listFiles()) { - if (!f.getName().endsWith(".roomdata")) continue; - try { - InputStream fis = new FileInputStream(f); - ObjectInputStream ois = new ObjectInputStream(fis); - DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); - ois.close(); - fis.close(); - register(dri); - } catch (Exception e) { - System.out.println(f.getName());e.printStackTrace();} - } - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java deleted file mode 100755 index 9052ba3e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/RoomMatcher.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.dungeon.roomfinder; - -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import kr.syeyoung.dungeonsguide.utils.ArrayUtils; -import kr.syeyoung.dungeonsguide.utils.ShortUtils; -import lombok.Getter; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -import java.util.List; - -public class RoomMatcher { - private final DungeonRoom dungeonRoom; - - @Getter - private DungeonRoomInfo match; - @Getter - private int rotation; // how much the "found room" has to rotate clockwise to match the given dungeon room info. ! - private boolean triedMatch = false; - - private final World w; - - public RoomMatcher(DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - w = dungeonRoom.getContext().getWorld(); - } - - public DungeonRoomInfo match() { - if (triedMatch) return match; - - int zz = dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 1; - int xx = dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 1; - for (int z = 0; z < zz; z ++) { - for (int x = 0; x < xx; x++) { - if (x % 8 == 0 && z % 8 == 0 && dungeonRoom.getContext().getWorld().getChunkFromBlockCoords(dungeonRoom.getRelativeBlockPosAt(x, 0, z)).isEmpty()) { - throw new IllegalStateException("chunk is not loaded"); - - } - } - } - - triedMatch = true; - int lowestcost = 10; - int lowestRot = 0; - DungeonRoomInfo bestMatch = null; - for (int rotation = 0; rotation < 4; rotation++) { - short shape = dungeonRoom.getShape(); - for (int j = 0; j roomInfoList = DungeonRoomInfoRegistry.getByShape(shape); - for (DungeonRoomInfo roomInfo : roomInfoList) { - int cost = tryMatching(roomInfo, rotation); - if (cost == 0) { - match = roomInfo; - this.rotation = rotation; - return match; - } - if (cost < lowestcost) { - lowestcost = cost; - bestMatch = roomInfo; - lowestRot = rotation; - } - } - } - match = bestMatch; - this.rotation = lowestRot; - return bestMatch; - } - - private int tryMatching(DungeonRoomInfo dungeonRoomInfo, int rotation) { - if (dungeonRoomInfo.getColor() != dungeonRoom.getColor()) return Integer.MAX_VALUE; - - int[][] res = dungeonRoomInfo.getBlocks(); - for (int i = 0; i < rotation; i++) - res = ArrayUtils.rotateCounterClockwise(res); - - int wrongs = 0; - for (int z = 0; z < res.length; z ++) { - for (int x = 0; x < res[0].length; x++) { - int data = res[z][x]; - if (data == -1) continue; - Block b = dungeonRoom.getRelativeBlockAt(x,0,z); - - if (b == null || Block.getIdFromBlock(b) != data) { - wrongs++; - - if (wrongs > 10) return wrongs; - } - } - } - return wrongs; - } - - private static final int offset = 3; - public DungeonRoomInfo createNew() { - DungeonRoomInfo roomInfo = new DungeonRoomInfo(dungeonRoom.getShape(), dungeonRoom.getColor()); - - int maxX = dungeonRoom.getMax().getX(); - int maxZ = dungeonRoom.getMax().getZ(); - int minX = dungeonRoom.getMin().getX(); - int minZ = dungeonRoom.getMin().getZ(); - int widthX = maxX - minX + 2; - int heightZ = maxZ - minZ + 2; - int[][] data = new int[dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() +2][dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 2]; - - for (int z = 0; z < data.length; z++) { - for (int x = 0; x < data[0].length; x++) { -// if (!(offset < x && widthX - offset > x && offset < z && heightZ - offset > z)) { -// data[z][x] = -1; -// continue; -// } - if (!(dungeonRoom.canAccessRelative(x + offset, z + offset) - && dungeonRoom.canAccessRelative(x - offset -1 , z - offset-1) - && dungeonRoom.canAccessRelative(x + offset , z - offset-1) - && dungeonRoom.canAccessRelative(x - offset -1 , z + offset))) { - data[z][x] = -1; - continue; - } - - Block b = dungeonRoom.getRelativeBlockAt(x,0,z); - if (b == null || b == Blocks.chest || b == Blocks.trapped_chest) { - data[z][x] = -1; - } else { - data[z][x] = Block.getIdFromBlock(b); - } - } - } - - roomInfo.setBlocks(data); - roomInfo.setUserMade(true); - return roomInfo; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java deleted file mode 100755 index 7997aec4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.eventlistener; - -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.*; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; -import kr.syeyoung.dungeonsguide.utils.MapUtils; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiErrorScreen; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.Vec3; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.InputEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.relauncher.Side; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -public class DungeonListener { - @SubscribeEvent - public void onWorldLoad(WorldEvent.Unload event) { - try { - Config.saveConfig(); - } catch (IOException e) { - e.printStackTrace(); - } - DungeonActionManager.getSpawnLocation().clear(); - DungeonActionManager.getKilleds().clear(); - } - - @SubscribeEvent - public void onPostDraw(GuiScreenEvent.DrawScreenEvent.Post e) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - if (!skyblockStatus.isOnDungeon()) return; - - if (skyblockStatus.getContext() != null) { - DungeonContext context = skyblockStatus.getContext(); - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - if (thePlayer == null) return; - if (context.getBossfightProcessor() != null) context.getBossfightProcessor().onPostGuiRender(e); - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null && dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().onPostGuiRender(e); - } - } - GlStateManager.enableBlend(); - GlStateManager.color(1,1,1,1); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.enableAlpha(); - } catch (Throwable e2) {e2.printStackTrace(); Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcDG HAS RAN INTO ERROR WHILE RENDERING SCREEN! Please report to support channel"));} - } - @SubscribeEvent - public void onEntityUpdate(LivingEvent.LivingUpdateEvent e) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - if (!skyblockStatus.isOnDungeon()) return; - - if (skyblockStatus.getContext() != null) { - DungeonContext context = skyblockStatus.getContext(); - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - if (thePlayer == null) return; - if (context.getBossfightProcessor() != null) context.getBossfightProcessor().onEntityUpdate(e); - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null && dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().onEntityUpdate(e); - } - } - } catch (Throwable e2) {e2.printStackTrace();} - } - - boolean wasOnHypixel = false; - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent ev) throws Throwable { - try { - if (ev.side == Side.SERVER) return; - if (ev.phase == TickEvent.Phase.START) { - - - - - - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - { - boolean isOnDungeon = skyblockStatus.isOnDungeon(); - boolean isOnSkyblock = skyblockStatus.isOnSkyblock(); - skyblockStatus.updateStatus(); - - if (!wasOnHypixel && skyblockStatus.isOnHypixel()) { - MinecraftForge.EVENT_BUS.post(new HypixelJoinedEvent()); - } - wasOnHypixel = skyblockStatus.isOnHypixel(); - - if (isOnSkyblock && !skyblockStatus.isOnSkyblock()) { - MinecraftForge.EVENT_BUS.post(new SkyblockLeftEvent()); - } else if (!isOnSkyblock && skyblockStatus.isOnSkyblock()) { - MinecraftForge.EVENT_BUS.post(new SkyblockJoinedEvent()); - } - - if ((isOnDungeon && !skyblockStatus.isOnDungeon())) { - MinecraftForge.EVENT_BUS.post(new DungeonLeftEvent()); - skyblockStatus.setContext(null); - if (!FeatureRegistry.ADVANCED_DEBUGGABLE_MAP.isEnabled()) - MapUtils.clearMap(); - return; - } - if (isOnSkyblock) { - if (skyblockStatus.getContext() != null) { - skyblockStatus.getContext().tick(); - } else if (skyblockStatus.isOnDungeon()){ - skyblockStatus.setContext(new DungeonContext(Minecraft.getMinecraft().thePlayer.worldObj)); - MinecraftForge.EVENT_BUS.post(new DungeonStartedEvent()); - } - } - } - - if (!skyblockStatus.isOnDungeon()) return; - - if (skyblockStatus.getContext() != null) { - DungeonContext context = skyblockStatus.getContext(); - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - if (thePlayer == null) return; - if (context.getBossfightProcessor() != null) context.getBossfightProcessor().tick(); - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null && dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().tick(); - } - } - } - } catch (Throwable e2) { - if (e2 instanceof CustomModLoadingErrorDisplayException) throw e2; - e2.printStackTrace(); - } - } - - - @SubscribeEvent - public void onHypixelJoin(HypixelJoinedEvent skyblockJoinedEvent) { - if (DungeonsGuide.getDungeonsGuide().isFirstTimeUsingDG()) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfThank you for installing DungeonsGuide, the most intelligent skyblock dungeon mod!")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfThe gui for relocating GUI Elements and enabling or disabling features can be opened by typing ยงe/dg")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfType ยงe/dg help ยงfto view full list of commands offered by dungeons guide!")); - } - } - - @SubscribeEvent - public void onRender(RenderGameOverlayEvent.Post postRender) { - try { - if (!(postRender.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || postRender.type == RenderGameOverlayEvent.ElementType.JUMPBAR)) return; - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - - if (skyblockStatus.getContext() != null) { - DungeonContext context = skyblockStatus.getContext(); - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - if (context.getBossfightProcessor() != null) context.getBossfightProcessor().drawScreen(postRender.partialTicks); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().drawScreen(postRender.partialTicks); - } - } - - } - GlStateManager.enableBlend(); - GlStateManager.color(1,1,1,1); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - Minecraft.getMinecraft().entityRenderer.setupOverlayRendering(); - GlStateManager.enableAlpha(); - } catch (Throwable e) { - e.printStackTrace();Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcDG HAS RAN INTO ERROR WHILE RENDERING SCREEN! Please report to support channel")); - } - } - - @SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGHEST) - public void onChatReceived(ClientChatReceivedEvent clientChatReceivedEvent) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - - if (clientChatReceivedEvent.type != 2 && clientChatReceivedEvent.message.getFormattedText().contains("ยง6> ยงeยงlEXTRA STATS ยง6<")) { - MinecraftForge.EVENT_BUS.post(new DungeonEndedEvent()); - } - - DungeonContext context = skyblockStatus.getContext(); - - if (skyblockStatus.getContext() != null) { - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - try { - context.onChat(clientChatReceivedEvent); - } catch (Throwable t) { - t.printStackTrace(); - } - - if (context.getBossfightProcessor() != null) { - if (clientChatReceivedEvent.type == 2) - context.getBossfightProcessor().actionbarReceived(clientChatReceivedEvent.message); - else - context.getBossfightProcessor().chatReceived(clientChatReceivedEvent.message); - } - RoomProcessor roomProcessor = null; - try { - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - if (clientChatReceivedEvent.type == 2) { - dungeonRoom.getRoomProcessor().actionbarReceived(clientChatReceivedEvent.message); - roomProcessor = dungeonRoom.getRoomProcessor(); - } else { - dungeonRoom.getRoomProcessor().chatReceived(clientChatReceivedEvent.message); - roomProcessor = dungeonRoom.getRoomProcessor(); - } - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - if (clientChatReceivedEvent.type == 2) return; - for (RoomProcessor globalRoomProcessor : context.getGlobalRoomProcessors()) { - if (globalRoomProcessor == roomProcessor) continue; - try { - globalRoomProcessor.chatReceived(clientChatReceivedEvent.message); - } catch (Throwable t) { - t.printStackTrace(); - } - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - - - @SubscribeEvent - public void onWorldRender(RenderWorldLastEvent renderWorldLastEvent) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return; - if (FeatureRegistry.DEBUG.isEnabled()) { - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - for(DungeonDoor door : dungeonRoom.getDoors()) { - RenderUtils.renderDoor(door, renderWorldLastEvent.partialTicks); - } - } - } - - - if (skyblockStatus.getContext() != null) { - - if (context.getBossfightProcessor() != null) { - context.getBossfightProcessor().drawWorld(renderWorldLastEvent.partialTicks); - } - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().drawWorld(renderWorldLastEvent.partialTicks); - } - } - - if (FeatureRegistry.DEBUG.isEnabled() && dungeonRoom !=null) { - - Vec3 player = Minecraft.getMinecraft().thePlayer.getPositionVector(); - BlockPos real = new BlockPos(player.xCoord * 2, player.yCoord * 2, player.zCoord * 2); - for (BlockPos allInBox : BlockPos.getAllInBox(real.add(-1, -1, -1), real.add(1, 1, 1))) { - boolean blocked = dungeonRoom.isBlocked(allInBox.getX(), allInBox.getY(), allInBox.getZ()); - - RenderUtils.highlightBox( - AxisAlignedBB.fromBounds( - allInBox.getX() / 2.0 - 0.1, allInBox.getY() / 2.0 - 0.1, allInBox.getZ() / 2.0 - 0.1, - allInBox.getX() / 2.0 + 0.1, allInBox.getY() / 2.0 + 0.1, allInBox.getZ() / 2.0 + 0.1 - ), blocked ? new Color(0x55FF0000, true) : new Color(0x3300FF00, true), renderWorldLastEvent.partialTicks, false); - - } - } - - } - - if (EditingContext.getEditingContext() != null) { - GuiScreen guiScreen = EditingContext.getEditingContext().getCurrent(); - if (guiScreen instanceof GuiDungeonParameterEdit) { - ValueEdit valueEdit = ((GuiDungeonParameterEdit) guiScreen).getValueEdit(); - if (valueEdit != null) { - valueEdit.renderWorld(renderWorldLastEvent.partialTicks); - } - } else if (guiScreen instanceof GuiDungeonValueEdit) { - ValueEdit valueEdit = ((GuiDungeonValueEdit) guiScreen).getValueEdit(); - if (valueEdit != null) { - valueEdit.renderWorld(renderWorldLastEvent.partialTicks); - } - } else if (guiScreen instanceof GuiDungeonAddSet) { - ((GuiDungeonAddSet) guiScreen).onWorldRender(renderWorldLastEvent.partialTicks); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - @SubscribeEvent() - public void onKey2(KeyBindPressedEvent keyInputEvent) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - - DungeonContext context = skyblockStatus.getContext(); - - if (skyblockStatus.getContext() != null) { - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - if (context.getBossfightProcessor() != null) { - context.getBossfightProcessor().onKeybindPress(keyInputEvent); - } - RoomProcessor roomProcessor = null; - try { - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().onKeybindPress(keyInputEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - @SubscribeEvent() - public void onInteract(PlayerInteractEntityEvent interact) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - - DungeonContext context = skyblockStatus.getContext(); - - if (skyblockStatus.getContext() != null) { - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - if (context.getBossfightProcessor() != null) { - context.getBossfightProcessor().onInteract(interact); - } - RoomProcessor roomProcessor = null; - try { - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().onInteract(interact); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - - @SubscribeEvent() - public void onBlockChange(BlockUpdateEvent.Post postInteract) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - - DungeonContext context = skyblockStatus.getContext(); - - if (skyblockStatus.getContext() != null) { - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - if (context.getBossfightProcessor() != null) { - context.getBossfightProcessor().onBlockUpdate(postInteract); - } - RoomProcessor roomProcessor = null; - try { - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().onBlockUpdate(postInteract); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - - @SubscribeEvent - public void onKeyInput(KeyBindPressedEvent keyInputEvent) { - if (FeatureRegistry.DEBUG.isEnabled() && FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && keyInputEvent.getKey() == FeatureRegistry.ADVANCED_ROOMEDIT.getParameter("key").getValue() ){ - EditingContext ec = EditingContext.getEditingContext(); - if (ec == null) { - DungeonContext context = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext(); - if (context == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Not in dungeons")); - return; - } - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - - if (dungeonRoom == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Can't determine the dungeon room you're in")); - return; - } - - if (EditingContext.getEditingContext() != null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("There is an editing session currently open.")); - return; - } - - EditingContext.createEditingContext(dungeonRoom); - EditingContext.getEditingContext().openGui(new GuiDungeonRoomEdit(dungeonRoom)); - } else ec.reopen(); - } - } - @SubscribeEvent - public void onInteract(PlayerInteractEvent keyInputEvent) { - try { - if (!keyInputEvent.world.isRemote) return; - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - - DungeonContext context = skyblockStatus.getContext(); - - if (skyblockStatus.getContext() != null) { - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - if (context.getBossfightProcessor() != null) { - context.getBossfightProcessor().onInteractBlock(keyInputEvent); - } - RoomProcessor roomProcessor = null; - try { - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().onInteractBlock(keyInputEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - - @Getter - private final Map entityIdToPosMap = new HashMap(); - @SubscribeEvent - public void onEntitySpawn(EntityJoinWorldEvent spawn) { - DungeonActionManager.getSpawnLocation().put(spawn.entity.getEntityId(), new Vec3(spawn.entity.posX, spawn.entity.posY, spawn.entity.posZ)); - } - - - @SubscribeEvent - public void onEntityDeSpawn(LivingDeathEvent deathEvent) { - if (deathEvent.entityLiving instanceof EntityBat) - DungeonActionManager.getKilleds().add(deathEvent.entity.getEntityId()); - - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - - DungeonContext context = skyblockStatus.getContext(); - - if (skyblockStatus.getContext() != null) { - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - - if (context.getBossfightProcessor() != null) { - context.getBossfightProcessor().onEntityDeath(deathEvent); - } - RoomProcessor roomProcessor = null; - try { - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().onEntityDeath(deathEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - - if (!(deathEvent.entityLiving instanceof EntityBat)) - DungeonActionManager.getSpawnLocation().remove(deathEvent.entity.getEntityId()); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java deleted file mode 100644 index a3e8faa3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.eventlistener; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.events.*; -import kr.syeyoung.dungeonsguide.features.*; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.listener.*; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraftforge.client.event.*; -import net.minecraftforge.client.event.sound.PlaySoundEvent; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -public class FeatureListener { - @SubscribeEvent - public void onRender(RenderGameOverlayEvent.Post postRender) { - try { - boolean isLocConfig = Minecraft.getMinecraft().currentScreen instanceof GuiGuiLocationConfig; - - if (!(postRender.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || postRender.type == RenderGameOverlayEvent.ElementType.JUMPBAR)) return; - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof ScreenRenderListener && (!isLocConfig || !(abstractFeature instanceof GuiFeature))) { - ((ScreenRenderListener) abstractFeature).drawScreen(postRender.partialTicks); - } - } - GlStateManager.enableBlend(); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @SubscribeEvent - public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof KeybindPressedListener) { - ((KeybindPressedListener) abstractFeature).onKeybindPress(keyBindPressedEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @SubscribeEvent - public void onStomp(StompConnectedEvent stompConnectedEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof StompConnectedListener) { - ((StompConnectedListener) abstractFeature).onStompConnected(stompConnectedEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onStomp(TextureStitchEvent.Pre textureStitchEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof TextureStichListener) { - ((TextureStichListener) abstractFeature).onTextureStitch(textureStitchEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onStomp(TextureStitchEvent.Post textureStitchEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof TextureStichListener) { - ((TextureStichListener) abstractFeature).onTextureStitch(textureStitchEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onDiscordUserUpdate(DiscordUserUpdateEvent discordUserUpdateEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof DiscordUserUpdateListener) { - ((DiscordUserUpdateListener) abstractFeature).onDiscordUserUpdate(discordUserUpdateEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onDiscordUserUpdate(DiscordUserJoinRequestEvent discordUserUpdateEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof DiscordUserJoinRequestListener) { - ((DiscordUserJoinRequestListener) abstractFeature).onDiscordUserJoinRequest(discordUserUpdateEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onWindowUpdate(WindowUpdateEvent windowUpdateEvent) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof GuiUpdateListener) { - ((GuiUpdateListener) abstractFeature).onGuiUpdate(windowUpdateEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onRender(RenderLivingEvent.Pre preRender) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof EntityLivingRenderListener) { - ((EntityLivingRenderListener) abstractFeature).onEntityRenderPre(preRender); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @SubscribeEvent - public void onSound(PlaySoundEvent soundEvent) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof SoundListener) { - ((SoundListener) abstractFeature).onSound(soundEvent); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @SubscribeEvent - public void onRender(RenderLivingEvent.Post preRender) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof EntityLivingRenderListener) { - ((EntityLivingRenderListener) abstractFeature).onEntityRenderPost(preRender); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onRender(TitleEvent titleEvent) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof TitleListener) { - ((TitleListener) abstractFeature).onTitle(titleEvent.getPacketTitle()); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onRender(RenderPlayerEvent.Pre preRender) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof PlayerRenderListener) { - ((PlayerRenderListener) abstractFeature).onEntityRenderPre(preRender); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onRender(RenderPlayerEvent.Post preRender) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof PlayerRenderListener) { - ((PlayerRenderListener) abstractFeature).onEntityRenderPost(preRender); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - - @SubscribeEvent - public void onRenderWorld(RenderWorldLastEvent postRender) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof WorldRenderListener) { - ((WorldRenderListener) abstractFeature).drawWorld(postRender.partialTicks); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onInteract(PlayerInteractEvent postRender) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof InteractListener) { - ((InteractListener) abstractFeature).onInteract(postRender); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - - @SubscribeEvent - public void onRenderWorld(ClientChatReceivedEvent postRender) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof ChatListener) { - ((ChatListener) abstractFeature).onChat(postRender); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @SubscribeEvent - public void onChatGlobal(ClientChatReceivedEvent postRender) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof ChatListenerGlobal) { - ((ChatListenerGlobal) abstractFeature).onChat(postRender); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @SubscribeEvent - public void dungeonTooltip(ItemTooltipEvent event) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof TooltipListener) { - ((TooltipListener) abstractFeature).onTooltip(event); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent tick) { - if (tick.phase == TickEvent.Phase.END && tick.type == TickEvent.Type.CLIENT ) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof TickListener) { - ((TickListener) abstractFeature).onTick(); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - } - @SubscribeEvent - public void onGuiOpen(GuiOpenEvent tick) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof GuiOpenListener) { - ((GuiOpenListener) abstractFeature).onGuiOpen(tick); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onGuiRender(GuiScreenEvent.DrawScreenEvent.Post render) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof GuiPostRenderListener) { - ((GuiPostRenderListener) abstractFeature).onGuiPostRender(render); - } - } - GlStateManager.enableBlend(); - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onGuiRender(GuiScreenEvent.DrawScreenEvent.Pre render) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof GuiPreRenderListener) { - ((GuiPreRenderListener) abstractFeature).onGuiPreRender(render); - } - } - GlStateManager.enableBlend(); - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onGuiRender(GuiScreenEvent.BackgroundDrawnEvent render) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof GuiBackgroundRenderListener) { - ((GuiBackgroundRenderListener) abstractFeature).onGuiBGRender(render); - } - } - GlStateManager.enableBlend(); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGH) - public void onGuiEvent(GuiScreenEvent.MouseInputEvent.Pre input) { - try { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnSkyblock()) return; - - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof GuiClickListener) { - ((GuiClickListener) abstractFeature).onMouseInput(input); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onSkyblockJoin(SkyblockJoinedEvent joinedEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof SkyblockJoinListener) { - ((SkyblockJoinListener) abstractFeature).onSkyblockJoin(); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onSkyblockQuit(SkyblockLeftEvent leftEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof SkyblockLeaveListener) { - ((SkyblockLeaveListener) abstractFeature).onSkyblockQuit(); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onKey(GuiScreenEvent.KeyboardInputEvent event) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof KeyInputListener) { - ((KeyInputListener) abstractFeature).onKeyInput(event); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onDungeonStart(DungeonStartedEvent leftEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof DungeonStartListener) { - ((DungeonStartListener) abstractFeature).onDungeonStart(); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onDungeonLeft(DungeonLeftEvent leftEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof DungeonQuitListener) { - ((DungeonQuitListener) abstractFeature).onDungeonQuit(); - } - if (abstractFeature instanceof DungeonEndListener) { - ((DungeonEndListener) abstractFeature).onDungeonEnd(); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onDungeonInitialize(DungeonContextInitializationEvent leftEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof DungeonContextInitializationListener) { - ((DungeonContextInitializationListener) abstractFeature).onDungeonInitialize(); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onDungeonInitialize(BossroomEnterEvent enterEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof BossroomEnterListener) { - ((BossroomEnterListener) abstractFeature).onBossroomEnter(); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - @SubscribeEvent - public void onDungeonInitialize(DungeonEndedEvent endedEvent) { - try { - for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { - if (abstractFeature instanceof DungeonEndListener) { - ((DungeonEndListener) abstractFeature).onDungeonEnd(); - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java deleted file mode 100644 index 759ecca9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.eventlistener; - -import io.netty.channel.ChannelDuplexHandler; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelPromise; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.cosmetics.CustomPacketPlayerListItem; -import kr.syeyoung.dungeonsguide.events.*; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.network.Packet; -import net.minecraft.network.play.INetHandlerPlayClient; -import net.minecraft.network.play.client.C02PacketUseEntity; -import net.minecraft.network.play.server.*; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Tuple; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.network.FMLNetworkEvent; - -import java.util.Arrays; - -@ChannelHandler.Sharable -public class PacketListener extends ChannelDuplexHandler { - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - Packet packet = (Packet) msg; - if (skyblockStatus.isOnSkyblock() - && msg instanceof S04PacketEntityEquipment - && FeatureRegistry.FIX_SPIRIT_BOOTS.isEnabled()) { // Inventory packet name - S04PacketEntityEquipment packet2 = (S04PacketEntityEquipment) msg; - if (packet2.getEntityID() == Minecraft.getMinecraft().thePlayer.getEntityId()) { - packet2 = new S04PacketEntityEquipment(packet2.getEntityID(), packet2.getEquipmentSlot() + 1, packet2.getItemStack()); - packet = packet2; - } - } - if (packet instanceof S45PacketTitle) { - MinecraftForge.EVENT_BUS.post(new TitleEvent((S45PacketTitle) packet)); - } - if (packet instanceof S38PacketPlayerListItem) { - packet = new CustomPacketPlayerListItem((S38PacketPlayerListItem) packet); - } - if (packet instanceof S30PacketWindowItems) { - packet = new CustomWindowItems((S30PacketWindowItems) packet); - } - if (packet instanceof S2FPacketSetSlot) { - packet = new CustomSetSlot((S2FPacketSetSlot) packet); - } - if (packet instanceof S23PacketBlockChange) { - packet = new SingleBlockChange((S23PacketBlockChange) packet); - } else if (packet instanceof S22PacketMultiBlockChange) { - packet = new MultiBlockChange((S22PacketMultiBlockChange) packet); - } - super.channelRead(ctx, packet); - } - - private static class CustomWindowItems extends S30PacketWindowItems { - public CustomWindowItems(S30PacketWindowItems parent) { - super(parent.func_148911_c(), Arrays.asList(parent.getItemStacks())); - } - - @Override - public void processPacket(INetHandlerPlayClient handler) { - super.processPacket(handler); - MinecraftForge.EVENT_BUS.post(new WindowUpdateEvent(this, null)); - } - } - private static class CustomSetSlot extends S2FPacketSetSlot { - public CustomSetSlot(S2FPacketSetSlot parent) { - super(parent.func_149175_c(), parent.func_149173_d(), parent.func_149174_e()); - } - @Override - public void processPacket(INetHandlerPlayClient handler) { - super.processPacket(handler); - MinecraftForge.EVENT_BUS.post(new WindowUpdateEvent(null, this)); - } - } - - private static class SingleBlockChange extends S23PacketBlockChange { - private S23PacketBlockChange old; - public SingleBlockChange(S23PacketBlockChange blockChange) { - this.old = blockChange; - } - - @Override - public void processPacket(INetHandlerPlayClient handler) { - BlockUpdateEvent blockUpdateEvent = new BlockUpdateEvent.Pre(); - blockUpdateEvent.getUpdatedBlocks().add(new Tuple<>(getBlockPosition(),getBlockState())); - MinecraftForge.EVENT_BUS.post(blockUpdateEvent); - super.processPacket(handler); - blockUpdateEvent = new BlockUpdateEvent.Post(); - blockUpdateEvent.getUpdatedBlocks().add(new Tuple<>(getBlockPosition(), getBlockState())); - MinecraftForge.EVENT_BUS.post(blockUpdateEvent); - } - - @Override - public BlockPos getBlockPosition() { - return old.getBlockPosition(); - } - - @Override - public IBlockState getBlockState() { - return old.getBlockState(); - } - } - - - private static class MultiBlockChange extends S22PacketMultiBlockChange { - private S22PacketMultiBlockChange old; - public MultiBlockChange(S22PacketMultiBlockChange blockChange) { - this.old = blockChange; - } - @Override - public void processPacket(INetHandlerPlayClient handler) { - BlockUpdateEvent blockUpdateEvent = new BlockUpdateEvent.Pre(); - for (S22PacketMultiBlockChange.BlockUpdateData changedBlock : getChangedBlocks()) { - blockUpdateEvent.getUpdatedBlocks().add(new Tuple<>(changedBlock.getPos(), changedBlock.getBlockState())); - } - MinecraftForge.EVENT_BUS.post(blockUpdateEvent); - super.processPacket(handler); - blockUpdateEvent = new BlockUpdateEvent.Post(); - for (S22PacketMultiBlockChange.BlockUpdateData changedBlock : getChangedBlocks()) { - blockUpdateEvent.getUpdatedBlocks().add(new Tuple<>(changedBlock.getPos(), changedBlock.getBlockState())); - } - MinecraftForge.EVENT_BUS.post(blockUpdateEvent); - } - - @Override - public BlockUpdateData[] getChangedBlocks() { - return old.getChangedBlocks(); - } - } - - @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { - Packet packet = (Packet) msg; - if (packet instanceof C02PacketUseEntity) { - C02PacketUseEntity packet2 = (C02PacketUseEntity) packet; - PlayerInteractEntityEvent piee; - if (packet2.getAction() == C02PacketUseEntity.Action.ATTACK) - piee = new PlayerInteractEntityEvent(true, packet2.getEntityFromWorld(Minecraft.getMinecraft().theWorld)); - else - piee = new PlayerInteractEntityEvent(false, ((C02PacketUseEntity) packet).getEntityFromWorld(Minecraft.getMinecraft().theWorld)); - - if (MinecraftForge.EVENT_BUS.post(piee)) return; - } - super.write(ctx, msg, promise); - } - - @SubscribeEvent - public void onServerConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { - event.manager.channel().pipeline().addBefore("packet_handler", "dg_packet_handler", this); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/BlockUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/BlockUpdateEvent.java deleted file mode 100644 index e6e94dcc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/BlockUpdateEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import lombok.Data; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Tuple; -import net.minecraftforge.fml.common.eventhandler.Event; - -import java.util.HashSet; -import java.util.Set; - -public abstract class BlockUpdateEvent extends Event { - @Getter @Setter - private Set> updatedBlocks = new HashSet<>(); - - public static class Pre extends BlockUpdateEvent {}; - public static class Post extends BlockUpdateEvent {}; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/BossroomEnterEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/BossroomEnterEvent.java deleted file mode 100644 index ecf57688..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/BossroomEnterEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class BossroomEnterEvent extends Event { -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/DiscordUserJoinRequestEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/DiscordUserJoinRequestEvent.java deleted file mode 100644 index 80a9315a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/DiscordUserJoinRequestEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordUser; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Data @AllArgsConstructor -public class DiscordUserJoinRequestEvent extends Event { - private DiscordUser discordUser; - private boolean isInvite; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/DiscordUserUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/DiscordUserUpdateEvent.java deleted file mode 100644 index f737b598..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/DiscordUserUpdateEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import kr.syeyoung.dungeonsguide.rpc.JDiscordRelation; -import kr.syeyoung.dungeonsguide.rpc.JDiscordUser; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Data @AllArgsConstructor -public class DiscordUserUpdateEvent extends Event { - private JDiscordRelation prev, current; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonContextInitializationEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonContextInitializationEvent.java deleted file mode 100644 index dfd9ed6f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonContextInitializationEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class DungeonContextInitializationEvent extends Event { -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonEndedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonEndedEvent.java deleted file mode 100644 index 399d7013..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonEndedEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class DungeonEndedEvent extends Event { -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonLeftEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonLeftEvent.java deleted file mode 100644 index 8e624516..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonLeftEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class DungeonLeftEvent extends Event { -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonStartedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonStartedEvent.java deleted file mode 100644 index 675adef1..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/DungeonStartedEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class DungeonStartedEvent extends Event { -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/HypixelJoinedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/HypixelJoinedEvent.java deleted file mode 100644 index c2f6b1d6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/HypixelJoinedEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class HypixelJoinedEvent extends Event { -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/KeyBindPressedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/KeyBindPressedEvent.java deleted file mode 100644 index c277b227..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/KeyBindPressedEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Data @AllArgsConstructor -public class KeyBindPressedEvent extends Event { - private int key; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerInteractEntityEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerInteractEntityEvent.java deleted file mode 100644 index 799e8102..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerInteractEntityEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.entity.Entity; -import net.minecraftforge.fml.common.eventhandler.Event; - -@AllArgsConstructor -public class PlayerInteractEntityEvent extends Event { - - @Getter @Setter - private boolean attack; - @Getter @Setter - private Entity entity; - - @Override - public boolean isCancelable() { - return true; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerListItemPacketEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerListItemPacketEvent.java deleted file mode 100644 index 65e936f0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/PlayerListItemPacketEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.network.play.server.S38PacketPlayerListItem; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Data -@AllArgsConstructor -public class PlayerListItemPacketEvent extends Event { - private S38PacketPlayerListItem packetPlayerListItem; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/SkyblockJoinedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/SkyblockJoinedEvent.java deleted file mode 100644 index 937ae59c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/SkyblockJoinedEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class SkyblockJoinedEvent extends Event { -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/SkyblockLeftEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/SkyblockLeftEvent.java deleted file mode 100644 index 3e9919be..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/SkyblockLeftEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class SkyblockLeftEvent extends Event { -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/StompConnectedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/StompConnectedEvent.java deleted file mode 100644 index d7220b17..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/StompConnectedEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import kr.syeyoung.dungeonsguide.stomp.StompInterface; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Data -@AllArgsConstructor -public class StompConnectedEvent extends Event { - private StompInterface stompInterface; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/TitleEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/TitleEvent.java deleted file mode 100644 index ab164d9d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/TitleEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.network.play.server.S45PacketTitle; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Data -@AllArgsConstructor -public class TitleEvent extends Event { - S45PacketTitle packetTitle; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/WindowUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/WindowUpdateEvent.java deleted file mode 100644 index 4c1b1150..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/events/WindowUpdateEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.events; - -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.network.play.server.S2FPacketSetSlot; -import net.minecraft.network.play.server.S30PacketWindowItems; -import net.minecraft.network.play.server.S45PacketTitle; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Data -@AllArgsConstructor -public class WindowUpdateEvent extends Event { - S30PacketWindowItems windowItems; - S2FPacketSetSlot packetSetSlot; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java deleted file mode 100644 index 23b76546..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features; - -import com.google.common.base.Supplier; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.config.types.TypeConverter; -import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; - -import java.util.*; - -public abstract class AbstractFeature { - @Getter - private final String category; - @Getter - private final String name; - - @Getter - private final String description; - - @Getter - private final String key; - - protected Map parameters = new HashMap(); - - protected AbstractFeature(String category, String name, String description, String key) { - this.category = category; - this.name = name; - this.description = description; - this.key = key; - } - - @Getter - @Setter - private boolean enabled = true; - - public List getParameters() { return new ArrayList(parameters.values()); } - - public FeatureParameter getParameter(String key) { - return parameters.get(key); - } - - public void loadConfig(JsonObject jsonObject) { // gets key, calls it - enabled = jsonObject.get("$enabled").getAsBoolean(); - - for (Map.Entry parameterEntry : parameters.entrySet()) { - parameterEntry.getValue().setToDefault(); - JsonElement element = jsonObject.get(parameterEntry.getKey()); - if (element == null) continue; - TypeConverter typeConverter = TypeConverterRegistry.getTypeConverter(parameterEntry.getValue().getValue_type()); - parameterEntry.getValue().setValue(typeConverter.deserialize(element)); - } - } - - public JsonObject saveConfig() { - JsonObject object = new JsonObject(); - for (Map.Entry parameterEntry : parameters.entrySet()) { - TypeConverter typeConverter = TypeConverterRegistry.getTypeConverter(parameterEntry.getValue().getValue_type()); - JsonElement obj = typeConverter.serialize(parameterEntry.getValue().getValue()); - object.add(parameterEntry.getKey(), obj); - } - object.addProperty("$enabled", isEnabled()); - return object; - } - - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + key , new Supplier() { - @Override - public MPanel get() { - MFeatureEdit featureEdit = new MFeatureEdit(AbstractFeature.this, rootConfigPanel); - for (FeatureParameter parameter: getParameters()) { - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(AbstractFeature.this, parameter, rootConfigPanel)); - } - return featureEdit; - } - }); - return "base." + key ; - } - - public void onParameterReset() {} - - public boolean isDisyllable() { - return true; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureParameter.java deleted file mode 100644 index f5a2133a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureParameter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features; - -import kr.syeyoung.dungeonsguide.config.types.TypeConverter; -import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class FeatureParameter { - private String key; - - private String name; - private String description; - - private T value; - private T default_value; - private String value_type; - - public FeatureParameter(String key, String name, String description, T default_value, String value_type) { - this.key = key; this.name = name; this.default_value = default_value; - this.description = description; this.value_type = value_type; - } - - public void setToDefault() { - TypeConverter typeConverter = TypeConverterRegistry.getTypeConverter(getValue_type()); - value = (T) typeConverter.deserialize(typeConverter.serialize(default_value)); - } - - public T getValue() { - return value == null ? default_value : value; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java deleted file mode 100644 index bf3be41d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features; - -import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureDebug; -import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureDebuggableMap; -import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureRoomCoordDisplay; -import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureRoomDebugInfo; -import kr.syeyoung.dungeonsguide.features.impl.boss.*; -import kr.syeyoung.dungeonsguide.features.impl.boss.terminal.FeatureSimonSaysSolver; -import kr.syeyoung.dungeonsguide.features.impl.boss.terminal.FeatureTerminalSolvers; -import kr.syeyoung.dungeonsguide.features.impl.cosmetics.FeatureNicknameColor; -import kr.syeyoung.dungeonsguide.features.impl.cosmetics.FeatureNicknamePrefix; -import kr.syeyoung.dungeonsguide.features.impl.discord.inviteViewer.PartyInviteViewer; -import kr.syeyoung.dungeonsguide.features.impl.discord.onlinealarm.PlayingDGAlarm; -import kr.syeyoung.dungeonsguide.features.impl.dungeon.*; -import kr.syeyoung.dungeonsguide.features.impl.etc.*; -import kr.syeyoung.dungeonsguide.features.impl.etc.ability.FeatureAbilityCooldown; -import kr.syeyoung.dungeonsguide.features.impl.party.APIKey; -import kr.syeyoung.dungeonsguide.features.impl.party.FeaturePartyList; -import kr.syeyoung.dungeonsguide.features.impl.party.FeaturePartyReady; -import kr.syeyoung.dungeonsguide.features.impl.party.customgui.FeatureCustomPartyFinder; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerStatsOnJoin; -import kr.syeyoung.dungeonsguide.features.impl.secret.*; -import kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser.FeatureMechanicBrowse; -import kr.syeyoung.dungeonsguide.features.impl.solvers.*; -import lombok.Getter; -import org.lwjgl.input.Keyboard; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class FeatureRegistry { - @Getter - private static final List featureList = new ArrayList(); - private static final Map featureByKey = new HashMap(); - @Getter - private static final Map> featuresByCategory = new HashMap>(); - @Getter - private static final Map categoryDescription = new HashMap<>(); - - public static AbstractFeature getFeatureByKey(String key) { - return featureByKey.get(key); - } - - public static T register(T abstractFeature) { - if (featureByKey.containsKey(abstractFeature.getKey())) throw new IllegalArgumentException("DUPLICATE FEATURE DEFINITION"); - featureList.add(abstractFeature); - featureByKey.put(abstractFeature.getKey(), abstractFeature); - List features = featuresByCategory.get(abstractFeature.getCategory()); - if (features == null) - features = new ArrayList(); - features.add(abstractFeature); - featuresByCategory.put(abstractFeature.getCategory(), features); - - return abstractFeature; - } - - - - public static final PathfindLineProperties SECRET_LINE_PROPERTIES_GLOBAL = register(new PathfindLineProperties("Dungeon Secrets", "Global Line Settings", "Global Line Settings", "secret.lineproperties.global", true, null)); - - - public static final FeatureMechanicBrowse SECRET_BROWSE = register(new FeatureMechanicBrowse()); - public static final PathfindLineProperties SECRET_LINE_PROPERTIES_SECRET_BROWSER = register(new PathfindLineProperties("Dungeon Secrets.Secret Browser", "Line Settings", "Line Settings when pathfinding using Secret Browser", "secret.lineproperties.secretbrowser", true, SECRET_LINE_PROPERTIES_GLOBAL)); - public static final FeatureActions SECRET_ACTIONS = register(new FeatureActions()); - - public static final FeaturePathfindStrategy SECRET_PATHFIND_STRATEGY = register(new FeaturePathfindStrategy()); - public static final FeatureTogglePathfind SECRET_TOGGLE_KEY = register(new FeatureTogglePathfind()); - public static final FeatureFreezePathfind SECRET_FREEZE_LINES = register(new FeatureFreezePathfind()); - public static final FeatureCreateRefreshLine SECRET_CREATE_REFRESH_LINE = register(new FeatureCreateRefreshLine()); - static { - categoryDescription.put("ROOT.Dungeon Secrets.Keybinds", "Useful keybinds / Toggle Pathfind lines, Freeze Pathfind lines, Refresh pathfind line or Trigger pathfind (you would want to use it, if you're using Pathfind to All)"); - } - - - public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto Pathfind to next secret", "Auto browse best next secret after current one completes.\nthe first pathfinding of first secret needs to be triggered first in order for this option to work", "secret.autobrowse", false)); - public static final SimpleFeature SECRET_AUTO_START = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto pathfind to new secret", "Auto browse best secret upon entering the room.", "secret.autouponenter", false)); - public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto Pathfind to new secret upon pressing a key", "Auto browse the best next secret when you press key.\nPress settings to edit the key", "secret.keyfornext", false) { - { - parameters.put("key", new FeatureParameter("key", "Key","Press to navigate to next best secret", Keyboard.KEY_NONE, "keybind")); - } - }); - - public static final SimpleFeature SECRET_BLOOD_RUSH = register(new FeatureBloodRush()); - public static final PathfindLineProperties SECRET_BLOOD_RUSH_LINE_PROPERTIES = register(new PathfindLineProperties("Dungeon Secrets.Blood Rush", "Blood Rush Line Settings", "Line Settings to be used", "secret.lineproperties.bloodrush", false, SECRET_LINE_PROPERTIES_GLOBAL)); - - - public static final PathfindLineProperties SECRET_LINE_PROPERTIES_AUTOPATHFIND = register(new PathfindLineProperties("Dungeon Secrets.Legacy AutoPathfind", "Line Settings", "Line Settings when pathfinding using above features", "secret.lineproperties.autopathfind", true, SECRET_LINE_PROPERTIES_GLOBAL)); - - public static final FeaturePathfindToAll SECRET_PATHFIND_ALL = register(new FeaturePathfindToAll()); - public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Parent Line Settings", "Line Settings to be used by default", "secret.lineproperties.apf.parent", false, SECRET_LINE_PROPERTIES_GLOBAL)); - public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_BAT = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Bat Line Settings", "Line Settings when pathfind to Bat, when using above feature", "secret.lineproperties.apf.bat", true, SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT)); - public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_CHEST = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Chest Line Settings", "Line Settings when pathfind to Chest, when using above feature", "secret.lineproperties.apf.chest", true, SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT)); - public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_ESSENCE = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Essence Line Settings", "Line Settings when pathfind to Essence, when using above feature", "secret.lineproperties.apf.essence", true, SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT)); - public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_ITEM_DROP = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Item Drop Line Settings", "Line Settings when pathfind to Item Drop, when using above feature", "secret.lineproperties.apf.itemdrop", true, SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT)); - - public static final FeatureSolverRiddle SOLVER_RIDDLE = register(new FeatureSolverRiddle()); - public static final FeatureSolverTictactoe SOLVER_TICTACTOE = register(new FeatureSolverTictactoe()); - public static final SimpleFeature SOLVER_WATERPUZZLE = register(new SimpleFeature("Solver.Any Floor", "Waterboard (Advanced)", "Calculates solution for waterboard puzzle and displays it to user", "solver.waterboard")); - public static final SimpleFeature SOLVER_CREEPER = register(new SimpleFeature("Solver.Any Floor", "Creeper", "Draws line between prismarine lamps in creeper room", "solver.creeper")); - public static final FeatureSolverTeleport SOLVER_TELEPORT = register(new FeatureSolverTeleport()); - public static final FeatureSolverBlaze SOLVER_BLAZE = register(new FeatureSolverBlaze()); - public static final FeatureSolverIcefill SOLVER_ICEPATH = register(new FeatureSolverIcefill()); - public static final FeatureSolverSilverfish SOLVER_SILVERFISH = register(new FeatureSolverSilverfish()); - public static final FeatureSolverBox SOLVER_BOX = register(new FeatureSolverBox()); - public static final FeatureSolverKahoot SOLVER_KAHOOT = register(new FeatureSolverKahoot()); - public static final FeatureSolverBombdefuse SOLVER_BOMBDEFUSE = register(new FeatureSolverBombdefuse()); - - - public static final FeatureDungeonMap DUNGEON_MAP = register(new FeatureDungeonMap()); - public static final FeatureDungeonRoomName DUNGEON_ROOMNAME = register(new FeatureDungeonRoomName()); - public static final FeaturePressAnyKeyToCloseChest DUNGEON_CLOSECHEST = register(new FeaturePressAnyKeyToCloseChest()); - public static final FeatureBoxSkelemaster DUNGEON_BOXSKELEMASTER = register(new FeatureBoxSkelemaster()); - public static final FeatureBoxBats DUNGEON_BOXBAT = register(new FeatureBoxBats()); - public static final FeatureBoxStarMobs DUNGEON_BOXSTARMOBS = register(new FeatureBoxStarMobs()); - public static final FeatureWatcherWarning DUNGEON_WATCHERWARNING = register(new FeatureWatcherWarning()); - public static final FeatureDungeonDeaths DUNGEON_DEATHS = register(new FeatureDungeonDeaths()); - public static final FeatureDungeonMilestone DUNGEON_MILESTONE = register(new FeatureDungeonMilestone()); - public static final FeatureDungeonRealTime DUNGEON_REALTIME = register(new FeatureDungeonRealTime()); - public static final FeatureDungeonSBTime DUNGEON_SBTIME = register(new FeatureDungeonSBTime()); - public static final FeatureDungeonSecrets DUNGEON_SECRETS = register(new FeatureDungeonSecrets()); - public static final FeatureDungeonCurrentRoomSecrets DUNGEON_SECRETS_ROOM = register(new FeatureDungeonCurrentRoomSecrets()); - public static final FeatureDungeonTombs DUNGEON_TOMBS = register(new FeatureDungeonTombs()); - public static final FeatureDungeonScore DUNGEON_SCORE = register(new FeatureDungeonScore()); - public static final FeatureWarnLowHealth DUNGEON_LOWHEALTH_WARN = register(new FeatureWarnLowHealth()); - public static final SimpleFeature DUNGEON_INTERMODCOMM = register(new SimpleFeature("Dungeon.Teammates", "Communicate With Other's Dungeons Guide", "Sends total secret in the room to others\nSo that they can use the data to calculate total secret in dungeon run\n\nThis automates player chatting action, (chatting data) Thus it might be against hypixel's rules.\nBut mods like auto-gg which also automate player action and is kinda allowed mod exist so I'm leaving this feature.\nThis option is use-at-your-risk and you'll be responsible for ban if you somehow get banned because of this feature\n(Although it is not likely to happen)\nDefaults to off", "dungeon.intermodcomm", false)); - public static final FeaturePlayerESP DUNGEON_PLAYERESP = register(new FeaturePlayerESP()); - public static final FeatureHideNameTags DUNGEON_HIDENAMETAGS = register(new FeatureHideNameTags()); - public static final FeatureSoulRoomWarning DUNGEON_FAIRYSOUL = register(new FeatureSoulRoomWarning()); - - public static final FeatureWarningOnPortal BOSSFIGHT_WARNING_ON_PORTAL = register(new FeatureWarningOnPortal()); - public static final SimpleFeature BOSSFIGHT_CHESTPRICE = register(new FeatureChestPrice()); - public static final FeatureAutoReparty BOSSFIGHT_AUTOREPARTY = register(new FeatureAutoReparty()); - public static final FeatureBossHealth BOSSFIGHT_HEALTH = register(new FeatureBossHealth()); - public static final FeatureHideAnimals BOSSFIGHT_HIDE_ANIMALS = register(new FeatureHideAnimals()); - public static final FeatureThornBearPercentage BOSSFIGHT_BEAR_PERCENT = register(new FeatureThornBearPercentage()); - public static final FeatureThornSpiritBowTimer BOSSFIGHT_BOW_TIMER = register(new FeatureThornSpiritBowTimer()); - public static final FeatureBoxRealLivid BOSSFIGHT_BOX_REALLIVID = register(new FeatureBoxRealLivid()); - public static final FeatureTerracotaTimer BOSSFIGHT_TERRACOTTA_TIMER = register(new FeatureTerracotaTimer()); - public static final FeatureCurrentPhase BOSSFIGHT_CURRENT_PHASE = register(new FeatureCurrentPhase()); - public static final FeatureTerminalSolvers BOSSFIGHT_TERMINAL_SOLVERS = register(new FeatureTerminalSolvers()); - public static final FeatureSimonSaysSolver BOSSFIGHT_SIMONSAYS_SOLVER = register(new FeatureSimonSaysSolver()); - - public static final APIKey PARTYKICKER_APIKEY = register(new APIKey()); - public static final FeatureViewPlayerStatsOnJoin PARTYKICKER_VIEWPLAYER = register(new FeatureViewPlayerStatsOnJoin()); - public static final FeatureCustomPartyFinder PARTYKICKER_CUSTOM = register(new FeatureCustomPartyFinder()); - public static final FeaturePartyList PARTY_LIST = register(new FeaturePartyList()); - public static final FeaturePartyReady PARTY_READY = register(new FeaturePartyReady()); - - public static final FeatureTooltipDungeonStat ETC_DUNGEONSTAT = register(new FeatureTooltipDungeonStat()); - public static final FeatureTooltipPrice ETC_PRICE = register(new FeatureTooltipPrice()); - public static final FeatureAbilityCooldown ETC_ABILITY_COOLDOWN = register(new FeatureAbilityCooldown()); - public static final FeatureCooldownCounter ETC_COOLDOWN = register(new FeatureCooldownCounter()); - public static final FeatureRepartyCommand ETC_REPARTY = register(new FeatureRepartyCommand()); - public static final FeatureDecreaseExplosionSound ETC_EXPLOSION_SOUND = register(new FeatureDecreaseExplosionSound()); - public static final FeatureAutoAcceptReparty ETC_AUTO_ACCEPT_REPARTY = register(new FeatureAutoAcceptReparty()); - public static final FeatureUpdateAlarm ETC_TEST = register(new FeatureUpdateAlarm()); - - public static final SimpleFeature FIX_SPIRIT_BOOTS = register(new SimpleFeature("Misc", "Spirit Boots Fixer", "Fix Spirit boots messing up with inventory", "fixes.spirit", true)); - public static final FeatureDisableMessage FIX_MESSAGES = register(new FeatureDisableMessage()); - - public static final FeatureCopyMessages ETC_COPY_MSG = register(new FeatureCopyMessages()); - - public static final FeaturePenguins ETC_PENGUIN = register(new FeaturePenguins()); - - public static final FeatureCollectScore ETC_COLLECT_SCORE = register(new FeatureCollectScore()); - - - - - - public static final FeatureNicknamePrefix COSMETIC_PREFIX = register(new FeatureNicknamePrefix()); - public static final FeatureNicknameColor COSMETIC_NICKNAMECOLOR = register(new FeatureNicknameColor()); - - - - public static final SimpleFeature DISCORD_RICHPRESENCE = register(new SimpleFeature("Discord", "Discord RPC", "Enable Discord rich presence", "advanced.richpresence", true) { - { - parameters.put("disablenotskyblock", new FeatureParameter("disablenotskyblock", "Disable When not on Skyblock", "Disable When not on skyblock", false, "boolean")); - } - }); - public static final PartyInviteViewer DISCORD_ASKTOJOIN = register(new PartyInviteViewer()); - public static final PlayingDGAlarm DISCORD_ONLINEALARM = register(new PlayingDGAlarm()); - public static final SimpleFeature DISCORD_DONOTUSE = register(new SimpleFeature("Discord", "Disable Native Library", "Disables usage of jna for discord rpc support.\nBreaks any discord related feature in the mod.\nRequires mod restart to get affected.\n\nThis feature is only for those whose minecraft crashes due to discord gamesdk crash.", "discord.rpc", false)); - - - public static final SimpleFeature DEBUG = register(new FeatureDebug()); - public static final SimpleFeature ADVANCED_ROOMEDIT = register(new SimpleFeature("Advanced", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false){ - { - parameters.put("key", new FeatureParameter("key", "Key","Press to edit room", Keyboard.KEY_R, "keybind")); - } - }); - - public static final FeatureRoomDebugInfo ADVANCED_DEBUG_ROOM = register(new FeatureRoomDebugInfo()); - public static final FeatureDebuggableMap ADVANCED_DEBUGGABLE_MAP = register(new FeatureDebuggableMap()); - public static final FeatureRoomCoordDisplay ADVANCED_COORDS = register(new FeatureRoomCoordDisplay()); - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java deleted file mode 100644 index 9e34be02..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features; - -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfigV2; -import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; -import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; -import kr.syeyoung.dungeonsguide.features.listener.ScreenRenderListener; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -@Getter -public abstract class GuiFeature extends AbstractFeature implements ScreenRenderListener { - @Setter - private GUIRectangle featureRect; - @Setter(value = AccessLevel.PROTECTED) - private boolean keepRatio; - @Setter(value = AccessLevel.PROTECTED) - private double defaultWidth; - @Setter(value = AccessLevel.PROTECTED) - private double defaultHeight; - private final double defaultRatio; - - protected GuiFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { - super(category, name, description, key); - this.keepRatio = keepRatio; - this.defaultWidth = width; - this.defaultHeight = height; - this.defaultRatio = defaultWidth / defaultHeight; - this.featureRect = new GUIRectangle(0, 0, width, height); - } - - @Override - public void drawScreen(float partialTicks) { - if (!isEnabled()) return; - - GlStateManager.pushMatrix(); - Rectangle featureRect = this.featureRect.getRectangleNoScale(); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GlStateManager.scale(1.0/scaledResolution.getScaleFactor(), 1.0/scaledResolution.getScaleFactor(), 1); - clip(featureRect.x, featureRect.y, featureRect.width, featureRect.height); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - - GlStateManager.translate(featureRect.x, featureRect.y, 0); - drawHUD(partialTicks); - - GL11.glDisable(GL11.GL_SCISSOR_TEST); - GlStateManager.popMatrix(); - - - GlStateManager.enableBlend(); - GlStateManager.color(1,1,1,1); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - - public abstract void drawHUD(float partialTicks); - - public void drawDemo(float partialTicks) { - drawHUD(partialTicks); - } - - private void clip(int x, int y, int width, int height) { -// int scale = resolution.getScaleFactor(); - int scale = 1; - GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); - } - - public static FontRenderer getFontRenderer() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - return fr; - } - - @Override - public void loadConfig(JsonObject jsonObject) { - super.loadConfig(jsonObject); - this.featureRect = TypeConverterRegistry.getTypeConverter("guirect",GUIRectangle.class).deserialize(jsonObject.get("$bounds")); - } - - @Override - public JsonObject saveConfig() { - JsonObject object = super.saveConfig(); - object.add("$bounds", TypeConverterRegistry.getTypeConverter("guirect", GUIRectangle.class).serialize(featureRect)); - return object; - } - - public List getTooltipForEditor(GuiGuiLocationConfig guiGuiLocationConfig) { - ArrayList mPanels = new ArrayList<>(); - mPanels.add(new MLabel(){ - { - setText(getName()); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(Minecraft.getMinecraft().fontRendererObj.getStringWidth(getName()), 20); - } - }); - mPanels.add(new MButton() { - { - setText("Edit"); - setOnActionPerformed(() -> { - GuiScreen guiScreen = guiGuiLocationConfig.getBefore(); - if (guiScreen == null) { - guiScreen = new GuiConfigV2(); - } - Minecraft.getMinecraft().displayGuiScreen(guiScreen); - if (guiScreen instanceof GuiConfigV2) { - ((GuiConfigV2) guiScreen).getRootConfigPanel().setCurrentPageAndPushHistory(getEditRoute(((GuiConfigV2) guiScreen).getRootConfigPanel())); - } - }); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(100,20); - } - }); - mPanels.add(new MPassiveLabelAndElement("Enabled", new MToggleButton() {{ - setEnabled(GuiFeature.this.isEnabled()); - setOnToggle(() ->{ - GuiFeature.this.setEnabled(isEnabled()); - }); } - })); - return mPanels; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/SimpleFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/SimpleFeature.java deleted file mode 100644 index 03be804c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/SimpleFeature.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features; - -public class SimpleFeature extends AbstractFeature { - protected SimpleFeature(String category, String name, String key) { - this(category, name, name, key); - } - protected SimpleFeature(String category, String name, String description, String key) { - this(category, name, description, key, true); - } - - protected SimpleFeature(String category, String name, String description, String key, boolean enabled) { - super(category, name, description, key); - this.setEnabled(enabled); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java deleted file mode 100644 index a254f0db..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebug.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.advanced; - -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; - -public class FeatureDebug extends SimpleFeature { - public FeatureDebug() { - super("Advanced", "Debug", "Toggles debug mode", "debug", false); - parameters.put("Key", new FeatureParameter("Key", "Secret Key given by syeyoung", "Put the debug enable key here to enable debug mode", "","string")); - } - @Override - public boolean isEnabled() { - return "just hide it".equals(this.getParameter("Key").getValue()); - } - @Override - public boolean isDisyllable() { - return false; - } - - @Override - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { - @Override - public MPanel get() { - MFeatureEdit featureEdit = new MFeatureEdit(FeatureDebug.this, rootConfigPanel); - for (FeatureParameter parameter: getParameters()) { - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureDebug.this, parameter, rootConfigPanel)); - } - featureEdit.addParameterEdit("IsEnabled", new MParameterEdit(FeatureDebug.this, new FeatureParameter("Key Status", "Key Status", "Key Enabled? Or not?", "", "idk"), rootConfigPanel, new MLabel() { - @Override - public String getText() { - return isEnabled() ? "Enabled!" : "Incorrect Key"; - } - }, (a) -> false)); - return featureEdit; - } - }); - return "base." + getKey() ; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java deleted file mode 100644 index 2a2b1a39..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.advanced; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener; -import kr.syeyoung.dungeonsguide.utils.MapUtils; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.fml.client.config.GuiUtils; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.Arrays; - -public class FeatureDebuggableMap extends GuiFeature { - public FeatureDebuggableMap() { - super("Advanced", "Display Debug Info included map", "ONLY WORKS WITH SECRET SETTING", "advanced.debug.map", true, 128, 128); - this.setEnabled(false); - } - - - DynamicTexture dynamicTexture = new DynamicTexture(128, 128); - ResourceLocation location = Minecraft.getMinecraft().renderEngine.getDynamicTextureLocation("dungeons/map/", dynamicTexture); - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public void drawHUD(float partialTicks) { -// if (!skyblockStatus.isOnDungeon()) return; - if (!FeatureRegistry.DEBUG.isEnabled()) return; -// DungeonContext context = skyblockStatus.getContext(); -// if (context == null) return; - - GlStateManager.pushMatrix(); - double factor = getFeatureRect().getRectangle().getWidth() / 128; - GlStateManager.scale(factor, factor, 1); - int[] textureData = dynamicTexture.getTextureData(); - MapUtils.getImage().getRGB(0, 0, 128, 128, textureData, 0, 128); - dynamicTexture.updateDynamicTexture(); - Minecraft.getMinecraft().getTextureManager().bindTexture(location); - GlStateManager.enableAlpha(); - GuiScreen.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 128, 128, 128, 128); - GlStateManager.popMatrix(); - - - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) return; - Rectangle featureRect = this.getFeatureRect().getRectangleNoScale(); - - int i = (int) ((int) (Mouse.getEventX() - featureRect.getX()) / factor); - int j = (int) ((int) (Minecraft.getMinecraft().displayHeight - Mouse.getEventY() - featureRect.getY())/ factor); - if (i >= 0 && j>= 0 && i <= 128 && j <= 128 && MapUtils.getColors() != null) { - GuiUtils.drawHoveringText(Arrays.asList(i+","+j,"Color: "+MapUtils.getColors()[j * 128 + i]),(int)(Mouse.getEventX() - featureRect.getX()), (int) (Minecraft.getMinecraft().displayHeight - Mouse.getEventY() - featureRect.getY()), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, -1, Minecraft.getMinecraft().fontRendererObj); - } - } - - @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - Rectangle featureRect = getFeatureRect().getRectangle(); - GL11.glLineWidth(2); - RenderUtils.drawUnfilledBox(0,0,featureRect.width, featureRect.height, 0xff000000, false); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java deleted file mode 100644 index 553cf3a5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.advanced; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.BlockPos; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; - -public class FeatureRoomCoordDisplay extends GuiFeature { - public FeatureRoomCoordDisplay() { - super("Advanced", "Display Coordinate Relative to the Dungeon Room and room's rotation", "X: 0 Y: 3 Z: 5 Facing: Z+" , "advanced.coords", false, getFontRenderer().getStringWidth("X: 48 Y: 100 Z: 48 Facing: Z+"), 10); - this.setEnabled(false); - parameters.put("color", new FeatureParameter("color", "Color", "Color of text", Color.yellow, "color")); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private static final String[] facing = {"Z+", "X-", "Z-", "X+"}; - @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return; - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) { - return; - } - - int facing = (int) (thePlayer.rotationYaw + 45) % 360; - if (facing < 0) facing += 360; - int real = (facing / 90 + dungeonRoom.getRoomMatcher().getRotation()) % 4; - - OffsetPoint offsetPoint = new OffsetPoint(dungeonRoom, new BlockPos((int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ)); - - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - - double scale = getFeatureRect().getRectangle().getHeight() / fontRenderer.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - - int color = this.getParameter("color").getValue().getRGB(); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fontRenderer.drawString("X: "+offsetPoint.getX()+" Y: "+offsetPoint.getY()+" Z: "+offsetPoint.getZ()+" Facing: "+ FeatureRoomCoordDisplay.facing[real], 0, 0, color); - } - - @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - int facing = (int) (Minecraft.getMinecraft().thePlayer.rotationYaw + 45) % 360; - if (facing < 0) facing += 360; - double scale = getFeatureRect().getRectangle().getHeight() / fr.FONT_HEIGHT; - GlStateManager.scale(scale, scale, 0); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("X: 0 Y: 3 Z: 5 Facing: "+FeatureRoomCoordDisplay.facing[(facing / 90) % 4], 0,0, this.getParameter("color").getValue().getRGB()); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomDebugInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomDebugInfo.java deleted file mode 100644 index c5dc4264..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomDebugInfo.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.advanced; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import org.apache.commons.lang3.StringUtils; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; - -public class FeatureRoomDebugInfo extends GuiFeature { - public FeatureRoomDebugInfo() { - super("Advanced", "Display Room Debug Info", "ONLY WORKS WITH SECRET SETTING", "advanced.debug.roominfo", false, getFontRenderer().getStringWidth("longestplayernamepos: 100"), getFontRenderer().FONT_HEIGHT * 6); - this.setEnabled(false); - parameters.put("color", new FeatureParameter("color", "Color", "Color of text", Color.white, "color")); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - if (!FeatureRegistry.DEBUG.isEnabled()) return; - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return; - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - int color = this.getParameter("color").getValue().getRGB(); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (dungeonRoom == null) { - if (context.getBossfightProcessor() == null) { - fontRenderer.drawString("Where are you?!", 0, 0, 0xFFFFFF); - } else { - fontRenderer.drawString("You're prob in bossfight", 0, 0, color); - fontRenderer.drawString("processor: "+context.getBossfightProcessor(), 0, 10, color); - fontRenderer.drawString("phase: "+context.getBossfightProcessor().getCurrentPhase(), 0, 20, color); - fontRenderer.drawString("nextPhase: "+ StringUtils.join(context.getBossfightProcessor().getNextPhases(), ","), 0, 30, color); - fontRenderer.drawString("phases: "+ StringUtils.join(context.getBossfightProcessor().getPhases(), ","), 0, 40, color); - } - } else { - fontRenderer.drawString("you're in the room... color/shape/rot " + dungeonRoom.getColor() + " / " + dungeonRoom.getShape() + " / "+dungeonRoom.getRoomMatcher().getRotation(), 0, 0, color); - fontRenderer.drawString("room uuid: " + dungeonRoom.getDungeonRoomInfo().getUuid() + (dungeonRoom.getDungeonRoomInfo().isRegistered() ? "" : " (not registered)"), 0, 10, color); - fontRenderer.drawString("room name: " + dungeonRoom.getDungeonRoomInfo().getName(), 0, 20, color); - fontRenderer.drawString("room state / max secret: " + dungeonRoom.getCurrentState() + " / "+dungeonRoom.getTotalSecrets(), 0, 30, color); - - } - } - - @Override - public void drawDemo(float partialTicks) { - FontRenderer fr = getFontRenderer(); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Line 1", 0,0, this.getParameter("color").getValue().getRGB()); - fr.drawString("Line 2", 0,10, this.getParameter("color").getValue().getRGB()); - fr.drawString("Line 3", 0,20, this.getParameter("color").getValue().getRGB()); - fr.drawString("Line 4", 0,30, this.getParameter("color").getValue().getRGB()); - fr.drawString("Line 5", 0,40, this.getParameter("color").getValue().getRGB()); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java deleted file mode 100644 index ad6b7200..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.DungeonQuitListener; - -public class FeatureAutoReparty extends SimpleFeature implements DungeonQuitListener { - public FeatureAutoReparty() { - super("Party.Reparty", "Auto reparty when dungeon finishes","Auto reparty on dungeon finish\n\nThis automates player chatting action, (disbanding, repartying) Thus it might be against hypixel's rules.\nBut mods like auto-gg exist so I'm leaving this feature.\nThis option is use-at-your-risk and you'll be responsible for ban if you somehow get banned because of this feature\n(Although it is not likely to happen)\nDefaults to off", "bossfight.autoreparty", false); - } - - @Override - public void onDungeonQuit() { - if (isEnabled()) DungeonsGuide.getDungeonsGuide().getCommandReparty().requestReparty(true); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java deleted file mode 100644 index f8cd2257..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.HealthData; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureBossHealth extends TextHUDFeature { - public FeatureBossHealth() { - super("Bossfight", "Display Boss Health(s)", "Show the health of boss and minibosses in bossfight (Guardians, Priests..)", "bossfight.health", false, getFontRenderer().getStringWidth("The Professor: 4242m"), getFontRenderer().FONT_HEIGHT * 5); - this.setEnabled(true); - parameters.put("totalHealth", new FeatureParameter("totalHealth", "show total health", "Show total health along with current health", false, "boolean")); - parameters.put("formatHealth", new FeatureParameter("formatHealth", "format health", "1234568 -> 1m", true, "boolean")); - parameters.put("ignoreInattackable", new FeatureParameter("ignoreInattackable", "Don't show health of in-attackable enemy", "For example, do not show guardians health when they're not attackable", false, "boolean")); - - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("health", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("maxHealth", new AColor(0x55, 0x55,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - - @Override - public boolean doesScaleWithHeight() { - return false; - } - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() != null; - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("title", "separator", "health", "separator2", "maxHealth"); - } - - @Override - public java.util.List getDummyText() { - List actualBit = new ArrayList(); - addLine(new HealthData("The Professor", 3300000, 5000000, false), actualBit); - addLine(new HealthData("Chaos Guardian", 500000, 2000000, true), actualBit); - addLine(new HealthData("Healing Guardian", 1000000, 3000000, true), actualBit); - addLine(new HealthData("Laser Guardian", 5000000, 5000000, true), actualBit); - addLine(new HealthData("Giant", 10000000, 20000000, false), actualBit); - return actualBit; - } - - public void addLine(HealthData data, List actualBit) { - boolean format = this.getParameter("formatHealth").getValue(); - boolean total = this.getParameter("totalHealth").getValue(); - boolean ignore = this.getParameter("ignoreInattackable").getValue(); - if (ignore && !data.isAttackable()) return; - - actualBit.add(new StyledText(data.getName(),"title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText( (format ? TextUtils.format(data.getHealth()) : data.getHealth()) + (total ? "" : "\n"),"health")); - if (total) { - actualBit.add(new StyledText("/", "separator2")); - actualBit.add(new StyledText( (format ? TextUtils.format(data.getMaxHealth()) : data.getMaxHealth()) +"\n","maxHealth")); - } - } - - @Override - public java.util.List getText() { - List actualBit = new ArrayList(); - List healths = skyblockStatus.getContext().getBossfightProcessor().getHealths(); - for (HealthData heal : healths) { - addLine(heal, actualBit); - } - return actualBit; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java deleted file mode 100644 index 415753b5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessorLivid; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.util.AxisAlignedBB; - - -public class FeatureBoxRealLivid extends SimpleFeature implements WorldRenderListener { - public FeatureBoxRealLivid() { - super("Bossfight.Floor 5", "Box Real Livid", "Box Real Livid in bossfight", "bossfight.realLividBox", true); - parameters.put("color", new FeatureParameter("color", "Highlight Color", "Highlight Color of Livid", new AColor(0,255,0,150), "acolor")); - } - - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public void drawWorld(float partialTicks) { - if (!isEnabled()) return; - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null) return; - if (skyblockStatus.getContext().getBossfightProcessor() == null) return; - if (!(skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorLivid)) return; - EntityOtherPlayerMP playerMP = ((BossfightProcessorLivid) skyblockStatus.getContext().getBossfightProcessor()).getRealLivid(); - - AColor c = this.getParameter("color").getValue(); - if (playerMP != null) - RenderUtils.highlightBox(playerMP, AxisAlignedBB.fromBounds(-0.4,0,-0.4,0.4,1.8,0.4), c, partialTicks, true); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java deleted file mode 100644 index 6d4f9cf3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.GuiBackgroundRenderListener; -import kr.syeyoung.dungeonsguide.utils.AhUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.client.event.GuiScreenEvent; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.util.Comparator; -import java.util.Set; -import java.util.TreeSet; - -public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRenderListener { - public FeatureChestPrice() { - super("Bossfight", "Show Profit of Dungeon Chests","Show Profit of Dungeon Chests", "bossfight.profitchest", false); - } - - @Override - public void onGuiBGRender(GuiScreenEvent.BackgroundDrawnEvent rendered) { - if (!isEnabled()) return; - if (!(rendered.gui instanceof GuiChest)) return; - if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; - - GlStateManager.disableLighting(); - - ContainerChest chest = (ContainerChest) ((GuiChest) rendered.gui).inventorySlots; - if (!chest.getLowerChestInventory().getName().endsWith("Chest")) return; - IInventory actualChest = chest.getLowerChestInventory(); - - int chestPrice = 0; - int itemPrice = 0; - for (int i = 0; i 0) { - for (int j1 = 0; j1 < nbttaglist1.tagCount(); ++j1) { - String str = nbttaglist1.getStringTagAt(j1); - if (str.endsWith("Coins")) { - String coins = TextUtils.stripColor(str).replace(" Coins", "").replace(",",""); - try { - chestPrice = Integer.parseInt(coins); - } catch (Exception e) { - - } - } - } - } - } - } - } - itemPrice += getPrice(item) * item.stackSize; - } - } - - int i = 222; - int j = i - 108; - int ySize = j + (actualChest.getSizeInventory() / 9) * 18; - int left = (rendered.gui.width + 176) / 2; - int top = (rendered.gui.height - ySize ) / 2; - - int width = 120; - - GlStateManager.pushMatrix(); - GlStateManager.translate(left, top, 0); - Gui.drawRect( 0,0,width, 30, 0xFFDDDDDD); - - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("BIN/AH Price: ", 5,5, 0xFF000000); - String str = TextUtils.format(itemPrice); - fr.drawString(str, width - fr.getStringWidth(str) - 5, 5, 0xFF000000); - - fr.drawString("Profit: ", 5,15, 0xFF000000); - str = (itemPrice > chestPrice ? "+" : "") +TextUtils.format(itemPrice - chestPrice); - fr.drawString(str, width - fr.getStringWidth(str) - 5, 15, itemPrice > chestPrice ? 0xFF00CC00 : 0xFFCC0000); - - GlStateManager.popMatrix(); - - GlStateManager.enableLighting(); - GlStateManager.enableBlend(); - } - - public static long getPrice(ItemStack itemStack) { - if (itemStack == null) return 0; - NBTTagCompound compound = itemStack.getTagCompound(); - if (compound == null) - return 0; - if (!compound.hasKey("ExtraAttributes")) - return 0; - final String id = compound.getCompoundTag("ExtraAttributes").getString("id"); - if (id.equals("ENCHANTED_BOOK")) { - final NBTTagCompound enchants = compound.getCompoundTag("ExtraAttributes").getCompoundTag("enchantments"); - Set keys = enchants.getKeySet(); - Set actualKeys = new TreeSet(new Comparator() { - public int compare(String o1, String o2) { - String id2 = id + "::" + o1 + "-" + enchants.getInteger(o1); - AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); - long price1 = (auctionData == null) ? 0 : auctionData.lowestBin; - String id3 = id + "::" + o2 + "-" + enchants.getInteger(o2); - AhUtils.AuctionData auctionData2 = AhUtils.auctions.get(id3); - long price2 = (auctionData2 == null) ? 0 : auctionData2.lowestBin; - return (compare2(price1, price2) == 0) ? o1.compareTo(o2) : compare2(price1, price2); - } - - public int compare2(long y, long x) { - return (x < y) ? -1 : ((x == y) ? 0 : 1); - } - }); - actualKeys.addAll(keys); - int totalLowestPrice = 0; - for (String key : actualKeys) { - String id2 = id + "::" + key + "-" + enchants.getInteger(key); - AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); - totalLowestPrice += auctionData.lowestBin; - } - return totalLowestPrice; - } else { - AhUtils.AuctionData auctionData = AhUtils.auctions.get(id); - if (auctionData == null) { - return 0; - } else { - if (auctionData.sellPrice == -1 && auctionData.lowestBin != -1) return auctionData.lowestBin; - else if (auctionData.sellPrice != -1 && auctionData.lowestBin == -1) return auctionData.sellPrice; - else { - long ahPrice = auctionData.lowestBin; - if (ahPrice > auctionData.sellPrice) return ahPrice; - else return auctionData.sellPrice; - } - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureCurrentPhase.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureCurrentPhase.java deleted file mode 100644 index 502229fe..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureCurrentPhase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureCurrentPhase extends TextHUDFeature { - public FeatureCurrentPhase() { - super("Bossfight", "Display Current Phase", "Displays the current phase of bossfight", "bossfight.phasedisplay", false, getFontRenderer().getStringWidth("Current Phase: fight-2-idk-howlng"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(true); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("phase", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - private static final List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Current Phase","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("fight-2","phase")); - } - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() != null; - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("title", "separator", "phase"); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public List getText() { - String currentPhsae =skyblockStatus.getContext().getBossfightProcessor().getCurrentPhase(); - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Current Phase","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(currentPhsae,"phase")); - return actualBit; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureHideAnimals.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureHideAnimals.java deleted file mode 100644 index 6330f5bb..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureHideAnimals.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.EntityLivingRenderListener; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessorThorn; -import net.minecraft.entity.passive.*; -import net.minecraftforge.client.event.RenderLivingEvent; - - -public class FeatureHideAnimals extends SimpleFeature implements EntityLivingRenderListener { - public FeatureHideAnimals() { - super("Bossfight.Floor 4", "Hide animals on f4", "Hide Spirit Animals on F4. \nClick on Edit for precise setting", "bossfight.hideanimals", false); - parameters.put("sheep", new FeatureParameter("sheep", "Hide Sheeps", "Hide Sheeps", true, "boolean")); - parameters.put("cow", new FeatureParameter("cow", "Hide Cows", "Hide Cows", true, "boolean")); - parameters.put("chicken", new FeatureParameter("chicken", "Hide Chickens", "Hide Chickens", true, "boolean")); - parameters.put("wolf", new FeatureParameter("wolf", "Hide Wolves", "Hide Wolves", true, "boolean")); - parameters.put("rabbit", new FeatureParameter("rabbit", "Hide Rabbits", "Hide Rabbits", true, "boolean")); - } - - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - @Override - public void onEntityRenderPre(RenderLivingEvent.Pre renderPlayerEvent) { - if (!isEnabled()) return; - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null) return; - if (skyblockStatus.getContext().getBossfightProcessor() == null) return; - if (!(skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorThorn)) return; - - if (renderPlayerEvent.entity instanceof EntitySheep && this.getParameter("sheep").getValue()) { - renderPlayerEvent.setCanceled(true); - } else if (renderPlayerEvent.entity instanceof EntityCow && this.getParameter("cow").getValue() ) { - renderPlayerEvent.setCanceled(true); - } else if (renderPlayerEvent.entity instanceof EntityChicken && this.getParameter("chicken").getValue()) { - renderPlayerEvent.setCanceled(true); - } else if (renderPlayerEvent.entity instanceof EntityWolf && this.getParameter("wolf").getValue()) { - renderPlayerEvent.setCanceled(true); - } else if (renderPlayerEvent.entity instanceof EntityRabbit && this.getParameter("rabbit").getValue()) { - renderPlayerEvent.setCanceled(true); - } - } - - @Override - public void onEntityRenderPost(RenderLivingEvent.Post renderPlayerEvent) { - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureTerracotaTimer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureTerracotaTimer.java deleted file mode 100644 index 22538cca..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureTerracotaTimer.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessorSadan; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.entity.boss.BossStatus; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureTerracotaTimer extends TextHUDFeature { - public FeatureTerracotaTimer() { - super("Bossfight.Floor 6", "Display Terracotta phase timer", "Displays Terracotta phase timer", "bossfight.terracota", true, getFontRenderer().getStringWidth("Terracottas: 1m 99s"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(true); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("time", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - private static final List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Terracottas","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("1m 99s","time")); - } - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorSadan && - "fight-1".equalsIgnoreCase(skyblockStatus.getContext().getBossfightProcessor().getCurrentPhase()); - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("title", "separator", "number", "unit"); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public List getText() { - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Terracottas","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(TextUtils.formatTime((long) (BossStatus.healthScale * 1000 * 60 * 1.5)),"time")); - return actualBit; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java deleted file mode 100644 index 542beb6e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessorThorn; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureThornBearPercentage extends TextHUDFeature { - public FeatureThornBearPercentage() { - super("Bossfight.Floor 4", "Display Spirit Bear Summon Percentage", "Displays spirit bear summon percentage in hud", "bossfight.spiritbear", true, getFontRenderer().getStringWidth("Spirit Bear: 100%"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(true); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("unit", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - private static final java.util.List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Spirit Bear","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("50","number")); - dummyText.add(new StyledText("%","unit")); - } - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorThorn; - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("title", "separator", "number", "unit"); - } - - @Override - public java.util.List getDummyText() { - return dummyText; - } - - @Override - public java.util.List getText() { - int percentage = (int) (((BossfightProcessorThorn) skyblockStatus.getContext().getBossfightProcessor()).calculatePercentage() * 100); - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Spirit Bear","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(percentage+"","number")); - actualBit.add(new StyledText("%","unit")); - return actualBit; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornSpiritBowTimer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornSpiritBowTimer.java deleted file mode 100644 index 094600cb..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornSpiritBowTimer.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.TickListener; -import kr.syeyoung.dungeonsguide.features.listener.TitleListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessorThorn; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.network.play.server.S45PacketTitle; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureThornSpiritBowTimer extends TextHUDFeature implements ChatListener, TitleListener { - public FeatureThornSpiritBowTimer() { - super("Bossfight.Floor 4", "Display Spirit bow timer", "Displays how long until spirit bow gets destroyed", "bossfight.spiritbowdisplay", false, getFontRenderer().getStringWidth("Spirit Bow Destruction: 2m 00s"), getFontRenderer().FONT_HEIGHT); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("time", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - private static final List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Spirit Bow Destruction","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("1s","time")); - } - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorThorn && time > System.currentTimeMillis(); - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("title", "separator", "time"); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public List getText() { - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Spirit Bow Destruction","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(TextUtils.formatTime(time - System.currentTimeMillis()),"time")); - return actualBit; - } - private long time = 0; - - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (!(skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorThorn)) return; - String text = clientChatReceivedEvent.message.getFormattedText(); - if (text.equals("ยงrยงaยงlThe ยงrยง5ยงlSpirit Bow ยงrยงaยงlhas dropped!ยงr")) { - time = System.currentTimeMillis() + 16000; - } else if (text.startsWith("ยงrยงc[BOSS] Thornยงrยงf: ")) { - if (text.contains("another wound") - || text.contains("My energy, it goes away") - || text.contains("dizzy") - || text.contains("a delicate feeling")) { - time = 0; - } - } else if (text.startsWith("ยงrยงb[CROWD]")) { - if (text.contains("That wasn't fair!!!") || text.contains("how to damage") || text.contains("Cheaters!") || text.contains("BOOOO")) { - time = 0; - } else if (text.contains("missing easy shots like that") || text.contains("missed the shot!") || text.contains("Keep dodging") || text.contains("no thumbs") || text.contains("can't aim")) { - time = 0; - } - } else if (text.equals("ยงrยงcThe ยงrยง5Spirit Bowยงrยงc disintegrates as you fire off the shot!ยงr")) { - time = 0; - } - } - - @Override - public void onTitle(S45PacketTitle renderPlayerEvent) { - if (!(skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getBossfightProcessor() instanceof BossfightProcessorThorn)) return; - if (renderPlayerEvent.getMessage().getFormattedText().contains("picked up")) { - time = System.currentTimeMillis() + 21000; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java deleted file mode 100644 index 1ee76e91..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss; - -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.impl.dungeon.FeatureDungeonScore; -import kr.syeyoung.dungeonsguide.features.text.*; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.util.*; - -public class FeatureWarningOnPortal extends SimpleFeature implements StyledTextProvider { - public FeatureWarningOnPortal() { - super("Dungeon.Blood Room", "Score Warning on Watcher portal", "Display warnings such as\n- 'NOT ALL ROOMS DISCOVERED'\n- 'NOT ALL ROOMS COMPLETED'\n- 'Expected Score: 304'\n- 'MISSING 3 CRYPTS'\non portal", "bossfight.warningonportal"); - this.parameters.put("textStyles", new FeatureParameter>("textStyles", "", "", new ArrayList(), "list_textStyle")); - getStyles().add(new TextStyle("warning", new AColor(255, 0,0,255), new AColor(255, 255,255,255), false)); - getStyles().add(new TextStyle("field_name", new AColor(255, 72,255,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("field_separator", new AColor(204, 204,204,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("field_value", new AColor(255, 255,0,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("field_etc", new AColor(204, 204,204,255), new AColor(0, 0,0,0), false)); - } - - - private static final List dummyText = new ArrayList(); - static { - dummyText.add(new StyledText("!!!WARNING!!! <- text changes in boss-room\n", "warning")); - - dummyText.add(new StyledText("Total Secrets","field_name")); - dummyText.add(new StyledText(": ","field_separator")); - dummyText.add(new StyledText("103/100 of 50","field_value")); - dummyText.add(new StyledText("(103% 41.2 Explorer)","field_etc")); - - - dummyText.add(new StyledText("Crypts","field_name")); - dummyText.add(new StyledText(": ","field_separator")); - dummyText.add(new StyledText("5/5\n","field_value")); - - - dummyText.add(new StyledText("Deaths","field_name")); - dummyText.add(new StyledText(": ","field_separator")); - dummyText.add(new StyledText("0\n","field_value")); - - dummyText.add(new StyledText("Score Estimate","field_name")); - dummyText.add(new StyledText(": ","field_separator")); - dummyText.add(new StyledText("1000 ","field_value")); - dummyText.add(new StyledText("(S++++)\n","field_etc")); - - - dummyText.add(new StyledText("Skill","field_name")); - dummyText.add(new StyledText(": ","field_separator")); - dummyText.add(new StyledText("100 ","field_value")); - dummyText.add(new StyledText("(0 Deaths: 0 pts)\n","field_etc")); - - dummyText.add(new StyledText("Explorer","field_name")); - dummyText.add(new StyledText(": ","field_separator")); - dummyText.add(new StyledText("100 ","field_value")); - dummyText.add(new StyledText("(100% + secrets)\n","field_etc")); - - dummyText.add(new StyledText("Time","field_name")); - dummyText.add(new StyledText(": ","field_separator")); - dummyText.add(new StyledText("100 ","field_value")); - dummyText.add(new StyledText("(-30m 29s)\n","field_etc")); - - dummyText.add(new StyledText("Bonus","field_name")); - dummyText.add(new StyledText(": ","field_separator")); - dummyText.add(new StyledText("5\n","field_value")); - } - @Override - public List getDummyText() { - return dummyText; - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public List getText() { - ArrayList texts = new ArrayList(); - DungeonContext context = skyblockStatus.getContext(); - FeatureDungeonScore.ScoreCalculation scoreCalculation = FeatureRegistry.DUNGEON_SCORE.calculateScore(); - - boolean failed = context.getDungeonRoomList().stream().anyMatch(a -> a.getCurrentState() == DungeonRoom.RoomState.FAILED); - if (context.getMapProcessor().getUndiscoveredRoom() > 0) { - texts.add(new StyledText("There are at least "+context.getMapProcessor().getUndiscoveredRoom()+" undiscovered rooms!\n", "warning")); - } else if (failed) { - texts.add(new StyledText("There is a failed puzzle room! Yikes!\n", "warning")); - } else if (!scoreCalculation.isFullyCleared()) { - texts.add(new StyledText("Some rooms are not fully cleared!\n", "warning")); - } else if (scoreCalculation.getTombs() < 5) { - texts.add(new StyledText("Only less than 5 crypts are blown up!\n", "warning")); - } else { - texts.add(new StyledText("\n", "warning")); - } - - texts.add(new StyledText("Total Secrets","field_name")); - texts.add(new StyledText(": ","field_separator")); - texts.add(new StyledText(scoreCalculation.getSecrets() +"/" + scoreCalculation.getEffectiveTotalSecrets()+" of "+scoreCalculation.getTotalSecrets(),"field_value")); - texts.add(new StyledText(" ("+(int)(scoreCalculation.getSecrets() / (float)scoreCalculation.getEffectiveTotalSecrets() * 100.0f)+"% "+(int)Math.ceil(scoreCalculation.getSecrets() / (float)scoreCalculation.getEffectiveTotalSecrets() * 40.0f)+" Explorer)\n","field_etc")); - - - texts.add(new StyledText("Crypts","field_name")); - texts.add(new StyledText(": ","field_separator")); - texts.add(new StyledText(scoreCalculation.getTombs() +"/5\n","field_value")); - - - texts.add(new StyledText("Deaths","field_name")); - texts.add(new StyledText(": ","field_separator")); - texts.add(new StyledText(scoreCalculation.getDeaths() + "\n","field_value")); - - int sum = scoreCalculation.getTime() + scoreCalculation.getExplorer() + scoreCalculation.getSkill() + scoreCalculation.getBonus(); - texts.add(new StyledText("Score Estimate","field_name")); - texts.add(new StyledText(": ","field_separator")); - texts.add(new StyledText(sum+" ","field_value")); - texts.add(new StyledText("("+FeatureRegistry.DUNGEON_SCORE.getLetter(sum)+")\n","field_etc")); - - - texts.add(new StyledText("Skill","field_name")); - texts.add(new StyledText(": ","field_separator")); - texts.add(new StyledText(scoreCalculation.getSkill()+" ","field_value")); - texts.add(new StyledText("("+scoreCalculation.getDeaths()+" Deaths: "+(scoreCalculation.getDeaths() * -2)+" pts)\n","field_etc")); - - texts.add(new StyledText("Explorer","field_name")); - texts.add(new StyledText(": ","field_separator")); - texts.add(new StyledText(scoreCalculation.getExplorer()+" ","field_value")); - texts.add(new StyledText("("+FeatureRegistry.DUNGEON_SCORE.getPercentage()+"% + secrets)\n","field_etc")); - - texts.add(new StyledText("Time","field_name")); - texts.add(new StyledText(": ","field_separator")); - texts.add(new StyledText(scoreCalculation.getTime()+" ","field_value")); - texts.add(new StyledText("("+ TextUtils.formatTime(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed())+")\n","field_etc")); - - texts.add(new StyledText("Bonus","field_name")); - texts.add(new StyledText(": ","field_separator")); - texts.add(new StyledText(scoreCalculation.getBonus()+"\n","field_value")); - - - return texts; - } - - public List getStyles() { - return this.>getParameter("textStyles").getValue(); - } - private Map stylesMap; - public Map getStylesMap() { - if (stylesMap == null) { - List styles = getStyles(); - Map res = new HashMap(); - for (TextStyle ts : styles) { - res.put(ts.getGroupName(), ts); - } - stylesMap = res; - } - return stylesMap; - } - - - @Override - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { - @Override - public MPanel get() { - MFeatureEdit featureEdit = new MFeatureEdit(FeatureWarningOnPortal.this, rootConfigPanel); - featureEdit.addParameterEdit("textStyles", new PanelTextParameterConfig(FeatureWarningOnPortal.this)); - for (FeatureParameter parameter: getParameters()) { - if (parameter.getKey().equals("textStyles")) continue; - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureWarningOnPortal.this, parameter, rootConfigPanel)); - } - return featureEdit; - } - }); - return "base." + getKey() ; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java deleted file mode 100644 index 5c4106c6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import net.minecraft.init.Blocks; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.Slot; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.Item; - -import java.util.ArrayList; -import java.util.List; - -public class CorrectThePaneSolutionProvider implements TerminalSolutionProvider { - @Override - public TerminalSolution provideSolution(ContainerChest chest, List clicked) { - TerminalSolution ts = new TerminalSolution(); - ts.setCurrSlots(new ArrayList()); - for (Slot inventorySlot : chest.inventorySlots) { - if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; - if (inventorySlot.getHasStack() && inventorySlot.getStack() != null) { - if (inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - inventorySlot.getStack().getItemDamage() == EnumDyeColor.RED.getMetadata()) { - ts.getCurrSlots().add(inventorySlot); - } - } - } - - - return ts; - } - - @Override - public boolean isApplicable(ContainerChest chest) { - return chest.getLowerChestInventory().getName().equals("Correct all the panes!"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureSimonSaysSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureSimonSaysSolver.java deleted file mode 100644 index a13eafc2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureSimonSaysSolver.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.InteractListener; -import kr.syeyoung.dungeonsguide.features.listener.TickListener; -import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; -import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessorNecron; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.awt.*; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -public class FeatureSimonSaysSolver extends SimpleFeature implements WorldRenderListener, TickListener, InteractListener { - public FeatureSimonSaysSolver() { - super("Solver.Floor 7+.Bossfight","Simon Says Solver","Solver for Simon says puzzle", "bossfight.simonsays2"); - } - - private final SkyblockStatus ss = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private final List orderbuild = new ArrayList(); - private final LinkedList orderclick = new LinkedList(); - - @Override - public void drawWorld(float partialTicks) { - if (!isEnabled()) return; - DungeonContext dc = ss.getContext(); - if (dc == null) { - return; - } - if (!(dc.getBossfightProcessor() instanceof BossfightProcessorNecron)) return; - if (Minecraft.getMinecraft().thePlayer.getPosition().distanceSq(309,123,291) > 400) return; - - - if (orderclick.size() >= 1) - RenderUtils.highlightBlock(orderclick.get(0), new Color(0, 255 ,255, 100), partialTicks, false); - if (orderclick.size() >= 2) - RenderUtils.highlightBlock(orderclick.get(1), new Color(255, 170, 0, 100), partialTicks, false); - } - private boolean wasButton = false; - @Override - public void onTick() { - DungeonContext dc = ss.getContext(); - if (dc == null) { - wasButton = false; - return; - } - if (!(dc.getBossfightProcessor() instanceof BossfightProcessorNecron)) return; - - World w = dc.getWorld(); - - if (wasButton && w.getBlockState(new BlockPos(309, 123, 291)).getBlock() == Blocks.air) { - orderclick.clear(); - orderbuild.clear(); - wasButton = false; - } else if (!wasButton && w.getBlockState(new BlockPos(309, 123, 291)).getBlock() == Blocks.stone_button){ - orderclick.addAll(orderbuild); - wasButton = true; - } - - - if (!wasButton) { - for (BlockPos allInBox : BlockPos.getAllInBox(new BlockPos(310, 123, 291), new BlockPos(310, 120, 294))) { - if (w.getBlockState(allInBox).getBlock() == Blocks.sea_lantern && !orderbuild.contains(allInBox)) { - orderbuild.add(allInBox); - } - } - } - } - - @Override - public void onInteract(PlayerInteractEvent event) { - if (!isEnabled()) return; - - DungeonContext dc = ss.getContext(); - if (dc == null) return; - if (!(dc.getBossfightProcessor() instanceof BossfightProcessorNecron)) return; - if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return; - World w = dc.getWorld(); - - BlockPos pos = event.pos.add(1,0,0); - if (120 <= pos.getY() && pos.getY() <= 123 && pos.getX() == 310 && 291 <= pos.getZ() && pos.getZ() <= 294) { - if (w.getBlockState(event.pos).getBlock() != Blocks.stone_button) return; - if (pos.equals(orderclick.peek())) { - orderclick.poll(); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureTerminalSolvers.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureTerminalSolvers.java deleted file mode 100644 index 749f1e2a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureTerminalSolvers.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.*; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.Slot; -import net.minecraftforge.client.event.GuiOpenEvent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import org.lwjgl.input.Mouse; - -import java.util.ArrayList; -import java.util.List; - -public class FeatureTerminalSolvers extends SimpleFeature implements GuiOpenListener, TickListener, GuiPostRenderListener, GuiClickListener, TooltipListener { - public FeatureTerminalSolvers() { - super("Solver.Floor 7+.Bossfight","F7 GUI Terminal Solver", "Solve f7 gui terminals. (color, startswith, order, navigate, correct panes)", "bossfight.terminals"); - } - - public static final List solutionProviders = new ArrayList(); - - static { - solutionProviders.add(new WhatStartsWithSolutionProvider()); - solutionProviders.add(new SelectAllColorSolutionProivider()); - solutionProviders.add(new SelectInOrderSolutionProvider()); - solutionProviders.add(new NavigateMazeSolutionProvider()); - solutionProviders.add(new CorrectThePaneSolutionProvider()); - } - - private TerminalSolutionProvider solutionProvider; - private TerminalSolution solution; - private final List clicked = new ArrayList(); - - @Override - public void onGuiOpen(GuiOpenEvent event) { - if (!isEnabled()) return; - solution = null; - solutionProvider = null; - clicked.clear(); - if (event.gui instanceof GuiChest) { - ContainerChest cc = (ContainerChest) ((GuiChest) event.gui).inventorySlots; - for (TerminalSolutionProvider solutionProvider : solutionProviders) { - if (solutionProvider.isApplicable(cc)) { - solution = solutionProvider.provideSolution(cc, clicked); - this.solutionProvider = solutionProvider; - } - } - } - } - - @Override - public void onTick() { - if (!isEnabled()) return; - if (solutionProvider == null) return; - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { - solution = null; - solutionProvider = null; - clicked.clear(); - return; - } - ContainerChest cc = (ContainerChest) ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots; - - solution = solutionProvider.provideSolution(cc, clicked); - } - - @Override - public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { - if (!isEnabled()) return; - if (solutionProvider == null) return; - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { - solution = null; - solutionProvider = null; - clicked.clear(); - return; - } - - if (solution != null) { - int i = 222; - int j = i - 108; - int ySize = j + (((ContainerChest)(((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots)).getLowerChestInventory().getSizeInventory() / 9) * 18; - int left = (rendered.gui.width - 176) / 2; - int top = (rendered.gui.height - ySize ) / 2; - GlStateManager.pushMatrix(); - GlStateManager.disableDepth(); - GlStateManager.disableLighting(); - GlStateManager.colorMask(true, true, true, false); - GlStateManager.translate(left, top, 0); - if (solution.getCurrSlots() != null) { - for (Slot currSlot : solution.getCurrSlots()) { - int x = currSlot.xDisplayPosition; - int y = currSlot.yDisplayPosition; - Gui.drawRect(x, y, x + 16, y + 16, 0x7700FFFF); - } - } - if (solution.getNextSlots() != null) { - for (Slot nextSlot : solution.getNextSlots()) { - int x = nextSlot.xDisplayPosition; - int y = nextSlot.yDisplayPosition; - Gui.drawRect(x, y, x + 16, y + 16, 0x77FFFF00); - } - } - GlStateManager.colorMask(true, true, true, true); - GlStateManager.popMatrix(); - } - GlStateManager.enableBlend(); - GlStateManager.enableLighting(); - } - - @Override - public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { - if (!isEnabled()) return; - if (Mouse.getEventButton() == -1) return; - if (solutionProvider == null) return; - if (solution == null) return; - if (solution.getCurrSlots() == null) { - return; - } - Slot s = ((GuiChest) Minecraft.getMinecraft().currentScreen).getSlotUnderMouse(); - if (solution.getCurrSlots().contains(s)) { - clicked.add(s); - return; - } - } - - @Override - public void onTooltip(ItemTooltipEvent event) { - if (!isEnabled()) return; - if (solutionProvider == null) return; - event.toolTip.clear(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/NavigateMazeSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/NavigateMazeSolutionProvider.java deleted file mode 100644 index f46442d6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/NavigateMazeSolutionProvider.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import net.minecraft.init.Blocks; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.Slot; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.Item; - -import java.util.ArrayList; -import java.util.List; - -public class NavigateMazeSolutionProvider implements TerminalSolutionProvider { - @Override - public TerminalSolution provideSolution(ContainerChest chest, List clicked) { - TerminalSolution ts = new TerminalSolution(); - ts.setCurrSlots(new ArrayList()); - Slot solution = null; - for (Slot inventorySlot : chest.inventorySlots) { - if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; - if (inventorySlot.getHasStack() && inventorySlot.getStack() != null) { - if (inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - inventorySlot.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { - int x = inventorySlot.slotNumber % 9; - int y = inventorySlot.slotNumber / 9; - - if (x > 0) { - Slot toChk = chest.inventorySlots.get(y * 9 + x - 1); - - if (toChk.getHasStack() && toChk.getStack() != null && - toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { - solution = inventorySlot; - break; - } - } - if (x < 8) { - Slot toChk = chest.inventorySlots.get(y * 9 + x + 1); - - if (toChk.getHasStack() && toChk.getStack() != null && - toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { - solution = inventorySlot; - break; - } - } - if (y > 0) { - Slot toChk = chest.inventorySlots.get((y-1) * 9 + x); - - if (toChk.getHasStack() && toChk.getStack() != null && - toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { - solution = inventorySlot; - break; - } - } - if (y < chest.getLowerChestInventory().getSizeInventory() / 9 - 1) { - Slot toChk = chest.inventorySlots.get((y+1) * 9 + x); - - if (toChk.getHasStack() && toChk.getStack() != null && - toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { - solution = inventorySlot; - break; - } - } - } - } - } - - if (solution == null) return null; - ts.getCurrSlots().add(solution); - ts.setNextSlots(new ArrayList()); - { - int x = solution.slotNumber % 9; - int y = solution.slotNumber / 9; - - if (x > 0) { - Slot toChk = chest.inventorySlots.get(y * 9 + x - 1); - - if (toChk.getHasStack() && toChk.getStack() != null && - toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { - ts.getNextSlots().add(toChk); - return ts; - } - } - if (x < 8) { - Slot toChk = chest.inventorySlots.get(y * 9 + x + 1); - - if (toChk.getHasStack() && toChk.getStack() != null && - toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { - ts.getNextSlots().add(toChk); - return ts; - } - } - if (y > 0) { - Slot toChk = chest.inventorySlots.get((y-1) * 9 + x); - - if (toChk.getHasStack() && toChk.getStack() != null && - toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { - ts.getNextSlots().add(toChk); - return ts; - } - } - if (y < chest.getLowerChestInventory().getSizeInventory() / 9 - 1) { - Slot toChk = chest.inventorySlots.get((y+1) * 9 + x); - - if (toChk.getHasStack() && toChk.getStack() != null && - toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && - toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { - ts.getNextSlots().add(toChk); - return ts; - } - } - } - - return ts; - } - - @Override - public boolean isApplicable(ContainerChest chest) { - return chest.getLowerChestInventory().getName().equals("Navigate the maze!"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectAllColorSolutionProivider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectAllColorSolutionProivider.java deleted file mode 100644 index 230383fe..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectAllColorSolutionProivider.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import net.minecraft.init.Items; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.Slot; -import net.minecraft.item.EnumDyeColor; - -import java.util.ArrayList; -import java.util.List; - -public class SelectAllColorSolutionProivider implements TerminalSolutionProvider { - @Override - public TerminalSolution provideSolution(ContainerChest chest, List clicked) { - TerminalSolution ts = new TerminalSolution(); - ts.setCurrSlots(new ArrayList()); - String name = chest.getLowerChestInventory().getName(); - EnumDyeColor edc = null; - for (EnumDyeColor edc2 : EnumDyeColor.values()) { - if (name.contains(edc2.getName().toUpperCase().replace("_"," "))) { - edc = edc2; - break; - } - } - if (edc == null) return null; - - for (Slot inventorySlot : chest.inventorySlots) { - if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; - if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && !inventorySlot.getStack().isItemEnchanted()) { - if (inventorySlot.getStack().getItem() != Items.dye && inventorySlot.getStack().getItemDamage() == edc.getMetadata()) - ts.getCurrSlots().add(inventorySlot); - else if (inventorySlot.getStack().getItem() == Items.dye && inventorySlot.getStack().getItemDamage() == edc.getDyeDamage()) - ts.getCurrSlots().add(inventorySlot); - } - } - return ts; - } - - @Override - public boolean isApplicable(ContainerChest chest) { - return chest.getLowerChestInventory().getName().startsWith("Select all the "); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectInOrderSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectInOrderSolutionProvider.java deleted file mode 100644 index b04a7726..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectInOrderSolutionProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import net.minecraft.init.Blocks; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.Slot; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.Item; - -import java.util.ArrayList; -import java.util.List; - -public class SelectInOrderSolutionProvider implements TerminalSolutionProvider { - @Override - public TerminalSolution provideSolution(ContainerChest chest, List clicked) { - TerminalSolution ts = new TerminalSolution(); - ts.setCurrSlots(new ArrayList()); - int lowest = 1000; - Slot slotLowest = null; - for (Slot inventorySlot : chest.inventorySlots) { - if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; - if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) - && inventorySlot.getStack().getItemDamage() == EnumDyeColor.RED.getMetadata()) { - if (inventorySlot.getStack().stackSize < lowest) { - lowest = inventorySlot.getStack().stackSize; - slotLowest = inventorySlot; - } - } - } - if (slotLowest != null) - ts.getCurrSlots().add(slotLowest); - - Slot next = null; - for (Slot inventorySlot : chest.inventorySlots) { - if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; - if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) - && inventorySlot.getStack().getItemDamage() == EnumDyeColor.RED.getMetadata()) { - if (inventorySlot.getStack().stackSize == lowest + 1) { - next = inventorySlot; - } - } - } - if (next != null) { - ts.setNextSlots(new ArrayList()); - ts.getNextSlots().add(next); - } - - return ts; - } - - @Override - public boolean isApplicable(ContainerChest chest) { - return chest.getLowerChestInventory().getName().equals("Click in order!"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolution.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolution.java deleted file mode 100644 index e8b0c9a4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolution.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import lombok.Data; -import net.minecraft.inventory.Slot; - -import java.util.List; - -@Data -public class TerminalSolution { - private List currSlots; - private List nextSlots; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolutionProvider.java deleted file mode 100644 index 4c7b3d02..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolutionProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.Slot; - -import java.util.List; - -public interface TerminalSolutionProvider { - TerminalSolution provideSolution(ContainerChest chest, List clicked); - boolean isApplicable(ContainerChest chest); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java deleted file mode 100644 index 758360fe..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; - -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.Slot; -import org.apache.logging.log4j.core.appender.db.jpa.converter.ThrowableAttributeConverter; - -import java.util.ArrayList; -import java.util.List; - -public class WhatStartsWithSolutionProvider implements TerminalSolutionProvider{ - @Override - public TerminalSolution provideSolution(ContainerChest chest, List clicked) { - String that = chest.getLowerChestInventory().getName().replace("What starts with: '", "").replace("'?", "").trim().toLowerCase(); - - TerminalSolution ts = new TerminalSolution(); - ts.setCurrSlots(new ArrayList()); - for (Slot inventorySlot : chest.inventorySlots) { - if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; - if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && !inventorySlot.getStack().isItemEnchanted() ) { - String name = TextUtils.stripColor(inventorySlot.getStack().getDisplayName()).toLowerCase(); - if (name.startsWith(that)) - ts.getCurrSlots().add(inventorySlot); - } - } - return ts; - } - - @Override - public boolean isApplicable(ContainerChest chest) { - return chest.getLowerChestInventory().getName().startsWith("What starts with: '"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknameColor.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknameColor.java deleted file mode 100644 index 89d80ca5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknameColor.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.cosmetics; - -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeatureNicknameColor extends SimpleFeature { - public FeatureNicknameColor() { - super("Cosmetics", "Nickname Color", "Click on Edit to choose nickname color cosmetic", "cosmetic.nickname"); - this.parameters.put("dummy", new FeatureParameter("dummy", "dummy", "dummy", "dummy", "string")); - } - - @Override - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , () -> new PrefixSelectorGUI("color", new String[] { - "ยง9Party ยง8> ยงrยงa[RANKยง6+ยงa] %prefix%%name%ยงf: TEST", - "ยง2Guild > ยงrยงa[RANKยง6+ยงa] %prefix%%name% ยง3[Vet]ยงf: TEST", - "ยงdTo ยงrยงrยงa[RANKยงrยง6+ยงrยงa] %prefix%%name%ยงrยง7: ยงrยง7TESTยงr", - "ยงdFrom ยงrยงrยงa[RANKยงrยง6+ยงrยงa] %prefix%%name%ยงrยง7: ยงrยง7TESTยงr", - "ยงrยงb[RANKยงc+ยงb] %prefix%%name%ยงf: TEST", - "ยงrยงbCo-op > ยงrยงa[RANKยง6+ยงa] %prefix%%name%ยงf: ยงrTESTยงr" - }, a -> (a.replace("&", "ยง")+"Color "+(a.replace("&", "ยง").equals("ยงz") ? "(Rainbow on sba)" : "")))); - return "base." + getKey(); - } - - @Override - public boolean isDisyllable() { - return false; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknamePrefix.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknamePrefix.java deleted file mode 100644 index 78a9c1c8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/FeatureNicknamePrefix.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.cosmetics; - -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeatureNicknamePrefix extends SimpleFeature { - public FeatureNicknamePrefix() { - super("Cosmetics", "Nickname Prefix", "Click on Edit to choose prefix cosmetic", "cosmetic.prefix"); - this.parameters.put("dummy", new FeatureParameter("dummy", "dummy", "dummy", "dummy", "string")); - } - - @Override - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , () -> new PrefixSelectorGUI("prefix", new String[] { - "ยง9Party ยง8> ยงr%prefix% ยงa[RANKยง6+ยงa] %name%ยงf: TEST", - "ยง2Guild > ยงr%prefix% ยงa[RANKยง6+ยงa] %name% ยง3[Vet]ยงf: TEST", - "ยงdTo ยงr%prefix% ยงrยงa[RANKยงrยง6+ยงrยงa] %name%ยงrยง7: ยงrยง7TESTยงr", - "ยงdFrom ยงr%prefix% ยงrยงa[RANKยงrยง6+ยงrยงa] %name%ยงrยง7: ยงrยง7TESTยงr", - "ยงr%prefix% ยงb[RANKยงc+ยงb] %name%ยงf: TEST", - "ยงrยงbCo-op > ยงr%prefix% ยงa[RANKยง6+ยงa] %name%ยงf: ยงrTESTยงr" - }, a->a.replace("&", "ยง"))); - return "base." + getKey(); - } - - @Override - public boolean isDisyllable() { - return false; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/PrefixSelectorGUI.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/PrefixSelectorGUI.java deleted file mode 100644 index 4750831e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/cosmetics/PrefixSelectorGUI.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.cosmetics; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.*; -import java.util.List; -import java.util.function.Function; - -public class PrefixSelectorGUI extends MPanel { - private String cosmeticType; - private Function optionTransformer; - - public PrefixSelectorGUI(String cosmeticType, String[] previews, Function optionTransformer) { - this.cosmeticType = cosmeticType; - this.previews = previews; - this.optionTransformer = optionTransformer; - CosmeticsManager cosmeticsManager = DungeonsGuide.getDungeonsGuide().getCosmeticsManager(); - List activeCosmeticList = cosmeticsManager.getActiveCosmeticByPlayer().computeIfAbsent(Minecraft.getMinecraft().thePlayer.getGameProfile().getId(), (a) -> new ArrayList<>()); - for (ActiveCosmetic activeCosmetic : activeCosmeticList) { - CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData != null && cosmeticData.getCosmeticType().equals(cosmeticType)) { - selected = cosmeticData; - return; - } - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - private CosmeticData selected; - // ยง9Party ยง8> ยงa[VIPยง6+ยงa] syeyoungยงf: ty - // ยง2Guild > ยงa[VIPยง6+ยงa] syeyoung ยง3[Vet]ยงf - // ยงdTo ยงrยงa[VIPยงrยง6+ยงrยงa] SlashSlayerยงrยง7: ยงrยง7whatยงr - // ยงdFrom ยงrยงa[VIPยงrยง6+ยงrยงa] SlashSlayerยงrยง7: ยงrยง7?ยงr - // ยง7Rock_Birdยง7ยงrยง7: SELLING 30 DIAMOD BLOCK /p meยงr - // ยงb[MVPยงc+ยงb] Probutnoobgamerยงf: quitting skyblock! highe - // ยงrยงbCo-op > ยงa[VIPยง6+ยงa] syeyoungยงf: ยงrwhatยงr - String[] previews; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - CosmeticsManager cosmeticsManager = DungeonsGuide.getDungeonsGuide().getCosmeticsManager(); - - List activeCosmeticList2 = cosmeticsManager.getActiveCosmeticByPlayer().get(Minecraft.getMinecraft().thePlayer.getGameProfile().getId()); - Set activeCosmeticList = new HashSet<>(); - if (activeCosmeticList2 !=null) { - for (ActiveCosmetic activeCosmetic : activeCosmeticList2) { - activeCosmeticList.add(activeCosmetic.getCosmeticData()); - } - } - - - - GlStateManager.translate(0,2,0); - Gui.drawRect(0,0,getBounds().width, getBounds().height-2, 0xFF444444); - Gui.drawRect(5,5,265, getBounds().height-7, 0xFF222222); - Gui.drawRect(6,17,264, getBounds().height-8, 0xFF555555); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Preview", (270 - fr.getStringWidth("Preview")) / 2, 7, 0xFFFFFFFF); - - { - String prefix = selected != null ? selected.getData() : "[DG]"; - GlStateManager.pushMatrix(); - GlStateManager.translate(6,17,0); - for (int i = 0; i < previews.length; i++) { - fr.drawString(previews[i].replace("%name%", Minecraft.getMinecraft().getSession().getUsername()).replace("%prefix%", prefix.replace("&", "ยง")), 0, i*fr.FONT_HEIGHT, -1); - } - GlStateManager.popMatrix(); - } - { - GlStateManager.pushMatrix(); - GlStateManager.translate(270,17,0); - int relX = relMousex0 - 270, relY = relMousey0 - 19; - int cnt = 0; - for (CosmeticData value : cosmeticsManager.getCosmeticDataMap().values()) { - if (value.getCosmeticType().equals(cosmeticType)) { - if (!cosmeticsManager.getPerms().contains(value.getReqPerm()) && value.getReqPerm().startsWith("invis_")) continue; - Gui.drawRect(0,0,220, fr.FONT_HEIGHT+3, 0xFF222222); - Gui.drawRect(1,1, 219, fr.FONT_HEIGHT+2, 0xFF555555); - Gui.drawRect(120,1,160, fr.FONT_HEIGHT+2, new Rectangle(120,cnt * (fr.FONT_HEIGHT+4) + 2,40,fr.FONT_HEIGHT+1).contains(relX, relY) ? 0xFF859DF0 : 0xFF7289da); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(optionTransformer.apply(value.getData()), 2, 2, -1); - fr.drawString("TEST", (280-fr.getStringWidth("TEST"))/2, 2, -1); - - if (cosmeticsManager.getPerms().contains(value.getReqPerm())) { - Gui.drawRect(161,1,219, fr.FONT_HEIGHT+2, new Rectangle(161,cnt * (fr.FONT_HEIGHT+4) + 2,58,fr.FONT_HEIGHT+1).contains(relX, relY) ? 0xFF859DF0 : 0xFF7289da); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (activeCosmeticList.contains(value.getId())) { - fr.drawString("UNSELECT", (381 - fr.getStringWidth("UNSELECT")) / 2, 2, -1); - } else { - fr.drawString("SELECT", (381 - fr.getStringWidth("SELECT")) / 2, 2, -1); - } - } else { - Gui.drawRect(161,1,219, fr.FONT_HEIGHT+2, 0xFFFF3333); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Locked", (381 - fr.getStringWidth("Locked")) / 2, 2, -1); - } - GlStateManager.translate(0,fr.FONT_HEIGHT+4, 0); - - cnt++; - } - } - GlStateManager.popMatrix(); - } - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - CosmeticsManager cosmeticsManager = DungeonsGuide.getDungeonsGuide().getCosmeticsManager(); - - int relX = relMouseX - 270, relY = relMouseY - 19; - int cnt = 0; - - List activeCosmeticList = cosmeticsManager.getActiveCosmeticByPlayer().computeIfAbsent(Minecraft.getMinecraft().thePlayer.getGameProfile().getId(), (a) -> new ArrayList<>()); - - for (CosmeticData value : cosmeticsManager.getCosmeticDataMap().values()) { - if (value.getCosmeticType().equals(cosmeticType)) { - if (!cosmeticsManager.getPerms().contains(value.getReqPerm()) && value.getReqPerm().startsWith("invis_")) continue; - if (new Rectangle(120,cnt * (fr.FONT_HEIGHT+4) + 2,40,fr.FONT_HEIGHT+1).contains(relX, relY)) { - selected = value; - return; - } - try { - if (new Rectangle(161, cnt * (fr.FONT_HEIGHT + 4) + 2, 58, fr.FONT_HEIGHT + 1).contains(relX, relY) && cosmeticsManager.getPerms().contains(value.getReqPerm())) { - for (ActiveCosmetic activeCosmetic : activeCosmeticList) { - if (activeCosmetic.getCosmeticData().equals(value.getId())) { - cosmeticsManager.removeCosmetic(activeCosmetic); - return; - } - } - cosmeticsManager.setCosmetic(value); - selected = value; - } - } catch (Exception e) { - e.printStackTrace(); - } - - cnt++; - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/ImageTexture.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/ImageTexture.java deleted file mode 100644 index 62ee2913..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/ImageTexture.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.discord.inviteViewer; - - -import lombok.Data; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.ResourceLocation; - -import javax.imageio.ImageIO; -import javax.imageio.ImageReader; -import javax.imageio.stream.ImageInputStream; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Iterator; - -@Data -public class ImageTexture { - private String url; - private BufferedImage image; - private DynamicTexture previewTexture; - private ResourceLocation resourceLocation; - - private int width; - private int height; - private int frames; - private int size; - - @Getter @Setter - private int lastFrame = 0; - - public void buildGLThings() { - previewTexture = new DynamicTexture(image); - resourceLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("dgurl/"+url, previewTexture); - } - - public ImageTexture(String url) throws IOException { - this.url = url; - - URL urlObj = new URL(url); - HttpURLConnection huc = (HttpURLConnection) urlObj.openConnection(); - huc.addRequestProperty("User-Agent", "DungeonsGuideMod (dungeons.guide, 1.0)"); - ImageInputStream imageInputStream = ImageIO.createImageInputStream(huc.getInputStream()); - Iterator readers = ImageIO.getImageReaders(imageInputStream); - if(!readers.hasNext()) throw new IOException("No image reader what" + url); - ImageReader reader = readers.next(); - reader.setInput(imageInputStream); - frames = reader.getNumImages(true); - BufferedImage dummyFrame = reader.read(0); - width = dummyFrame.getWidth(); height = dummyFrame.getHeight(); - - - image = new BufferedImage(width, height * frames, dummyFrame.getType()); - Graphics2D graphics2D = image.createGraphics(); - - for (int i = 0; i < frames; i++) { - BufferedImage bufferedImage = reader.read(i); - graphics2D.drawImage(bufferedImage, 0, i*height, null); - } - reader.dispose(); imageInputStream.close(); huc.disconnect(); - } - - public void drawFrame(int frame, int x, int y, int width, int height) { - if (getResourceLocation() == null) - buildGLThings(); - - TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); - textureManager.bindTexture(getResourceLocation()); - - GlStateManager.color(1, 1, 1, 1.0F); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos((double)x, (double)(y + height), 0.0D) - .tex(0,((frame+1) * height)/ ((double)frames * height)).endVertex(); - worldrenderer.pos((double)(x + width), (double)(y + height), 0.0D) - .tex(1, ((frame+1) * height)/ ((double)frames * height)).endVertex(); - worldrenderer.pos((double)(x + width), (double)y, 0.0D) - .tex(1,(frame * height)/ ((double)frames * height)).endVertex(); - worldrenderer.pos((double)x, (double)y, 0.0D) - .tex(0, (frame * height) / ((double)frames * height)).endVertex(); - tessellator.draw(); - } - - public void drawFrameAndIncrement(int x, int y, int width, int height) { - drawFrame(lastFrame, x,y,width,height); - lastFrame++; - if (lastFrame >= frames) lastFrame = 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/PartyInviteViewer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/PartyInviteViewer.java deleted file mode 100644 index 551659d2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/PartyInviteViewer.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.discord.inviteViewer; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.events.DiscordUserJoinRequestEvent; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.*; -import kr.syeyoung.dungeonsguide.rpc.RichPresenceManager; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityJoinRequestReply; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraftforge.client.event.GuiScreenEvent; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.*; -import java.util.List; -import java.util.concurrent.*; - -public class PartyInviteViewer extends SimpleFeature implements GuiPostRenderListener, ScreenRenderListener, TickListener, GuiClickListener, DiscordUserJoinRequestListener { - public PartyInviteViewer() { - super("Discord", "Party Invite Viewer","Simply type /dg asktojoin or /dg atj to toggle whether ask-to-join would be presented as option on discord!\n\nRequires Discord RPC to be enabled", "discord.party_invite_viewer"); - } - - @Override - public boolean isDisyllable() { - return false; - } - - @Override - public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { - renderRequests(true); - } - - @Override - public void drawScreen(float partialTicks) { - if (!isEnabled()) return; - try { - renderRequests(false); - } catch (Throwable t) { - t.printStackTrace(); - } - } - @Override - public void onTick() { - try { - List partyJoinRequestList = new ArrayList<>(); - boolean isOnHypixel = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnHypixel(); - for (PartyJoinRequest joinRequest:joinRequests) { - if (joinRequest.getTtl() != -1) { - joinRequest.setTtl(joinRequest.getTtl() - 1); - if (joinRequest.getTtl() == 0 || !isOnHypixel) { - partyJoinRequestList.add(joinRequest); - } - } else if (!isOnHypixel){ -// DiscordRPC.discordRespond(joinRequest.getDiscordUser().userId, DiscordRPC.DiscordReply.NO); - partyJoinRequestList.add(joinRequest); - } else if (joinRequest.getExpire() < System.currentTimeMillis()) { - partyJoinRequestList.add(joinRequest); - } - } - joinRequests.removeAll(partyJoinRequestList); - } catch (Throwable e) {e.printStackTrace();} - } - - - @Override - public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { - if (!isEnabled()) return; - int mouseX = Mouse.getX(); - int mouseY = Minecraft.getMinecraft().displayHeight - Mouse.getY() +3; - for (PartyJoinRequest joinRequest:joinRequests) { - if (joinRequest.getWholeRect() != null && joinRequest.getWholeRect().contains(mouseX, mouseY)) { - mouseInputEvent.setCanceled(true); - - if (Mouse.getEventButton() == -1) return; - - if (joinRequest.getReply() != null) { - joinRequests.remove(joinRequest); - return; - } - - if (!joinRequest.isInvite()) { - if (joinRequest.getAcceptRect().contains(mouseX, mouseY)) { - joinRequest.setReply(PartyJoinRequest.Reply.ACCEPT); - joinRequest.setTtl(60); - RichPresenceManager.INSTANCE.respond(joinRequest.getDiscordUser().id, EDiscordActivityJoinRequestReply.DiscordActivityJoinRequestReply_Yes); - return; - } - - if (joinRequest.getDenyRect().contains(mouseX, mouseY)) { - joinRequest.setReply(PartyJoinRequest.Reply.DENY); - joinRequest.setTtl(60); - RichPresenceManager.INSTANCE.respond(joinRequest.getDiscordUser().id, EDiscordActivityJoinRequestReply.DiscordActivityJoinRequestReply_No); - return; - } - - if (joinRequest.getIgnoreRect().contains(mouseX, mouseY)) { - joinRequest.setReply(PartyJoinRequest.Reply.IGNORE); - joinRequest.setTtl(60); - RichPresenceManager.INSTANCE.respond(joinRequest.getDiscordUser().id, EDiscordActivityJoinRequestReply.DiscordActivityJoinRequestReply_Ignore); - return; - } - } else { - if (joinRequest.getAcceptRect().contains(mouseX, mouseY)) { - joinRequest.setReply(PartyJoinRequest.Reply.ACCEPT); - joinRequest.setTtl(60); - RichPresenceManager.INSTANCE.accept(joinRequest.getDiscordUser().id); - return; - } - - if (joinRequest.getDenyRect().contains(mouseX, mouseY)) { - joinRequest.setReply(PartyJoinRequest.Reply.DENY); - joinRequest.setTtl(60); - return; - } - } - - return; - } - } - } - - - - public CopyOnWriteArrayList joinRequests = new CopyOnWriteArrayList<>(); - - ExecutorService executorService = Executors.newFixedThreadPool(3); - public Map> futureMap = new HashMap<>(); - public Map imageMap = new HashMap<>(); - - public Future loadImage(String url) { - if (imageMap.containsKey(url)) return CompletableFuture.completedFuture(imageMap.get(url)); - if (futureMap.containsKey(url)) return futureMap.get(url); - Future future = executorService.submit(() -> { - try { - ImageTexture imageTexture = new ImageTexture(url); - imageMap.put(url, imageTexture); - return imageTexture; - } catch (Exception e) { - throw e; - } - }); - futureMap.put(url,future); - return future; - } - - - public void renderRequests(boolean hover) { - try { - GlStateManager.pushMatrix(); - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - GlStateManager.scale(1.0 / sr.getScaleFactor(), 1.0 / sr.getScaleFactor(), 1.0); - int height = 90; - int gap = 5; - int x = 5; - int y = 5; - for (PartyJoinRequest partyJoinRequest : joinRequests) { - renderRequest(partyJoinRequest, x, y, 350,height, hover); - y += height + gap; - } - GlStateManager.popMatrix(); - GlStateManager.enableBlend(); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - - public void renderRequest(PartyJoinRequest partyJoinRequest, int x, int y, int width, int height, boolean hover) { - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - - int mouseX = Mouse.getX(); - int mouseY = Minecraft.getMinecraft().displayHeight - Mouse.getY() +3; - - partyJoinRequest.getWholeRect().setBounds(x,y,width,height); - - - GlStateManager.pushMatrix(); - GlStateManager.translate(x,y,0); - - Gui.drawRect(0, 0,width,height, 0xFF23272a); - Gui.drawRect(2, 2, width-2, height-2, 0XFF2c2f33); - { - String avatar = "https://cdn.discordapp.com/avatars/"+Long.toUnsignedString(partyJoinRequest.getDiscordUser().id.longValue())+"/"+partyJoinRequest.getAvatar()+"."+(partyJoinRequest.getAvatar().startsWith("a_") ? "gif":"png"); - Future loadedImageFuture = loadImage(avatar); - ImageTexture loadedImage = null; - if (loadedImageFuture.isDone()) { - try { - loadedImage = loadedImageFuture.get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - if (loadedImage != null) { - loadedImage.drawFrameAndIncrement( 7,7,height-14,height-14); - } else { - Gui.drawRect(7, 7, height - 7, height-7, 0xFF4E4E4E); - } - } - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.pushMatrix(); - GlStateManager.translate(height +3,7, 0); - - GlStateManager.pushMatrix(); - GlStateManager.scale(3.0,3.0,1.0); - fr.drawString(partyJoinRequest.getUsername()+"", 0,0, 0xFFFFFFFF, true); - GlStateManager.popMatrix(); - - GlStateManager.pushMatrix(); - GlStateManager.translate(fr.getStringWidth(partyJoinRequest.getUsername()+"") * 3 + 1, (int)(fr.FONT_HEIGHT*1.5), 0); - fr.drawString("#"+partyJoinRequest.getDiscriminator(), 0,0,0xFFaaaaaa, true); - GlStateManager.popMatrix(); - GlStateManager.pushMatrix(); - GlStateManager.translate(0, fr.FONT_HEIGHT * 3 + 5, 0); - GlStateManager.scale(1.0,1.0,1.0); - if (partyJoinRequest.isInvite()) - fr.drawString("ยงewants to you to join their party! ("+(TextUtils.formatTime(partyJoinRequest.getExpire() - System.currentTimeMillis()))+")", 0,0,0xFFFFFFFF,false); - else - fr.drawString("wants to join your party! ("+(TextUtils.formatTime(partyJoinRequest.getExpire() - System.currentTimeMillis()))+")", 0,0,0xFFFFFFFF,false); - GlStateManager.popMatrix(); - GlStateManager.popMatrix(); - if (partyJoinRequest.getReply() == null) { - GlStateManager.pushMatrix(); - GlStateManager.translate(height + 3, height - 32, 0); - int widthForTheThing = (width - height) / 3; - GlStateManager.pushMatrix(); - String text = "Accept"; - partyJoinRequest.getAcceptRect().setBounds(x + height + 3, y + height - 25, widthForTheThing - 10, 25); - Gui.drawRect(0, 0, widthForTheThing - 10, 25, hover && partyJoinRequest.getAcceptRect().contains(mouseX, mouseY) ? 0xFF859DF0 : 0xFF7289da); - GlStateManager.translate((widthForTheThing - 10 - fr.getStringWidth(text) * 2) / 2, 15 - fr.FONT_HEIGHT, 0); - - GlStateManager.scale(2.0f, 2.0f, 1.0f); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(text, 0, 0, 0xFFFFFFFF); - GlStateManager.popMatrix(); - GlStateManager.translate(widthForTheThing, 0, 0); - partyJoinRequest.getDenyRect().setBounds(x + height + 3 + widthForTheThing, y + height - 25, widthForTheThing - 10, 25); - Gui.drawRect(0, 0, widthForTheThing - 10, 25, hover && partyJoinRequest.getDenyRect().contains(mouseX, mouseY) ? 0xFFAEC0CB : 0xFF99aab5); - GlStateManager.pushMatrix(); - text = "Deny"; - GlStateManager.translate((widthForTheThing - 10 - fr.getStringWidth(text) * 2) / 2, 15 - fr.FONT_HEIGHT, 0); - GlStateManager.scale(2.0f, 2.0f, 1.0f); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(text, 0, 0, 0xFFFFFFFF); - GlStateManager.popMatrix(); - if (!partyJoinRequest.isInvite()) { - GlStateManager.translate(widthForTheThing, 0, 0); - partyJoinRequest.getIgnoreRect().setBounds(x + height + 3 + widthForTheThing + widthForTheThing, y + height - 25, widthForTheThing - 10, 25); - Gui.drawRect(0, 0, widthForTheThing - 10, 25, hover && partyJoinRequest.getIgnoreRect().contains(mouseX, mouseY) ? 0xFFAEC0CB : 0xFF99aab5); // AEC0CB - - GlStateManager.pushMatrix(); - text = "Ignore"; - GlStateManager.translate((widthForTheThing - 10 - fr.getStringWidth(text) * 2) / 2, 15 - fr.FONT_HEIGHT, 0); - GlStateManager.scale(2.0f, 2.0f, 1.0f); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(text, 0, 0, 0xFFFFFFFF); - GlStateManager.popMatrix(); - } - GlStateManager.popMatrix(); - } else { - GlStateManager.pushMatrix(); - GlStateManager.translate(height + 3, height - 28, 0); - GlStateManager.scale(2.0f,2.0f,1.0f); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(partyJoinRequest.getReply().getPast()+" the invite.",0,0,0xFFFFFFFF); - GlStateManager.popMatrix(); - } - GlStateManager.popMatrix(); - } - - @Override - public void onDiscordUserJoinRequest(DiscordUserJoinRequestEvent event) { - PartyJoinRequest partyInvite = new PartyJoinRequest(); - partyInvite.setDiscordUser(event.getDiscordUser()); - partyInvite.setExpire(System.currentTimeMillis() + 30000L); - partyInvite.setInvite(event.isInvite()); - joinRequests.add(partyInvite); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/PartyJoinRequest.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/PartyJoinRequest.java deleted file mode 100644 index de025698..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/inviteViewer/PartyJoinRequest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.discord.inviteViewer; - -import kr.syeyoung.dungeonsguide.gamesdk.GameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordUser; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; - -import java.awt.*; - -@Data -public class PartyJoinRequest { - private DiscordUser discordUser; - - public void setDiscordUser(DiscordUser discordUser) { - this.discordUser = discordUser; - username = GameSDK.readString(discordUser.username); - discriminator = GameSDK.readString(discordUser.discriminator); - avatar = GameSDK.readString(discordUser.avatar); - } - - private String username, discriminator, avatar; - private long expire; - - private Rectangle wholeRect = new Rectangle(); - private Rectangle acceptRect = new Rectangle(); - private Rectangle denyRect = new Rectangle(); - private Rectangle ignoreRect = new Rectangle(); - - private boolean isInvite; - private int ttl = -1; - private Reply reply; - - @AllArgsConstructor - public enum Reply { - ACCEPT("Accepted"), DENY("Denied"), IGNORE("Ignored"); - - @Getter - private final String past; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/invteTooltip/MTooltipInvite.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/invteTooltip/MTooltipInvite.java deleted file mode 100644 index 253d0256..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/invteTooltip/MTooltipInvite.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.discord.invteTooltip; - -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityActionType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordRelationshipType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct.IDiscordActivityManager; -import kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct.IDiscordCore; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.rpc.JDiscordRelation; -import kr.syeyoung.dungeonsguide.rpc.RichPresenceManager; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; - -import java.awt.*; -import java.util.HashSet; -import java.util.Set; - -public class MTooltipInvite extends MModal { - private MScrollablePanel mScrollablePanel; - private MList list; - private MTextField search; - private MButton close; - private Set invited = new HashSet<>(); - public MTooltipInvite() { - setTitle("Invite Discord Friend"); - mScrollablePanel = new MScrollablePanel(1); - mScrollablePanel.setHideScrollBarWhenNotNecessary(true); - add(mScrollablePanel); - - list = new MList() { - @Override - public void resize(int parentWidth, int parentHeight) { - setSize(new Dimension(parentWidth, 9999)); - realignChildren(); - } - }; - list.setGap(1); - list.setDrawLine(true); - list.setGapLineColor(RenderUtils.blendAlpha(0x141414, 0.13f)); - mScrollablePanel.add(list); - mScrollablePanel.getScrollBarY().setWidth(5); - - search = new MTextField() { - @Override - public void edit(String str) { - super.edit(str); resetListContent(); - } - }; - search.setPlaceHolder("Search..."); - add(search); - - close = new MButton(); - close.setText("X"); - close.setBackground( RenderUtils.blendAlpha(0x141414, 0.20f)); - close.setHover( RenderUtils.blendAlpha(0x141414, 0.25f)); - close.setClicked( RenderUtils.blendAlpha(0x141414, 0.24f)); - close.setOnActionPerformed(this::close); - addSuper(close); - resetListContent(); - } - - @Override - public void onBoundsUpdate() { - super.onBoundsUpdate(); - Dimension effDim = getModalContent().getSize(); - search.setBounds(new Rectangle(5,2,effDim.width-10, 15)); - mScrollablePanel.setBounds(new Rectangle(10,18,effDim.width-20, effDim.height-25)); - close.setBounds(new Rectangle(getModalContent().getBounds().x + effDim.width-15,getModalContent().getBounds().y - 16,15,15)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - GlStateManager.pushMatrix(); - super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); - GlStateManager.popMatrix(); - - Dimension modalSize = getModalSize(); - Dimension effDim = getEffectiveDimension(); - int x = (effDim.width-modalSize.width)/2; - int y = (effDim.height - modalSize.height)/2; - GlStateManager.translate(x,y, 0); - } - - private void resetListContent() { - for (MPanel childComponent : list.getChildComponents()) { - list.remove(childComponent); - } - - String searchTxt = search.getText().trim().toLowerCase(); - for (JDiscordRelation value : RichPresenceManager.INSTANCE.getRelationMap().values()) { -// if (value.getDiscordActivity().getApplicationId() != 816298079732498473L) continue; - if (value.getDiscordRelationshipType() == EDiscordRelationshipType.DiscordRelationshipType_Blocked) continue; - if (!searchTxt.isEmpty() && !(value.getDiscordUser().getUsername().toLowerCase().contains(searchTxt))) continue; - list.add(new MTooltipInviteElement(value, invited.contains(value.getDiscordUser().getId()), this::invite)); - } - setBounds(getBounds()); - } - - public void invite(long id) { - invited.add(id); - IDiscordCore iDiscordCore = RichPresenceManager.INSTANCE.getIDiscordCore(); - IDiscordActivityManager iDiscordActivityManager = iDiscordCore.GetActivityManager.getActivityManager(iDiscordCore); - iDiscordActivityManager.SendInvite.sendInvite(iDiscordActivityManager, new DiscordSnowflake(id), EDiscordActivityActionType.DiscordActivityActionType_Join, "Dungeons Guide RPC Invite TESt", Pointer.NULL, (callbackData, result) -> { - System.out.println("Discord returned "+result+" For inviting "+id); - }); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/invteTooltip/MTooltipInviteElement.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/invteTooltip/MTooltipInviteElement.java deleted file mode 100644 index 4445f5a6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/invteTooltip/MTooltipInviteElement.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.discord.invteTooltip; - -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.discord.inviteViewer.ImageTexture; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.rpc.JDiscordRelation; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; - -import java.awt.*; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.function.Consumer; - -public class MTooltipInviteElement extends MPanel { - private JDiscordRelation relation; - private MButton invite; - public MTooltipInviteElement(JDiscordRelation jDiscordRelation, boolean invited, Consumer inviteCallback) { - this.relation = jDiscordRelation; - this.invite = new MButton(); - if (!invited) { - invite.setText("Invite"); - invite.setRoundness(2); - invite.setBorder(0xFF02EE67); - invite.setHover(RenderUtils.blendAlpha(0x141414, 0.2f)); - invite.setBackground(RenderUtils.blendAlpha(0x141414, 0.17f)); - invite.setForeground(new Color(0xFF02EE67)); - - invite.setOnActionPerformed(() -> { - if (invite.isEnabled()) - inviteCallback.accept(jDiscordRelation.getDiscordUser().getId()); - - invite.setText("Sent"); - invite.setRoundness(2); - invite.setHover(0); invite.setBorder(0); - invite.setBackground(0); invite.setDisabled(0); invite.setEnabled(false); - invite.setForeground(new Color(0xFF02EE67)); - }); - } else { - invite.setText("Sent"); - invite.setRoundness(2); - invite.setHover(0); - invite.setBackground(0); invite.setDisabled(0); invite.setEnabled(false); - invite.setForeground(new Color(0xFF02EE67)); - } - - add(invite); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (lastAbsClip.contains(absMousex, absMousey) && getTooltipsOpen() == 0) { - RenderUtils.drawRoundedRectangle(0,0,bounds.width, bounds.height, 3, Math.PI/8, RenderUtils.blendAlpha(0x141414, 0.17f)); - GlStateManager.enableTexture2D(); - } - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - if (!relation.getDiscordUser().getAvatar().isEmpty()){ - String avatar = "https://cdn.discordapp.com/avatars/"+Long.toUnsignedString(relation.getDiscordUser().getId())+"/"+relation.getDiscordUser().getAvatar()+"."+(relation.getDiscordUser().getAvatar().startsWith("a_") ? "gif":"png"); - Future loadedImageFuture = FeatureRegistry.DISCORD_ASKTOJOIN.loadImage(avatar); - ImageTexture loadedImage = null; - if (loadedImageFuture.isDone()) { - try { - loadedImage = loadedImageFuture.get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - if (loadedImage != null) { - loadedImage.drawFrameAndIncrement( 3,3,bounds.height-6,bounds.height-6); - } else { - Gui.drawRect(3, 3, bounds.height - 6, bounds.height-6, 0xFF4E4E4E); - } - } - fr.drawString(relation.getDiscordUser().getUsername()+"#"+relation.getDiscordUser().getDiscriminator(), bounds.height,(bounds.height-fr.FONT_HEIGHT)/2, -1); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(100, 20); - } - - @Override - public void onBoundsUpdate() { - invite.setBounds(new Rectangle(bounds.width-53,2,50,bounds.height-4)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/onlinealarm/PlayingDGAlarm.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/onlinealarm/PlayingDGAlarm.java deleted file mode 100644 index 95eed5a2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/discord/onlinealarm/PlayingDGAlarm.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.discord.onlinealarm; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.events.DiscordUserUpdateEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.impl.discord.inviteViewer.ImageTexture; -import kr.syeyoung.dungeonsguide.features.listener.DiscordUserUpdateListener; -import kr.syeyoung.dungeonsguide.features.listener.ScreenRenderListener; -import kr.syeyoung.dungeonsguide.features.listener.TickListener; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordRelationshipType; -import kr.syeyoung.dungeonsguide.rpc.JDiscordActivity; -import kr.syeyoung.dungeonsguide.rpc.JDiscordRelation; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.texture.TextureManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -public class PlayingDGAlarm extends SimpleFeature implements DiscordUserUpdateListener, ScreenRenderListener, TickListener { - public PlayingDGAlarm() { - super("Discord", "Friend Online Notification","Notifies you in bottom when your discord friend has launched a Minecraft with DG!\n\nRequires the Friend's Discord RPC to be enabled", "discord.playingalarm"); - } - private List notif = new CopyOnWriteArrayList<>(); - - @Override - public void onTick() { - try { - List partyJoinRequestList = new ArrayList<>(); - boolean isOnHypixel = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnHypixel(); - for (PlayerOnline joinRequest:notif) { - if (!isOnHypixel){ - partyJoinRequestList.add(joinRequest); - } else if (joinRequest.getEnd() < System.currentTimeMillis()) { - partyJoinRequestList.add(joinRequest); - } - } - notif.removeAll(partyJoinRequestList); - } catch (Throwable e) {e.printStackTrace();} - } - - - - @Override - public void drawScreen(float partialTicks) { - if (!isEnabled()) return; - try { - GlStateManager.pushMatrix(); - GlStateManager.translate(0,0,100); - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - GlStateManager.scale(1.0 / sr.getScaleFactor(), 1.0 / sr.getScaleFactor(), 1.0); - int height = 90; - int gap = 5; - int x = Minecraft.getMinecraft().displayWidth-350-gap; - int y = Minecraft.getMinecraft().displayHeight-(height+gap)*notif.size(); - for (PlayerOnline partyJoinRequest : notif) { - renderRequest(partyJoinRequest, x, y, 350,height); - y += height + gap; - } - GlStateManager.popMatrix(); - GlStateManager.enableBlend(); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - public void renderRequest(PlayerOnline online, int x, int y, int width, int height) { - GlStateManager.pushMatrix(); - GlStateManager.translate(x,y,0); - - Gui.drawRect(0, 0,width,height, 0xFF23272a); - Gui.drawRect(2, 2, width-2, height-2, 0XFF2c2f33); - { - String avatar = "https://cdn.discordapp.com/avatars/"+Long.toUnsignedString(online.getJDiscordRelation().getDiscordUser().getId())+"/"+online.getJDiscordRelation().getDiscordUser().getAvatar()+"."+(online.getJDiscordRelation().getDiscordUser().getAvatar().startsWith("a_") ? "gif":"png"); - Future loadedImageFuture = FeatureRegistry.DISCORD_ASKTOJOIN.loadImage(avatar); - ImageTexture loadedImage = null; - if (loadedImageFuture.isDone()) { - try { - loadedImage = loadedImageFuture.get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - if (loadedImage != null) { - loadedImage.drawFrameAndIncrement( 7,7,height-14,height-14); - } else { - Gui.drawRect(7, 7, height - 7, height-7, 0xFF4E4E4E); - } - } - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.pushMatrix(); - GlStateManager.translate(height +3,7, 0); - - GlStateManager.pushMatrix(); - GlStateManager.scale(3.0,3.0,1.0); - fr.drawString(online.getJDiscordRelation().getDiscordUser().getUsername()+"", 0,0, 0xFFFFFFFF, true); - GlStateManager.popMatrix(); - - GlStateManager.pushMatrix(); - GlStateManager.translate(fr.getStringWidth(online.getJDiscordRelation().getDiscordUser().getUsername()+"") * 3 + 1, (int)(fr.FONT_HEIGHT*1.5), 0); - fr.drawString("#"+online.getJDiscordRelation().getDiscordUser().getDiscriminator(), 0,0,0xFFaaaaaa, true); - GlStateManager.popMatrix(); - GlStateManager.pushMatrix(); - GlStateManager.translate(0, fr.FONT_HEIGHT * 3 + 5, 0); - GlStateManager.scale(1.0,1.0,1.0); - fr.drawString("Started Playing Skyblock! (Dismissed in "+(TextUtils.formatTime(online.getEnd() - System.currentTimeMillis()))+")", 0,0,0xFFFFFFFF,false); - GlStateManager.popMatrix(); - GlStateManager.popMatrix(); - GlStateManager.popMatrix(); - } - - - @Data @AllArgsConstructor - public static class PlayerOnline { - private JDiscordRelation jDiscordRelation; - private long end; - } - - @Override - public void onDiscordUserUpdate(DiscordUserUpdateEvent event) { - JDiscordRelation prev = event.getPrev(), current = event.getCurrent(); - if (!isDisplayable(prev) && isDisplayable(current)) { - notif.add(new PlayerOnline(current, System.currentTimeMillis()+3000)); - } - } - - public boolean isDisplayable(JDiscordRelation jDiscordRelation) { - EDiscordRelationshipType relationshipType = jDiscordRelation.getDiscordRelationshipType(); - if (relationshipType == EDiscordRelationshipType.DiscordRelationshipType_Blocked) return false; - if (relationshipType == EDiscordRelationshipType.DiscordRelationshipType_None) return false; - if (relationshipType == EDiscordRelationshipType.DiscordRelationshipType_PendingIncoming) return false; - if (relationshipType == EDiscordRelationshipType.DiscordRelationshipType_PendingOutgoing) return false; - - JDiscordActivity jDiscordActivity = jDiscordRelation.getDiscordActivity(); - return jDiscordActivity.getApplicationId() == 816298079732498473L; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxBats.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxBats.java deleted file mode 100644 index 5fac96b9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxBats.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.util.BlockPos; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - - -public class FeatureBoxBats extends SimpleFeature implements WorldRenderListener { - public FeatureBoxBats() { - super("Dungeon.Mobs", "Box Bats", "Box bats in dungeons\nDoes not appear through walls", "dungeon.batbox", true); - parameters.put("radius", new FeatureParameter("radius", "Highlight Radius", "The maximum distance between player and bats to be boxed", 20, "integer")); - parameters.put("color", new FeatureParameter("color", "Highlight Color", "Highlight Color of Bats", new AColor(255,0,0,50), "acolor")); - } - - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public void drawWorld(float partialTicks) { - if (!isEnabled()) return; - if (!skyblockStatus.isOnDungeon()) return; - - final BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - int val = this.getParameter("radius").getValue(); - final int sq = val * val; - - List skeletonList = Minecraft.getMinecraft().theWorld.getEntities(EntityBat.class, new Predicate() { - @Override - public boolean apply(@Nullable EntityBat input) { - if (input != null && input.isInvisible()) return false; - return input != null && input.getDistanceSq(player) < sq; - } - }); - AColor c = this.getParameter("color").getValue(); - for (EntityBat entitySkeleton : skeletonList) { - if (!entitySkeleton.isInvisible()) - RenderUtils.highlightBox(entitySkeleton, c, partialTicks, true); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java deleted file mode 100644 index 7e8c736b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.util.BlockPos; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - - -public class FeatureBoxSkelemaster extends SimpleFeature implements WorldRenderListener { - public FeatureBoxSkelemaster() { - super("Dungeon.Mobs", "Box Skeleton Masters", "Box skeleton masters in dungeons", "dungeon.skeletonmasterbox", true); - parameters.put("radius", new FeatureParameter("radius", "Highlight Radius", "The maximum distance between player and skeletonmaster to be boxed", 20, "integer")); - parameters.put("color", new FeatureParameter("color", "Highlight Color", "Highlight Color of Skeleton master", new AColor(255,0,0,50), "acolor")); - } - - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public void drawWorld(float partialTicks) { - if (!isEnabled()) return; - if (!skyblockStatus.isOnDungeon()) return; - - final BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - int val = this.getParameter("radius").getValue(); - final int sq = val * val; - - List skeletonList = Minecraft.getMinecraft().theWorld.getEntities(EntityArmorStand.class, new Predicate() { - @Override - public boolean apply(@Nullable EntityArmorStand input) { - if (player.distanceSq(input.getPosition()) > sq) return false; - if (!input.getAlwaysRenderNameTag()) return false; - return input.getName().contains("Skeleton Master"); - } - }); - AColor c = this.getParameter("color").getValue(); - for (EntityArmorStand entitySkeleton : skeletonList) { - RenderUtils.highlightBox(entitySkeleton, c, partialTicks, true); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java deleted file mode 100644 index e41e9f69..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.util.BlockPos; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - - -public class FeatureBoxStarMobs extends SimpleFeature implements WorldRenderListener { - public FeatureBoxStarMobs() { - super("Dungeon.Mobs", "Box Starred mobs", "Box Starred mobs in dungeons", "dungeon.starmobbox", false); - parameters.put("radius", new FeatureParameter("radius", "Highlight Radius", "The maximum distance between player and starred mobs to be boxed", 20, "integer")); - parameters.put("color", new FeatureParameter("color", "Highlight Color", "Highlight Color of Starred mobs", new AColor(0,255,255,50), "acolor")); - } - - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public void drawWorld(float partialTicks) { - if (!isEnabled()) return; - if (!skyblockStatus.isOnDungeon()) return; - - final BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - int val = this.getParameter("radius").getValue(); - final int sq = val * val; - - List skeletonList = Minecraft.getMinecraft().theWorld.getEntities(EntityArmorStand.class, new Predicate() { - @Override - public boolean apply(@Nullable EntityArmorStand input) { - if (player.distanceSq(input.getPosition()) > sq) return false; - if (!input.getAlwaysRenderNameTag()) return false; - return input.getName().contains("โœฏ"); - } - }); - AColor c = this.getParameter("color").getValue(); - for (EntityArmorStand entitySkeleton : skeletonList) { - RenderUtils.highlightBox(entitySkeleton, c, partialTicks, true); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureCollectScore.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureCollectScore.java deleted file mode 100644 index f7e92262..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureCollectScore.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.DungeonEndListener; - -public class FeatureCollectScore extends SimpleFeature { - public FeatureCollectScore() { - super("Misc", "Collect Speed Score", "Collect Speed score, run time, and floor and send that to developer's server for speed formula. This data is completely anonymous, opt out of the feature by disabling this feature", "misc.gatherscoredata", true); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java deleted file mode 100644 index cf1ebc08..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureDungeonCurrentRoomSecrets extends TextHUDFeature implements ChatListener { - public FeatureDungeonCurrentRoomSecrets() { - super("Dungeon.Dungeon Information", "Display # Secrets in current room", "Display what your actionbar says", "dungeon.stats.secretsroom", true, getFontRenderer().getStringWidth("Secrets In Room: 8/8"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("currentSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("totalSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - - private static final List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Secrets In Room","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("5","currentSecrets")); - dummyText.add(new StyledText("/","separator2")); - dummyText.add(new StyledText("8","totalSecrets")); - } - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon(); - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("title", "separator", "currentSecrets", "separator2", "totalSecrets"); - } - - @Override - public List getDummyText() { - return dummyText; - } - - private int latestCurrSecrets = 0; - private int latestTotalSecrets = 0; - - - @Override - public List getText() { - if (skyblockStatus.getContext().getBossfightProcessor() != null) return new ArrayList(); - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Secrets In Room","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(latestCurrSecrets +"","currentSecrets")); - actualBit.add(new StyledText("/","separator2")); - actualBit.add(new StyledText(latestTotalSecrets +"","totalSecrets")); - return actualBit; - } - - @Override - public void onChat(ClientChatReceivedEvent chat) { - if (chat.type != 2) return; - String text = chat.message.getFormattedText(); - if (!text.contains("/")) return; - - int secretsIndex = text.indexOf("Secrets"); - if (secretsIndex != -1) { - int theindex = 0; - for (int i = secretsIndex; i >= 0; i--) { - if (text.startsWith("ยง7", i)) { - theindex = i; - } - } - String it = text.substring(theindex + 2, secretsIndex - 1); - - latestCurrSecrets = Integer.parseInt(it.split("/")[0]); - latestTotalSecrets = Integer.parseInt(it.split("/")[1]); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java deleted file mode 100644 index bb3d5241..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.events.DungeonDeathEvent; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.*; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class FeatureDungeonDeaths extends TextHUDFeature implements ChatListener { - public FeatureDungeonDeaths() { - super("Dungeon.Dungeon Information", "Display Deaths", "Display names of player and death count in dungeon run", "dungeon.stats.deaths", false, getFontRenderer().getStringWidth("longestplayernamepos: 100"), getFontRenderer().FONT_HEIGHT * 6); - this.setEnabled(false); - getStyles().add(new TextStyle("username", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("total", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("deaths", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("totalDeaths", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public boolean isHUDViewable() { - if (!skyblockStatus.isOnDungeon()) return false; - DungeonContext context = skyblockStatus.getContext(); - return context != null; - } - - @Override - public boolean doesScaleWithHeight() { - return false; - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("username", "separator", "deaths", "total", "totalDeaths"); - } - - @Override - public List getText() { - - List text= new ArrayList(); - - DungeonContext context = skyblockStatus.getContext(); - Map deaths = context.getDeaths(); - int i = 0; - int deathsCnt = 0; - for (Map.Entry death:deaths.entrySet()) { - text.add(new StyledText(death.getKey(),"username")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(death.getValue()+"\n","deaths")); - deathsCnt += death.getValue(); - } - text.add(new StyledText("Total Deaths","total")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(getTotalDeaths()+"","totalDeaths")); - - return text; - } - - private static final List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("syeyoung","username")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("-130\n","deaths")); - dummyText.add(new StyledText("rioho","username")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("-999999\n","deaths")); - dummyText.add(new StyledText("dungeonsguide","username")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("-42\n","deaths")); - dummyText.add(new StyledText("penguinman","username")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("0\n","deaths")); - dummyText.add(new StyledText("probablysalt","username")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("0\n","deaths")); - dummyText.add(new StyledText("Total Deaths","total")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("0","totalDeaths")); - } - - @Override - public List getDummyText() { - return dummyText; - } - - public int getTotalDeaths() { - if (!skyblockStatus.isOnDungeon()) return 0; - for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); - if (name.contains("Deaths")) { - String whatever = TextUtils.keepIntegerCharactersOnly(TextUtils.keepScoreboardCharacters(TextUtils.stripColor(name))); - if (whatever.isEmpty()) break; - return Integer.parseInt(whatever); - } - } - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return 0; - int d = 0; - for (Integer value : context.getDeaths().values()) { - d += value; - } - return d; - } - - Pattern deathPattern = Pattern.compile("ยงrยงc โ˜  (.+?)ยงrยง7 .+and became a ghost.+"); - Pattern meDeathPattern = Pattern.compile("ยงrยงc โ˜  ยงrยง7You .+and became a ghost.+"); - - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (clientChatReceivedEvent.type == 2) return; - if (!skyblockStatus.isOnDungeon()) return; - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return; - - String txt = clientChatReceivedEvent.message.getFormattedText(); - Matcher m = deathPattern.matcher(txt); - if (m.matches()) { - String nickname = TextUtils.stripColor(m.group(1)); - int deaths = context.getDeaths().getOrDefault(nickname, 0); - context.getDeaths().put(nickname, deaths + 1); - context.createEvent(new DungeonDeathEvent(nickname, txt, deaths)); - DungeonsGuide.sendDebugChat(new ChatComponentText("Death verified :: "+nickname+" / "+(deaths + 1))); - } - Matcher m2 = meDeathPattern.matcher(txt); - if (m2.matches()) { - String nickname = "me"; - int deaths = context.getDeaths().getOrDefault(nickname, 0); - context.getDeaths().put(nickname, deaths + 1); - context.createEvent(new DungeonDeathEvent(Minecraft.getMinecraft().thePlayer.getName(), txt, deaths)); - DungeonsGuide.sendDebugChat(new ChatComponentText("Death verified :: me / "+(deaths + 1))); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java deleted file mode 100644 index fa8d214c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import com.google.common.collect.ComparisonChain; -import com.google.common.collect.Ordering; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.MapProcessor; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.features.listener.BossroomEnterListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonEndListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonStartListener; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.block.material.MapColor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Vec4b; -import net.minecraft.world.WorldSettings; -import net.minecraft.world.storage.MapData; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.jetbrains.annotations.Nullable; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import javax.vecmath.Vector2d; -import java.awt.*; -import java.util.Comparator; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, DungeonStartListener, BossroomEnterListener { - public FeatureDungeonMap() { - super("Dungeon", "Dungeon Map", "Display dungeon map!", "dungeon.map", true, 128, 128); - this.setEnabled(false); - parameters.put("scale", new FeatureParameter<>("scale", "Scale map", "Whether to scale map to fit screen", true, "boolean")); - parameters.put("playerCenter", new FeatureParameter<>("playerCenter", "Center map at player", "Render you in the center", false, "boolean")); - parameters.put("rotate", new FeatureParameter<>("rotate", "Rotate map centered at player", "Only works with Center map at player enabled", false, "boolean")); - parameters.put("postScale", new FeatureParameter<>("postScale", "Scale factor of map", "Only works with Center map at player enabled", 1.0f, "float")); - parameters.put("useplayerheads", new FeatureParameter<>("useplayerheads", "Use player heads instead of arrows", "Option to use player heads instead of arrows", true, "boolean")); - parameters.put("showotherplayers", new FeatureParameter<>("showotherplayers", "Show other players", "Option to show other players in map", true, "boolean")); - parameters.put("showtotalsecrets", new FeatureParameter<>("showtotalsecrets", "Show Total secrets in the room", "Option to overlay total secrets in the specific room", true, "boolean")); - parameters.put("playerheadscale", new FeatureParameter<>("playerheadscale", "Player head scale", "Scale factor of player heads, defaults to 1", 1.0f, "float")); - parameters.put("textScale", new FeatureParameter<>("textScale", "Text scale", "Scale factor of texts on map, defaults to 1", 1.0f, "float")); - - parameters.put("border_color", new FeatureParameter<>("border_color", "Color of the border", "Same as name", new AColor(255, 255, 255, 255), "acolor")); - parameters.put("background_color", new FeatureParameter<>("background_color", "Color of the background", "Same as name", new AColor(0x22000000, true), "acolor")); - parameters.put("player_color", new FeatureParameter<>("player_color", "Color of the player border", "Same as name", new AColor(255, 255, 255, 0), "acolor")); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - public static final Ordering field_175252_a = Ordering.from(new PlayerComparator()); - - private boolean on = false; - - @Override - public void onDungeonEnd() { - on = false; - } - - @Override - public void onDungeonStart() { - on = true; - } - - @Override - public void onBossroomEnter() { - on = false; - } - - @SideOnly(Side.CLIENT) - static class PlayerComparator implements Comparator { - private PlayerComparator() { - } - - public int compare(NetworkPlayerInfo compare1, NetworkPlayerInfo compare2) { - ScorePlayerTeam scoreplayerteam = compare1.getPlayerTeam(); - ScorePlayerTeam scoreplayerteam1 = compare2.getPlayerTeam(); - return ComparisonChain.start().compareTrueFirst(compare1.getGameType() != WorldSettings.GameType.SPECTATOR, compare2.getGameType() != WorldSettings.GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getRegisteredName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getRegisteredName() : "").compare(compare1.getGameProfile().getName(), compare2.getGameProfile().getName()).result(); - } - } - - @Override - public void drawHUD(float partialTicks) { - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) - return; - if (!on) return; - - DungeonContext context = skyblockStatus.getContext(); - MapProcessor mapProcessor = context.getMapProcessor(); - MapData mapData = mapProcessor.getLastMapData2(); - Rectangle featureRect = getFeatureRect().getRectangle(); - Gui.drawRect(0, 0, featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, this.getParameter("background_color").getValue())); - GlStateManager.color(1, 1, 1, 1); - GlStateManager.pushMatrix(); - if (mapData == null) { - Gui.drawRect(0, 0, featureRect.width, featureRect.height, 0xFFFF0000); - } else { - renderMap(partialTicks, mapProcessor, mapData, context); - } - GlStateManager.popMatrix(); - GL11.glLineWidth(2); - RenderUtils.drawUnfilledBox(0, 0, featureRect.width, featureRect.height, this.getParameter("border_color").getValue()); - } - - @Override - public void drawDemo(float partialTicks) { - if (skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getMapProcessor().isInitialized() && on) { - drawHUD(partialTicks); - return; - } - Rectangle featureRect = getFeatureRect().getRectangle(); - Gui.drawRect(0, 0, featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, this.getParameter("background_color").getValue())); - FontRenderer fr = getFontRenderer(); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Please join a dungeon to see preview", featureRect.width / 2 - fr.getStringWidth("Please join a dungeon to see preview") / 2, featureRect.height / 2 - fr.FONT_HEIGHT / 2, 0xFFFFFFFF); - GL11.glLineWidth(2); - RenderUtils.drawUnfilledBox(0, 0, featureRect.width, featureRect.height, this.getParameter("border_color").getValue()); - } - - public void renderMap(float partialTicks, MapProcessor mapProcessor, MapData mapData, DungeonContext context) { - float postScale; - if (this.getParameter("playerCenter").getValue()) { - postScale = this.getParameter("postScale").getValue(); - } else { - postScale = 1; - } - Rectangle featureRect = getFeatureRect().getRectangle(); - int width = featureRect.width; - float scale; - if (this.getParameter("scale").getValue()) { - scale = width / 128.0f; - } else { - scale = 1; - } - GlStateManager.translate(width / 2d, width / 2d, 0); - GlStateManager.scale(scale, scale, 0); - GlStateManager.scale(postScale, postScale, 0); - EntityPlayer p = Minecraft.getMinecraft().thePlayer; - - Vector2d pt = mapProcessor.worldPointToMapPointFLOAT(p.getPositionEyes(partialTicks)); - double yaw = p.rotationYaw; - if (this.getParameter("playerCenter").getValue()) { - if (this.getParameter("rotate").getValue()) { - GlStateManager.rotate((float) (180.0 - yaw), 0, 0, 1); - } - GlStateManager.translate(-pt.x, -pt.y, 0); - } else { - GlStateManager.translate(-64, -64, 0); - } - updateMapTexture(mapData.colors, mapProcessor, context.getDungeonRoomList()); - render(); - - - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(1, 771, 0, 1); - - if (this.getParameter("useplayerheads").getValue()) { - renderHeads(mapProcessor, mapData, scale, postScale, partialTicks); - } else { - renderArrows(mapData, scale, postScale); - } - - - FontRenderer fr = getFontRenderer(); - if (this.getParameter("showtotalsecrets").getValue()) { - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - GlStateManager.pushMatrix(); - - Point mapPt = mapProcessor.roomPointToMapPoint(dungeonRoom.getUnitPoints().get(0)); - GlStateManager.translate(mapPt.x + mapProcessor.getUnitRoomDimension().width / 2d, mapPt.y + mapProcessor.getUnitRoomDimension().height / 2d, 0); - - if (this.getParameter("playerCenter").getValue() && this.getParameter("rotate").getValue()) { - GlStateManager.rotate((float) (yaw - 180), 0, 0, 1); - } - GlStateManager.scale(1 / scale, 1 / scale, 0); - GlStateManager.scale(1 / postScale, 1 / postScale, 0); - float s = this.getParameter("textScale").getValue(); - GlStateManager.scale(s, s, 0); - String str = ""; - str += dungeonRoom.getTotalSecrets() == -1 ? "?" : String.valueOf(dungeonRoom.getTotalSecrets()); - str += " "; - if (dungeonRoom.getCurrentState() == DungeonRoom.RoomState.FINISHED) { - str += "โœ”"; - } else if (dungeonRoom.getCurrentState() == DungeonRoom.RoomState.COMPLETE_WITHOUT_SECRETS) { - str += "โ˜‘"; - } else if (dungeonRoom.getCurrentState() == DungeonRoom.RoomState.DISCOVERED) { - str += "โ˜"; - } else if (dungeonRoom.getCurrentState() == DungeonRoom.RoomState.FAILED) { - str += "โŒ"; - } - - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (dungeonRoom.getCurrentState() == DungeonRoom.RoomState.FINISHED) - fr.drawString(str, -(fr.getStringWidth(str) / 2), -(fr.FONT_HEIGHT / 2), 0xFF00FF00); - else { - if (dungeonRoom.getColor() == 74) - fr.drawString(str, -(fr.getStringWidth(str) / 2), -(fr.FONT_HEIGHT / 2), 0xff000000); - else fr.drawString(str, -(fr.getStringWidth(str) / 2), -(fr.FONT_HEIGHT / 2), 0xFFFFFFFF); - } - - GlStateManager.popMatrix(); - } - } - - } - - - private final DynamicTexture mapTexture = new DynamicTexture(128, 128); - private final ResourceLocation location = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("dungeonmap/map", mapTexture); - private final int[] mapTextureData = mapTexture.getTextureData(); - - private void updateMapTexture(byte[] colors, MapProcessor mapProcessor, List dungeonRooms) { - for (int i = 0; i < 16384; ++i) { - int j = colors[i] & 255; - - if (j / 4 == 0) { - this.mapTextureData[i] = 0x00000000; - } else { - this.mapTextureData[i] = MapColor.mapColorArray[j / 4].getMapColor(j & 3); - } - } - - if (this.getParameter("showtotalsecrets").getValue()) { - for (DungeonRoom dungeonRoom : dungeonRooms) { - for (Point pt : dungeonRoom.getUnitPoints()) { - for (int y1 = 0; y1 < mapProcessor.getUnitRoomDimension().height; y1++) { - for (int x1 = 0; x1 < mapProcessor.getUnitRoomDimension().width; x1++) { - int x = MathHelper.clamp_int(pt.x * (mapProcessor.getUnitRoomDimension().width + mapProcessor.getDoorDimension().height) + x1 + mapProcessor.getTopLeftMapPoint().x, 0, 128); - int y = MathHelper.clamp_int(pt.y * (mapProcessor.getUnitRoomDimension().height + mapProcessor.getDoorDimension().height) + y1 + mapProcessor.getTopLeftMapPoint().y, 0, 128); - int i = y * 128 + x; - int j = dungeonRoom.getColor(); - - if (j / 4 == 0) { - this.mapTextureData[i] = 0x00000000; - } else { - this.mapTextureData[i] = MapColor.mapColorArray[j / 4].getMapColor(j & 3); - } - } - } - } - } - } - - - this.mapTexture.updateDynamicTexture(); - } - - - private void renderHeads(MapProcessor mapProcessor, MapData mapData, float scale, float postScale, float partialTicks) { - List list = field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); - if (list.size() < 40) return; - - // 19 iterations bc we only want to scan the player part of tab list - for (int i = 1; i < 20; i++) { - NetworkPlayerInfo networkPlayerInfo = list.get(i); - - String name = getPlayerNameWithChecks(networkPlayerInfo); - if (name == null) continue; - - - EntityPlayer entityplayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(name); - - Vector2d pt2; - double yaw2; - - - if (entityplayer != null && (!entityplayer.isInvisible() || entityplayer == Minecraft.getMinecraft().thePlayer)) { - pt2 = mapProcessor.worldPointToMapPointFLOAT(entityplayer.getPositionEyes(partialTicks)); - yaw2 = entityplayer.prevRotationYawHead + (entityplayer.rotationYawHead - entityplayer.prevRotationYawHead) * partialTicks; - } else { - String iconName = mapProcessor.getMapIconToPlayerMap().get(name); - if (iconName == null) continue; - Vec4b vec = mapData.mapDecorations.get(iconName); - if (vec == null) { - continue; - } else { - pt2 = new Vector2d(vec.func_176112_b() / 2d + 64, vec.func_176113_c() / 2d + 64); - yaw2 = vec.func_176111_d() * 360 / 16.0f; - } - } - - GlStateManager.pushMatrix(); - - boolean showOtherPlayers = this.getParameter("showotherplayers").getValue(); - - if (entityplayer == Minecraft.getMinecraft().thePlayer || showOtherPlayers) { - boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE); - GlStateManager.enableTexture2D(); - Minecraft.getMinecraft().getTextureManager().bindTexture(networkPlayerInfo.getLocationSkin()); - int l2 = 8 + (flag1 ? 8 : 0); - int i3 = 8 * (flag1 ? -1 : 1); - - GlStateManager.translate(pt2.x, pt2.y, 0); - GlStateManager.rotate((float) yaw2, 0, 0, 1); - - GlStateManager.scale(1 / scale, 1 / scale, 0); - GlStateManager.scale(1 / postScale, 1 / postScale, 0); - - float s = this.getParameter("playerheadscale").getValue(); - GlStateManager.scale(s, s, 0); - - // cutting out the player head out of the skin texture - Gui.drawScaledCustomSizeModalRect(-4, -4, 8.0F, l2, 8, i3, 8, 8, 64.0F, 64.0F); - GL11.glLineWidth(1); - RenderUtils.drawUnfilledBox(-4, -4, 4, 4, this.getParameter("player_color").getValue()); - } - GlStateManager.popMatrix(); - } - } - - final Pattern tabListRegex = Pattern.compile("\\*[a-zA-Z0-9_]{2,16}\\*", Pattern.MULTILINE); - - /** - * We make sure that the player is alive and regex their name out - * @param networkPlayerInfo the network player info of player - * @return the username of player - */ - @Nullable - private String getPlayerNameWithChecks(NetworkPlayerInfo networkPlayerInfo) { - String name; - if (networkPlayerInfo.getDisplayName() != null) { - name = networkPlayerInfo.getDisplayName().getFormattedText(); - } else { - name = ScorePlayerTeam.formatPlayerName( - networkPlayerInfo.getPlayerTeam(), - networkPlayerInfo.getGameProfile().getName() - ); - } - - if (name.trim().equals("ยงr") || name.startsWith("ยงr ")) return null; - - name = TextUtils.stripColor(name); - - if(name.contains("(DEAD)")) { - return null; - } - - name = name.replace(" ", "*"); - - Matcher matcher = tabListRegex.matcher(name); - if (!matcher.find()) return null; - - name = matcher.group(0); - name = name.substring(0, name.length() - 1); - name = name.substring(1); - return name; - } - - - private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png"); - - private void renderArrows(MapData mapData, float scale, float postScale) { - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - int k = 0; - Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons); - for (Vec4b vec4b : mapData.mapDecorations.values()) { - if (vec4b.func_176110_a() == 1 || this.getParameter("showotherplayers").getValue()) { - GlStateManager.pushMatrix(); - GlStateManager.translate(vec4b.func_176112_b() / 2.0F + 64.0F, vec4b.func_176113_c() / 2.0F + 64.0F, -0.02F); - GlStateManager.rotate((vec4b.func_176111_d() * 360) / 16.0F, 0.0F, 0.0F, 1.0F); - - GlStateManager.scale(1 / scale, 1 / scale, 0); - GlStateManager.scale(1 / postScale, 1 / postScale, 0); - float s = this.getParameter("playerheadscale").getValue(); - GlStateManager.scale(s * 5, s * 5, 0); - - GlStateManager.translate(-0.125F, 0.125F, 0.0F); - byte b0 = vec4b.func_176110_a(); - float f1 = (b0 % 4) / 4.0F; - float f2 = (b0 / 4f) / 4.0F; - float f3 = (b0 % 4 + 1) / 4.0F; - float f4 = (b0 / 4f + 1) / 4.0F; - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(-1.0D, 1.0D, k * -0.001F).tex(f1, f2).endVertex(); - worldrenderer.pos(1.0D, 1.0D, k * -0.001F).tex(f3, f2).endVertex(); - worldrenderer.pos(1.0D, -1.0D, k * -0.001F).tex(f3, f4).endVertex(); - worldrenderer.pos(-1.0D, -1.0D, k * -0.001F).tex(f1, f4).endVertex(); - tessellator.draw(); - GlStateManager.popMatrix(); - ++k; - } - } - } - - private void render() { - int i = 0; - int j = 0; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - float f = 0.0F; - Minecraft.getMinecraft().getTextureManager().bindTexture(this.location); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(1, 771, 0, 1); - GlStateManager.disableAlpha(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos((i) + f, (j + 128) - f, -0.009999999776482582D).tex(0.0D, 1.0D).endVertex(); - worldrenderer.pos((i + 128) - f, (j + 128) - f, -0.009999999776482582D).tex(1.0D, 1.0D).endVertex(); - worldrenderer.pos((i + 128) - f, (j) + f, -0.009999999776482582D).tex(1.0D, 0.0D).endVertex(); - worldrenderer.pos((i) + f, (j) + f, -0.009999999776482582D).tex(0.0D, 0.0D).endVertex(); - tessellator.draw(); - GlStateManager.enableAlpha(); - GlStateManager.disableBlend(); - - GlStateManager.pushMatrix(); - GlStateManager.translate(0.0F, 0.0F, -0.04F); - GlStateManager.scale(1.0F, 1.0F, 1.0F); - GlStateManager.popMatrix(); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java deleted file mode 100644 index e9819690..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.regex.Pattern; - -public class FeatureDungeonMilestone extends TextHUDFeature implements ChatListener { - public FeatureDungeonMilestone() { - super("Dungeon.Dungeon Information", "Display Current Class Milestone", "Display current class milestone of yourself", "dungeon.stats.milestone", true, getFontRenderer().getStringWidth("Milestone: 12"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - private static final List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Milestone","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("9","number")); - } - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon(); - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("title", "separator", "number"); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public List getText() { - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Milestone","title")); - actualBit.add(new StyledText(": ","separator")); - for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); - if (name.startsWith("ยงr Milestone: ยงr")) { - String milestone = TextUtils.stripColor(name).substring(13); - actualBit.add(new StyledText(milestone+"","number")); - break; - } - } - return actualBit; - } - - public static final Pattern milestone_pattern = Pattern.compile("ยงrยงeยงl(.+) Milestone ยงrยงe(.)ยงrยง7: .+ ยงrยงa(.+)ยงr"); - - - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (clientChatReceivedEvent.type == 2) return; - if (!skyblockStatus.isOnDungeon()) return; - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return; - String txt = clientChatReceivedEvent.message.getFormattedText(); - if (milestone_pattern.matcher(txt).matches()) { - context.getMilestoneReached().add(new String[] { - TextUtils.formatTime(FeatureRegistry.DUNGEON_REALTIME.getTimeElapsed()), - TextUtils.formatTime(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed()) - }); - DungeonsGuide.sendDebugChat(new ChatComponentText("Reached Milestone At " + TextUtils.formatTime(FeatureRegistry.DUNGEON_REALTIME.getTimeElapsed()) + " / "+TextUtils.formatTime(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed()))); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java deleted file mode 100644 index 90f6dd01..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.listener.DungeonEndListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonQuitListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonStartListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureDungeonRealTime extends TextHUDFeature implements DungeonStartListener, DungeonQuitListener { - public FeatureDungeonRealTime() { - super("Dungeon.Dungeon Information", "Display Real Time-Dungeon Time", "Display how much real time has passed since dungeon run started", "dungeon.stats.realtime", true, getFontRenderer().getStringWidth("Time(Real): 59m 59s"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("discriminator", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - private long started = -1; - - public long getTimeElapsed() { - return System.currentTimeMillis() - started; - } - - private static final java.util.List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Time","title")); - dummyText.add(new StyledText("(Real)","discriminator")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("-42h","number")); - } - - @Override - public boolean isHUDViewable() { - return started != -1; - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("title", "discriminator", "separator", "number"); - } - - @Override - public java.util.List getDummyText() { - return dummyText; - } - - @Override - public java.util.List getText() { - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Time","title")); - actualBit.add(new StyledText("(Real)","discriminator")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(TextUtils.formatTime(getTimeElapsed()),"number")); - return actualBit; - } - - @Override - public void onDungeonStart() { - started= System.currentTimeMillis(); - } - - @Override - public void onDungeonQuit() { - started = -1; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRoomName.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRoomName.java deleted file mode 100644 index 03217b30..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRoomName.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureDungeonRoomName extends TextHUDFeature { - public FeatureDungeonRoomName() { - super("Dungeon.Dungeon Information", "Display name of the room you are in", "Display name of the room you are in", "dungeon.roomname", false, getFontRenderer().getStringWidth("You're in puzzle-tictactoe"), getFontRenderer().FONT_HEIGHT); - getStyles().add(new TextStyle("in", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("roomname", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - public int getTotalSecretsInt() { - DungeonContext context = skyblockStatus.getContext(); - int totalSecrets = 0; - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - if (dungeonRoom.getTotalSecrets() != -1) - totalSecrets += dungeonRoom.getTotalSecrets(); - } - return totalSecrets; - } - - private static final List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("You're in ","in")); - dummyText.add(new StyledText("puzzle-tictactoe","roomname")); - } - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getMapProcessor() != null; - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("roomname", "in"); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public List getText() { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - - Point roomPt = skyblockStatus.getContext().getMapProcessor().worldPointToRoomPoint(player.getPosition()); - DungeonRoom dungeonRoom = skyblockStatus.getContext().getRoomMapper().get(roomPt); - List actualBit = new ArrayList(); - actualBit.add(new StyledText("You're in ","in")); - if (dungeonRoom == null) { - actualBit.add(new StyledText("Unknown","roomname")); - } else { - actualBit.add(new StyledText(dungeonRoom.getDungeonRoomInfo().getName(),"roomname")); - } - - - return actualBit; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java deleted file mode 100644 index c4591be8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.scoreboard.Score; -import net.minecraft.scoreboard.ScoreObjective; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Scoreboard; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -public class FeatureDungeonSBTime extends TextHUDFeature { - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - public FeatureDungeonSBTime() { - super("Dungeon.Dungeon Information", "Display Ingame Dungeon Time", "Display how much time skyblock thinks has passed since dungeon run started", "dungeon.stats.igtime", true, getFontRenderer().getStringWidth("Time(IG): 1h 59m 59s"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("discriminator", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - public int getTimeElapsed() { - Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); - ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - Collection scores = scoreboard.getSortedScores(objective); - String time = "idkyet"; - for (Score sc:scores) { - ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); - String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); - if (strippedLine.startsWith("Time Elapsed: ")) { - time = strippedLine.substring(14); - } - } - time = time.replace(" ", ""); - int hour = time.indexOf('h') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('h'))); - if (time.contains("h")) time = time.substring(time.indexOf('h') + 1); - int minute = time.indexOf('m') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('m'))); - if (time.contains("m")) time = time.substring(time.indexOf('m') + 1); - int second = time.indexOf('s') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('s'))); - - int time2 = hour * 60 * 60 + minute * 60 + second; - return time2 * 1000; - } - - private static final java.util.List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Time","title")); - dummyText.add(new StyledText("(Ig)","discriminator")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("-42h","number")); - } - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon(); - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("title", "discriminator", "separator", "number"); - } - - @Override - public java.util.List getDummyText() { - return dummyText; - } - - @Override - public java.util.List getText() { - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Time","title")); - actualBit.add(new StyledText("(Ig)","discriminator")); - actualBit.add(new StyledText(": ","separator")); - Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); - ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - Collection scores = scoreboard.getSortedScores(objective); - String time = "unknown"; - for (Score sc:scores) { - ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); - String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); - if (strippedLine.startsWith("Time Elapsed: ")) { - time = strippedLine.substring(14); - } - } - actualBit.add(new StyledText(time,"number")); - return actualBit; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java deleted file mode 100644 index 72aaabd6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.listener.StompConnectedListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.stomp.StompInterface; -import kr.syeyoung.dungeonsguide.stomp.StompMessageHandler; -import kr.syeyoung.dungeonsguide.stomp.StompPayload; -import kr.syeyoung.dungeonsguide.stomp.StompSubscription; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.TimeScoreUtil; -import kr.syeyoung.dungeonsguide.wsresource.StaticResource; -import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.MathHelper; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -public class FeatureDungeonScore extends TextHUDFeature { - public FeatureDungeonScore() { - super("Dungeon.Dungeon Information", "Display Current Score", "Calculate and Display current score\nThis data is from pure calculation and can be different from actual score.", "dungeon.stats.score", false, 200, getFontRenderer().FONT_HEIGHT * 4); - this.setEnabled(false); - parameters.put("verbose", new FeatureParameter("verbose", "Show each score instead of sum", "Skill: 100 Explore: 58 S->S+(5 tombs) instead of Score: 305", true, "boolean")); - - getStyles().add(new TextStyle("scorename", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("score", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("brackets", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("etc", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("currentScore", new AColor(0xFF, 0xAA,0x00,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("arrow", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("nextScore", new AColor(0xFF, 0xAA,0x00,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("required", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon(); - } - - private static final java.util.List dummyText= new ArrayList(); - private static final java.util.List dummyText2= new ArrayList(); - static { - dummyText.add(new StyledText("Score","scorename")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("305 ","score")); - dummyText.add(new StyledText("(","brackets")); - dummyText.add(new StyledText("S+","currentScore")); - dummyText.add(new StyledText(")","brackets")); - - - - dummyText2.add(new StyledText("Skill","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("100 ","score")); - dummyText2.add(new StyledText("(","brackets")); - dummyText2.add(new StyledText("0 Deaths","etc")); - dummyText2.add(new StyledText(")\n","brackets")); - dummyText2.add(new StyledText("Explorer","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("99 ","score")); - dummyText2.add(new StyledText("(","brackets")); - dummyText2.add(new StyledText("Rooms O Secrets 39/40","etc")); - dummyText2.add(new StyledText(")\n","brackets")); - dummyText2.add(new StyledText("Time","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("100 ","score")); - dummyText2.add(new StyledText("Bonus","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("0 ","score")); - dummyText2.add(new StyledText("Total","scorename")); - dummyText2.add(new StyledText(": ","separator")); - dummyText2.add(new StyledText("299\n","score")); - dummyText2.add(new StyledText("S","currentScore")); - dummyText2.add(new StyledText("->","arrow")); - dummyText2.add(new StyledText("S+ ","nextScore")); - dummyText2.add(new StyledText("(","brackets")); - dummyText2.add(new StyledText("1 Required 1 crypt","required")); - dummyText2.add(new StyledText(")","brackets")); - - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("scorename", "separator", "score", "brackets", "etc", "currentScore", "arrow", "nextScore", "required"); - - } - - @Override - public java.util.List getDummyText() { - - if (this.getParameter("verbose").getValue()) {return dummyText2;} else return dummyText; - } - - @Override - public java.util.List getText() { - List actualBit = new ArrayList(); - - ScoreCalculation score = calculateScore(); - if (score == null) return new ArrayList(); - int sum = score.time + score.skill + score.explorer + score.bonus; - if (this.getParameter("verbose").getValue()) { - actualBit.add(new StyledText("Skill", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(score.skill + " ", "score")); - actualBit.add(new StyledText("(", "brackets")); - actualBit.add(new StyledText(score.deaths + " Deaths", "etc")); - actualBit.add(new StyledText(")\n", "brackets")); - actualBit.add(new StyledText("Explorer", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(score.explorer + " ", "score")); - actualBit.add(new StyledText("(", "brackets")); - actualBit.add(new StyledText("Rooms " + (score.fullyCleared ? "O" : "X") + " Secrets " + score.secrets + "/" + score.effectiveTotalSecrets +" of "+score.getTotalSecrets() + (score.totalSecretsKnown ? "" : "?"), "etc")); - actualBit.add(new StyledText(")\n", "brackets")); - actualBit.add(new StyledText("Time", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(score.time + " ", "score")); - actualBit.add(new StyledText("Bonus", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(score.bonus + " ", "score")); - actualBit.add(new StyledText("Total", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(sum + "\n", "score")); - actualBit.addAll(buildRequirement(score)); - } else { - String letter = getLetter(sum); - actualBit.add(new StyledText("Score", "scorename")); - actualBit.add(new StyledText(": ", "separator")); - actualBit.add(new StyledText(sum + " ", "score")); - actualBit.add(new StyledText("(", "brackets")); - actualBit.add(new StyledText(letter, "currentScore")); - actualBit.add(new StyledText(")", "brackets")); - } - - return actualBit; - } - - @Data - @AllArgsConstructor - public static class ScoreCalculation { - private int skill, explorer, time, bonus, tombs; - private boolean fullyCleared; - private int secrets, totalSecrets, effectiveTotalSecrets; - private boolean totalSecretsKnown; - private int deaths; - } - - public int getPercentage() { - return skyblockStatus.getPercentage(); - } - public int getCompleteRooms() { - for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); - if (name.startsWith("ยงr Completed Rooms: ยงr")) { - String milestone = TextUtils.stripColor(name).substring(18); - return Integer.parseInt(milestone); - } - } - return 0; - } - public int getTotalRooms() { - int compRooms = getCompleteRooms(); - if (compRooms == 0) return 100; - return (int) (100 * (compRooms / (double)getPercentage())); - } - public int getUndiscoveredPuzzles() { - int cnt = 0; - for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); - if (name.startsWith("ยงr ???: ")) { - cnt ++; - } - } - return cnt; - } - - public ScoreCalculation calculateScore() { - if (!skyblockStatus.isOnDungeon()) return null; - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return null; - if (!context.getMapProcessor().isInitialized()) return null; - - int skill = 100; - int deaths = 0; - { - deaths = FeatureRegistry.DUNGEON_DEATHS.getTotalDeaths(); - skill -= FeatureRegistry.DUNGEON_DEATHS.getTotalDeaths() * 2; - int totalCompRooms= 0; - int roomCnt = 0; - int roomSkillPenalty = 0; -// boolean bossroomIncomplete = true; - boolean traproomIncomplete = context.isTrapRoomGen(); - int incompletePuzzles = getUndiscoveredPuzzles(); - - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { -// if (dungeonRoom.getColor() == 74 && dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED) -// bossroomIncomplete = false; - if (dungeonRoom.getColor() == 62 && dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED) - traproomIncomplete = false; - if (dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED) - totalCompRooms += dungeonRoom.getUnitPoints().size(); - if (dungeonRoom.getColor() == 66 && (dungeonRoom.getCurrentState() == DungeonRoom.RoomState.DISCOVERED || dungeonRoom.getCurrentState() == DungeonRoom.RoomState.FAILED)) // INCOMPLETE PUZZLE ON MAP - incompletePuzzles++; - roomCnt += dungeonRoom.getUnitPoints().size(); - } - roomSkillPenalty += incompletePuzzles * 10; - if (context.getMapProcessor().getUndiscoveredRoom() != 0) - roomCnt = getTotalRooms(); - roomSkillPenalty += (roomCnt - totalCompRooms) * 4; -// if (bossroomIncomplete) roomSkillPenalty -=1; - if (traproomIncomplete) roomSkillPenalty -=1; - - - skill -= roomSkillPenalty; - - - - skill = MathHelper.clamp_int(skill, 0, 100); - } - int explorer = 0; - boolean fullyCleared = false; - boolean totalSecretsKnown = true; - int totalSecrets = 0; - int secrets = 0; - { - int completed = 0; - double total = 0; - - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - if (dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED && dungeonRoom.getCurrentState() != DungeonRoom.RoomState.FAILED) - completed += dungeonRoom.getUnitPoints().size(); - total += dungeonRoom.getUnitPoints().size(); - } - - totalSecrets = FeatureRegistry.DUNGEON_SECRETS.getTotalSecretsInt() ; - totalSecretsKnown = FeatureRegistry.DUNGEON_SECRETS.sureOfTotalSecrets(); - - fullyCleared = completed >= getTotalRooms() && context.getMapProcessor().getUndiscoveredRoom() == 0; - explorer += MathHelper.clamp_int((int) Math.floor(6.0 / 10.0 * (context.getMapProcessor().getUndiscoveredRoom() != 0 ? getPercentage() : completed / total * 100)), 0, 60); - explorer += MathHelper.clamp_int((int) Math.floor(40 * (secrets = FeatureRegistry.DUNGEON_SECRETS.getSecretsFound()) / Math.ceil(totalSecrets * context.getSecretPercentage())),0,40); - } - int time = 0; - { - int maxTime = context.getMaxSpeed(); -// int timeSec = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000 - maxTime + 480; -// -// if (timeSec <= 480) time = 100; -// else if (timeSec <= 580) time = (int) Math.ceil(148 - 0.1 * timeSec); -// else if (timeSec <= 980) time = (int) Math.ceil(119 - 0.05 * timeSec); -// else if (timeSec < 3060) time = (int) Math.ceil(3102 - (1/30.0) * timeSec); -// time = MathHelper.clamp_int(time, 0, 100); // just in case. - time = TimeScoreUtil.estimate(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed(), maxTime); - } - int bonus = 0; - int tombs; - { - bonus += tombs = MathHelper.clamp_int(FeatureRegistry.DUNGEON_TOMBS.getTombsFound(), 0, 5); - if (context.isGotMimic()) bonus += 2; - CompletableFuture staticResourceCompletableFuture = StaticResourceCache.INSTANCE.getResource(StaticResourceCache.BONUS_SCORE); - if (staticResourceCompletableFuture.isDone()) { - try { - bonus += Integer.parseInt(staticResourceCompletableFuture.get().getValue().trim()); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - } - - // amazing thing - return new ScoreCalculation(skill, explorer, time, bonus, tombs, fullyCleared, secrets, totalSecrets, (int)Math.ceil (totalSecrets * context.getSecretPercentage()), totalSecretsKnown, deaths); - } - public String getLetter(int score) { - if (score <= 99) return "D"; - if (score <= 159) return "C"; - if (score <= 229) return "B"; - if (score <= 269) return "A"; - if (score <= 299) return "S"; - return "S+"; - } - public int getScoreRequirement(String letter) { - if (letter.equals("D")) return 0; - if (letter.equals("C")) return 100; - if (letter.equals("B")) return 160; - if (letter.equals("A")) return 230; - if (letter.equals("S")) return 270; - if (letter.equals("S+")) return 300; - return -1; - } - public String getNextLetter(String letter) { - if (letter.equals("D")) return "C"; - if (letter.equals("C")) return "B"; - if (letter.equals("B")) return "A"; - if (letter.equals("A")) return "S"; - if (letter.equals("S")) return "S+"; - else return null; - } - public List buildRequirement(ScoreCalculation calculation) { - List actualBit = new ArrayList(); - int current = calculation.time + calculation.bonus + calculation.explorer + calculation.skill; - String currentLetter = getLetter(current); - String nextLetter= getNextLetter(currentLetter); - if (nextLetter == null) { - actualBit.add(new StyledText("S+ Expected","nextScore")); - return actualBit; - } - int req = getScoreRequirement(nextLetter); - int reqPT2 = req- current; - int reqPT = req - current; - - int tombsBreakable = Math.min(5 - calculation.tombs, reqPT); - reqPT -= tombsBreakable; - - double secretPer = 40.0 / calculation.effectiveTotalSecrets; - int secrets = (int) Math.ceil(reqPT / secretPer); - - actualBit.add(new StyledText(currentLetter,"currentScore")); - actualBit.add(new StyledText("->","arrow")); - actualBit.add(new StyledText(nextLetter+" ","nextScore")); - actualBit.add(new StyledText("(","brackets")); - actualBit.add(new StyledText(reqPT2+" required "+tombsBreakable+" crypt "+secrets+" secrets","required")); - actualBit.add(new StyledText(")","brackets")); - return actualBit; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java deleted file mode 100644 index 57174669..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureDungeonSecrets extends TextHUDFeature { - public FeatureDungeonSecrets() { - super("Dungeon.Dungeon Information", "Display Total # of Secrets", "Display how much total secrets have been found in a dungeon run.\n+ sign means DG does not know the correct number, but it's somewhere above that number.", "dungeon.stats.secrets", true, getFontRenderer().getStringWidth("Secrets: 999/999+ of 999+"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("currentSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("totalSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("unknown", new AColor(0xFF, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - public int getSecretsFound() { - for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); - if (name.startsWith("ยงr Secrets Found: ยงrยงb") && !name.contains("%")) { - String noColor = TextUtils.stripColor(name); - return Integer.parseInt(noColor.substring(16)); - } - } - return 0; - } - public double getSecretPercentage() { - for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); - if (name.startsWith("ยงr Secrets Found: ยงr") && name.contains("%")) { - String noColor = TextUtils.stripColor(name); - return Double.parseDouble(noColor.substring(16).replace("%", "")); - } - } - return 0; - } - - public int getTotalSecretsInt() { - if (getSecretsFound() != 0) return (int) Math.ceil (getSecretsFound() / getSecretPercentage() * 100); - DungeonContext context = skyblockStatus.getContext(); - int totalSecrets = 0; - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - if (dungeonRoom.getTotalSecrets() != -1) - totalSecrets += dungeonRoom.getTotalSecrets(); - } - return totalSecrets; - } - public boolean sureOfTotalSecrets() { - if (getSecretsFound() != 0) return true; - DungeonContext context = skyblockStatus.getContext(); - if (context.getMapProcessor().getUndiscoveredRoom() > 0) return false; - boolean allknown = true; - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - if (dungeonRoom.getTotalSecrets() == -1) allknown = false; - } - return allknown; - } - - public String getTotalSecrets() { - DungeonContext context = skyblockStatus.getContext(); - if (context == null) return "?"; - int totalSecrets = 0; - boolean allknown = true; - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - if (dungeonRoom.getTotalSecrets() != -1) - totalSecrets += dungeonRoom.getTotalSecrets(); - else allknown = false; - } - return totalSecrets + (allknown ? "":"+"); - } - - - private static final java.util.List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Secrets","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("999","currentSecrets")); - dummyText.add(new StyledText("/","separator2")); - dummyText.add(new StyledText("2","totalSecrets")); - dummyText.add(new StyledText("+","unknown")); - } - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon(); - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("title", "separator", "currentSecrets", "separator2", "totalSecrets", "unknown"); - } - - @Override - public java.util.List getDummyText() { - return dummyText; - } - - @Override - public java.util.List getText() { - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Secrets","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(getSecretsFound() +"","currentSecrets")); - actualBit.add(new StyledText("/","separator2")); - actualBit.add(new StyledText((int)Math.ceil(getTotalSecretsInt() * DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getSecretPercentage())+" of "+getTotalSecretsInt(),"totalSecrets")); - actualBit.add(new StyledText(getTotalSecrets().contains("+") ? "+" : "","unknown")); - return actualBit; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java deleted file mode 100644 index 4a3fb2cd..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.scoreboard.ScorePlayerTeam; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureDungeonTombs extends TextHUDFeature { - public FeatureDungeonTombs() { - super("Dungeon.Dungeon Information", "Display # of Crypts", "Display how much total crypts have been blown up in a dungeon run", "dungeon.stats.tombs", true, getFontRenderer().getStringWidth("Crypts: 42"), getFontRenderer().FONT_HEIGHT); - this.setEnabled(false); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - public int getTombsFound() { - for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { - String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); - if (name.startsWith("ยงr Crypts: ยงrยง6")) { - return Integer.parseInt(TextUtils.stripColor(name).substring(9)); - } - } - return 0; - } - - private static final java.util.List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Crypts","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("42","number")); - } - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon(); - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("title", "separator", "number"); - } - - @Override - public java.util.List getDummyText() { - return dummyText; - } - - @Override - public java.util.List getText() { - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Crypts","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(getTombsFound()+"","number")); - return actualBit; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureHideNameTags.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureHideNameTags.java deleted file mode 100644 index 13836a73..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureHideNameTags.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.EntityLivingRenderListener; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraftforge.client.event.RenderLivingEvent; - - -public class FeatureHideNameTags extends SimpleFeature implements EntityLivingRenderListener { - public FeatureHideNameTags() { - super("Dungeon.Mobs", "Hide mob nametags", "Hide mob nametags in dungeon", "dungeon.hidenametag", false); - } - - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - @Override - public void onEntityRenderPre(RenderLivingEvent.Pre renderPlayerEvent) { - if (!isEnabled()) return; - if (!skyblockStatus.isOnDungeon()) return; - - if (renderPlayerEvent.entity instanceof EntityArmorStand) { - EntityArmorStand armorStand = (EntityArmorStand) renderPlayerEvent.entity; - if (armorStand.getAlwaysRenderNameTag()) - renderPlayerEvent.setCanceled(true); - } - } - - @Override - public void onEntityRenderPost(RenderLivingEvent.Post renderPlayerEvent) { - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePlayerESP.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePlayerESP.java deleted file mode 100644 index 1609a5c2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePlayerESP.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.PlayerRenderListener; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.event.RenderPlayerEvent; -import org.lwjgl.opengl.GL11; - - -public class FeaturePlayerESP extends SimpleFeature implements PlayerRenderListener { - public FeaturePlayerESP() { - super("Dungeon.Teammates", "See players through walls", "See players through walls", "dungeon.playeresp", false); - setEnabled(false); - } - - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - private boolean preCalled = false; - @Override - public void onEntityRenderPre(RenderPlayerEvent.Pre renderPlayerEvent) { - - - if (preCalled) return; - if (!isEnabled()) return; - - - DungeonContext dungeonContext = skyblockStatus.getContext(); - if (dungeonContext == null) return; - if (!dungeonContext.getPlayers().contains(renderPlayerEvent.entityPlayer.getName())) { - return; - } - - preCalled = true; - - GL11.glEnable(GL11.GL_STENCIL_TEST); - GL11.glClearStencil(0); - GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); - - GL11.glStencilMask(0xFF); - GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); - GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); - - EntityPlayer entity = renderPlayerEvent.entityPlayer; - InventoryPlayer inv = entity.inventory; - ItemStack[] armor = inv.armorInventory; - inv.armorInventory = new ItemStack[4]; - ItemStack[] hand = inv.mainInventory; - inv.mainInventory = new ItemStack[36]; - - float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * renderPlayerEvent.partialRenderTick; - try { - renderPlayerEvent.renderer.doRender((AbstractClientPlayer) renderPlayerEvent.entityPlayer, renderPlayerEvent.x, renderPlayerEvent.y, renderPlayerEvent.z, f, renderPlayerEvent.partialRenderTick); - } catch (Throwable t) {} - - GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); - GL11.glStencilFunc(GL11.GL_NOTEQUAL, 1, 0xff); - GL11.glDepthMask(false); - GL11.glDepthFunc(GL11.GL_GEQUAL); - - GlStateManager.pushMatrix(); - GlStateManager.translate(renderPlayerEvent.x, renderPlayerEvent.y + 0.9, renderPlayerEvent.z); - GlStateManager.scale(1.2f, 1.1f, 1.2f); - renderPlayerEvent.renderer.setRenderOutlines(true); - try { - renderPlayerEvent.renderer.doRender((AbstractClientPlayer) renderPlayerEvent.entityPlayer, 0,-0.9,0, f, renderPlayerEvent.partialRenderTick); - } catch (Throwable t) {} - - renderPlayerEvent.renderer.setRenderOutlines(false); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GlStateManager.popMatrix(); - - GL11.glDisable(GL11.GL_STENCIL_TEST); // Turn this shit off! - - inv.armorInventory = armor; - inv.mainInventory = hand; - - preCalled = false; - - } - - @Override - public void onEntityRenderPost(RenderPlayerEvent.Post renderPlayerEvent) { - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java deleted file mode 100644 index e0dc7f97..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.impl.boss.FeatureChestPrice; -import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener; -import kr.syeyoung.dungeonsguide.features.listener.KeyInputListener; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.IInventory; -import net.minecraftforge.client.event.GuiScreenEvent; -import org.lwjgl.input.Mouse; - -public class FeaturePressAnyKeyToCloseChest extends SimpleFeature implements KeyInputListener, GuiClickListener { - public FeaturePressAnyKeyToCloseChest() { - super("Dungeon", "Press Any Mouse Button or Key to close Secret Chest", "dungeon.presskeytoclose"); - parameters.put("threshold", new FeatureParameter("threshold", "Price Threshold", "The maximum price of item for chest to be closed. Default 1m", 1000000, "integer")); - } - - @Override - public void onKeyInput(GuiScreenEvent.KeyboardInputEvent keyboardInputEvent) { - GuiScreen screen = Minecraft.getMinecraft().currentScreen; - if (!isEnabled()) return; - if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; - - if (screen instanceof GuiChest){ - ContainerChest ch = (ContainerChest) ((GuiChest)screen).inventorySlots; - if (!("Large Chest".equals(ch.getLowerChestInventory().getName()) - || "Chest".equals(ch.getLowerChestInventory().getName()))) return; - IInventory actualChest = ch.getLowerChestInventory(); - - int priceSum = 0; - for (int i = 0; i < actualChest.getSizeInventory(); i++) { - priceSum += FeatureChestPrice.getPrice(actualChest.getStackInSlot(i)); - } - - int threshold = this.getParameter("threshold").getValue(); - if (priceSum < threshold) { - Minecraft.getMinecraft().thePlayer.closeScreen(); - } - } - } - - @Override - public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { - GuiScreen screen = Minecraft.getMinecraft().currentScreen; - if (!isEnabled()) return; - if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; - if (Mouse.getEventButton() == -1) return; - - if (screen instanceof GuiChest){ - ContainerChest ch = (ContainerChest) ((GuiChest)screen).inventorySlots; - if (!("Large Chest".equals(ch.getLowerChestInventory().getName()) - || "Chest".equals(ch.getLowerChestInventory().getName()))) return; - IInventory actualChest = ch.getLowerChestInventory(); - - int priceSum = 0; - for (int i = 0; i < actualChest.getSizeInventory(); i++) { - priceSum += FeatureChestPrice.getPrice(actualChest.getStackInSlot(i)); - } - - int threshold = this.getParameter("threshold").getValue(); - if (priceSum < threshold) { - Minecraft.getMinecraft().thePlayer.closeScreen(); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java deleted file mode 100644 index 6b990f7c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.scoreboard.Score; -import net.minecraft.scoreboard.ScoreObjective; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Scoreboard; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - - -public class FeatureWarnLowHealth extends TextHUDFeature { - public FeatureWarnLowHealth() { - super("Dungeon.Teammates", "Low Health Warning", "Warn if someone is on low health", "dungeon.lowhealthwarn", false, 500, 20); - parameters.put("threshold", new FeatureParameter("threshold", "Health Threshold", "Health Threshold for this feature to be toggled. default to 500", 500, "integer")); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("unit", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - setEnabled(false); - } - - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnDungeon(); - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("title", "separator", "number", "unit"); - } - - private static final java.util.List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("DungeonsGuide","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("500","number")); - dummyText.add(new StyledText("hp","unit")); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public List getText() { - String lowestHealthName = ""; - int lowestHealth = 999999999; - Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); - ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - for (Score sc : scoreboard.getSortedScores(objective)) { - ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); - String line = ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()).trim(); - String stripped = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(line)); - if (line.contains("[") && line.endsWith("โค")) { - String name = stripped.split(" ")[stripped.split(" ").length - 2]; - int health = Integer.parseInt(stripped.split(" ")[stripped.split(" ").length - 1]); - if (health < lowestHealth) { - lowestHealth = health; - lowestHealthName = name; - } - } - } - if (lowestHealth > this.getParameter("threshold").getValue()) return new ArrayList(); - - List actualBit = new ArrayList(); - actualBit.add(new StyledText(lowestHealthName,"title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText(lowestHealth+"","number")); - actualBit.add(new StyledText("hp","unit")); - return actualBit; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWatcherWarning.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWatcherWarning.java deleted file mode 100644 index d9354137..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWatcherWarning.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.dungeon; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonEndListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; - -public class FeatureWatcherWarning extends TextHUDFeature implements ChatListener, DungeonEndListener { - - public FeatureWatcherWarning() { - super("Dungeon.Blood Room","Watcher Spawn Alert", "Alert when watcher says 'That will be enough for now'", "dungen.watcherwarn", true, getFontRenderer().getStringWidth("Watcher finished spawning all mobs!"), getFontRenderer().FONT_HEIGHT); - getStyles().add(new TextStyle("warning", new AColor(0xFF, 0x69,0x17,255), new AColor(0, 0,0,0), false)); - setEnabled(false); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public boolean isHUDViewable() { - return warning > System.currentTimeMillis(); - } - - @Override - public List getUsedTextStyle() { - return Collections.singletonList("warning"); - } - - private final UUID lastRoomUID = UUID.randomUUID(); - private long warning = 0; - - private static final List text = new ArrayList(); - static { - text.add(new StyledText("Watcher finished spawning all mobs!", "warning")); - } - - @Override - public List getText() { - return text; - } - - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (clientChatReceivedEvent.message.getFormattedText().equals("ยงrยงc[BOSS] The Watcherยงrยงf: That will be enough for now.ยงr")) { - warning = System.currentTimeMillis() + 2500; - DungeonContext context = skyblockStatus.getContext(); - if (context ==null) return; - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - if (dungeonRoom != null && dungeonRoom.getColor() == 18) - dungeonRoom.setCurrentState(DungeonRoom.RoomState.DISCOVERED); - } - } - } - - @Override - public void onDungeonEnd() { - warning = 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java deleted file mode 100644 index 0cb126ef..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.chat.ChatProcessor; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -public class FeatureAutoAcceptReparty extends SimpleFeature implements ChatListener { - public FeatureAutoAcceptReparty() { - super("Party.Reparty", "Auto accept reparty", "Automatically accept reparty", "qol.autoacceptreparty", true); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - private String lastDisband; - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (clientChatReceivedEvent.message.getFormattedText().endsWith("ยงehas disbanded the party!ยงr")) { - lastDisband = null; - String[] texts = TextUtils.stripColor(clientChatReceivedEvent.message.getFormattedText()).split(" "); - for (String s : texts) { - if (s.isEmpty()) continue; - if (s.startsWith("[")) continue; - if (s.equalsIgnoreCase("has")) break; - lastDisband = s; - break; - } - } else if (clientChatReceivedEvent.message.getFormattedText().contains("ยงehas invited you to join their party!")) { - String[] texts = TextUtils.stripColor(clientChatReceivedEvent.message.getFormattedText()).split(" "); - boolean equals = false; - for (String s : texts) { - if (s.isEmpty()) continue; - if (s.startsWith("[")) continue; - if (s.equalsIgnoreCase("has")) continue; - if (s.equalsIgnoreCase(lastDisband)) { - equals = true; - break; - } - } - - if (equals && isEnabled()) { - ChatProcessor.INSTANCE.addToChatQueue("/p accept " + lastDisband, () -> {}, true); - lastDisband = null; - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java deleted file mode 100644 index 2bdf607e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.features.listener.DungeonQuitListener; -import kr.syeyoung.dungeonsguide.features.listener.GuiOpenListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.inventory.ContainerChest; -import net.minecraftforge.client.event.GuiOpenEvent; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureCooldownCounter extends TextHUDFeature implements DungeonQuitListener, GuiOpenListener { - public FeatureCooldownCounter() { - super("Dungeon", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, getFontRenderer().getStringWidth("Cooldown: 10s "), getFontRenderer().FONT_HEIGHT); - getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - } - - private long leftDungeonTime = 0L; - - private static final java.util.List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Cooldown","title")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("20s","number")); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public boolean isHUDViewable() { - return System.currentTimeMillis() - leftDungeonTime < 20000; - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("title", "separator", "number"); - } - - @Override - public List getText() { - List actualBit = new ArrayList(); - actualBit.add(new StyledText("Cooldown","title")); - actualBit.add(new StyledText(": ","separator")); - actualBit.add(new StyledText((20 - (System.currentTimeMillis() - leftDungeonTime) / 1000)+"s","number")); - return actualBit; - } - - @Override - public boolean doesScaleWithHeight() { - return true; - } - - @Override - public void onDungeonQuit() { - leftDungeonTime = System.currentTimeMillis(); - } - - @Override - public void onGuiOpen(GuiOpenEvent rendered) { - if (!(rendered.gui instanceof GuiChest)) return; - ContainerChest chest = (ContainerChest) ((GuiChest) rendered.gui).inventorySlots; - if (chest.getLowerChestInventory().getName().contains("On cooldown!")) { - leftDungeonTime = System.currentTimeMillis(); - } else if (chest.getLowerChestInventory().getName().contains("Error")) { - leftDungeonTime = System.currentTimeMillis(); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCopyMessages.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCopyMessages.java deleted file mode 100644 index cda0eb7a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCopyMessages.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.event.ClickEvent; -import net.minecraft.event.HoverEvent; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -public class FeatureCopyMessages extends SimpleFeature implements ChatListener { - public FeatureCopyMessages() { - super("Misc.Chat", "Copy Chat Messages", "Click on copy to copy", "etc.copymsg"); - setEnabled(false); - } - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (!isEnabled()) return; - if (clientChatReceivedEvent.type == 2) return; - - clientChatReceivedEvent.message.appendSibling(new ChatComponentText(" ยง7[Copy]").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, TextUtils.stripColor(clientChatReceivedEvent.message.getFormattedText()))).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("ยงeCopy Message"))))); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDecreaseExplosionSound.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDecreaseExplosionSound.java deleted file mode 100644 index a382e646..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDecreaseExplosionSound.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.SoundListener; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraftforge.client.event.sound.PlaySoundEvent; - -public class FeatureDecreaseExplosionSound extends SimpleFeature implements SoundListener { - public FeatureDecreaseExplosionSound() { - super("Misc", "Decrease Explosion sound effect", "Decreases volume of explosions while on skyblock", "qol.explosionsound"); - parameters.put("sound", new FeatureParameter("sound", "Sound Multiplier %", "The volume of explosion effect will be multiplied by this value. 0~100", 10.0f, "float")); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - @Override - public void onSound(PlaySoundEvent soundEvent) { - if (!skyblockStatus.isOnSkyblock()) return; - - if (soundEvent.name.equalsIgnoreCase("random.explode") && soundEvent.result instanceof PositionedSoundRecord) { - PositionedSoundRecord positionedSoundRecord = (PositionedSoundRecord) soundEvent.result; - PositionedSoundRecord neweff = new PositionedSoundRecord( - positionedSoundRecord.getSoundLocation(), - positionedSoundRecord.getVolume() * (this.getParameter("sound").getValue() / 100), - positionedSoundRecord.getPitch(), - positionedSoundRecord.getXPosF(), - positionedSoundRecord.getYPosF(), - positionedSoundRecord.getZPosF() - ); - - soundEvent.result = neweff; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDisableMessage.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDisableMessage.java deleted file mode 100644 index b530a444..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDisableMessage.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.regex.Pattern; - -public class FeatureDisableMessage extends SimpleFeature implements ChatListener { - @Data - @AllArgsConstructor - public static class MessageData { - private Pattern pattern; - private String name; - private String description; - private String key; - } - - private static final MessageData[] PRE_DEFINED = new MessageData[] { - new MessageData(Pattern.compile("ยงrยงcThere are blocks in the way!ยงr"), "Aote block message", "\"There are blocks in the way!\"", "aote"), - new MessageData(Pattern.compile("ยงrยงcThis ability is currently on cooldown for .+ more seconds?\\.ยงr"), "Ability cooldown message", "\"This ability is currently on cooldown for 3 more seconds.\"", "cooldown"), - new MessageData(Pattern.compile("ยงrยงcThis ability is on cooldown for .+s\\.ยงr"), "Ability cooldown message2", "\"This ability is on cooldown for 3s.\"", "cooldown2"), - new MessageData(Pattern.compile("ยงrยงcWhow! Slow down there!ยงr"), "Grappling hook cooldown", "\"Whow! Slow down there!\"", "grappling"), - new MessageData(Pattern.compile("ยงrยงcNo more charges, next one in ยงrยงe.+ยงrยงcs!ยงr"), "Zombie Sword Charging", "\"No more charges, next one in 3s!\"", "zombie"), - new MessageData(Pattern.compile("ยงrยง7Your .+ hit ยงrยงc.+ ยงrยง7enem(?:y|ies) for ยงrยงc.+ ยงrยง7damage\\.ยงr"), "Ability Damage", "\"Your blahblah hit 42 enemy for a lots of damage\"", "ability"), - new MessageData(Pattern.compile("ยงrยงcYou do not have enough mana to do this!ยงr"), "Not enough mana", "\"You do not have enough mana to do this!\"", "mana"), - new MessageData(Pattern.compile("ยงrยงaUsed ยงr.+ยงrยงa!ยงr"), "Dungeon Ability Usage", "\"Used Guided Sheep!\" and such", "dungeonability"), - new MessageData(Pattern.compile("ยงr.+ยงrยงa is ready to use! Press ยงr.+ยงrยงa to activate it!ยงr"), "Ready to use message", "\"Blah is ready to use! Press F to activate it!", "readytouse"), - new MessageData(Pattern.compile("ยงr.+ ยงrยงais now available!ยงr"), "Ability Available","\"blah is now available!\"", "available"), - new MessageData(Pattern.compile("ยงrยงcThe Stone doesn't seem to do anything here\\.ยงr"), "Stone Message", "\"The Stone doesn't seem to do anything here\"", "stone"), - new MessageData(Pattern.compile("ยงrยงcNo target found!ยงr"), "Voodoo Doll No Target", "\"No target found!\"", "voodotarget") - }; - - public FeatureDisableMessage() { - super("Misc.Chat", "Disable ability messages", "Do not let ability messages show up in chatbox\nclick on Edit for more precise settings", "fixes.messagedisable", true); - for (MessageData messageData : PRE_DEFINED) { - this.parameters.put(messageData.key, new FeatureParameter(messageData.key, messageData.name, messageData.description, true, "boolean")); - } - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (clientChatReceivedEvent.type == 2) return; - if (!isEnabled()) return; - if (!skyblockStatus.isOnSkyblock()) return; - String msg = clientChatReceivedEvent.message.getFormattedText(); - for (MessageData md:PRE_DEFINED) { - if (this.getParameter(md.key).getValue() && md.pattern.matcher(msg).matches()) { - clientChatReceivedEvent.setCanceled(true); - return; - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeaturePenguins.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeaturePenguins.java deleted file mode 100644 index f00a34d8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeaturePenguins.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import com.google.common.collect.ImmutableMap; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.PlayerRenderListener; -import kr.syeyoung.dungeonsguide.features.listener.TextureStichListener; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.EntityRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.renderer.texture.TextureUtil; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.*; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.client.model.IModel; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.ModelLoaderRegistry; -import net.minecraftforge.client.model.obj.OBJLoader; -import net.minecraftforge.client.model.obj.OBJModel; -import net.minecraftforge.fml.relauncher.ReflectionHelper; - -import java.io.IOException; -import java.util.List; - - -public class FeaturePenguins extends SimpleFeature implements PlayerRenderListener, TextureStichListener { - public FeaturePenguins() { - super("Misc", "Penguins", "Awwww", "etc.penguin", false); - OBJLoader.instance.addDomain("dungeonsguide"); - - } - @Override - public void onTextureStitch(TextureStitchEvent event) { - if (event instanceof TextureStitchEvent.Pre) { - objModel = null; - ResourceLocation modelResourceLocation = new ResourceLocation("dungeonsguide:models/penguin.obj"); - try { - objModel = (OBJModel) OBJLoader.instance.loadModel(modelResourceLocation); - objModel = (OBJModel) objModel.process(new ImmutableMap.Builder().put("flip-v", "true").build()); - for (String obj : objModel.getMatLib().getMaterialNames()) { - ResourceLocation resourceLocation = objModel.getMatLib().getMaterial(obj).getTexture().getTextureLocation(); - event.map.registerSprite(resourceLocation); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - if (objModel != null && event instanceof TextureStitchEvent.Post) { - model = objModel.bake(objModel.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); - } - } - - - private OBJModel objModel; - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - private IBakedModel model; - - @Override - public void onEntityRenderPre(RenderPlayerEvent.Pre renderPlayerEvent) { - - if (!isEnabled()) return; - if (renderPlayerEvent.entityPlayer.isInvisible()) return; - renderPlayerEvent.setCanceled(true); - GlStateManager.pushMatrix(); - GlStateManager.color(1,1,1,1); - GlStateManager.translate(renderPlayerEvent.x, renderPlayerEvent.y, renderPlayerEvent.z); - if (renderPlayerEvent.entityPlayer.isSneaking()) - { - GlStateManager.translate(0.0F, -0.203125F, 0.0F); - } - float f1 = renderPlayerEvent.entityPlayer.prevRotationYawHead + (renderPlayerEvent.entityPlayer.rotationYawHead - renderPlayerEvent.entityPlayer.prevRotationYawHead) * renderPlayerEvent.partialRenderTick; - GlStateManager.rotate(f1+180,0,-1,0); - Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); - - Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor( - model, 1,1,1,1 - ); - GlStateManager.popMatrix(); - - - EntityPlayer entitylivingbaseIn = renderPlayerEvent.entityPlayer; - { - ItemStack itemstack = entitylivingbaseIn.getHeldItem(); - - if (itemstack != null) - { - GlStateManager.pushMatrix(); - GlStateManager.translate(renderPlayerEvent.x, renderPlayerEvent.y, renderPlayerEvent.z); - if (renderPlayerEvent.entityPlayer.isSneaking()) - { - GlStateManager.translate(0.0F, -0.203125F, 0.0F); - } - GlStateManager.rotate(f1+180, 0.0f, -1.0f, 0.0f); - GlStateManager.translate(0,1.30 ,-0.5); - - - - if (entitylivingbaseIn.fishEntity != null) - { - itemstack = new ItemStack(Items.fishing_rod, 0); - } - - Item item = itemstack.getItem(); - Minecraft minecraft = Minecraft.getMinecraft(); - - GlStateManager.rotate(180, 0.0f, 0.0f, 1.0f); - if (item.isFull3D()) { - GlStateManager.translate(0.05,0,0); - GlStateManager.rotate(90, 0.0f, 0.0f, 1.0f); - GlStateManager.rotate(-45, 1.0f, 0.0f, 0.0f); - } else if (item instanceof ItemBow) { - GlStateManager.translate(0,0.1, -0); - GlStateManager.rotate(90, 0.0f, 1.0f, 0.0f); - GlStateManager.rotate(-90, 0.0f, 0.0f, 1.0f); - } else if (item instanceof ItemBlock && Block.getBlockFromItem(item).getRenderType() == 2) { - GlStateManager.translate(0,-0.20,0.1); - GlStateManager.translate(0.0F, 0.1875F, -0.3125F); - GlStateManager.rotate(-25.0F, 1.0F, 0.0F, 0.0F); - GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F); - f1 = 0.375F; - GlStateManager.scale(-f1, -f1, f1); - } else if (item instanceof ItemBlock) { - GlStateManager.translate(0.0F, 0.05, 0.1); - GlStateManager.rotate(-25.0F, 1.0F, 0.0F, 0.0F); - } else { - GlStateManager.translate(0,-0.1, 0.1); - } - - GlStateManager.scale(0.8,0.8,0.8); - - minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON); - GlStateManager.popMatrix(); - } - } - - - renderPlayerEvent.renderer.renderName((AbstractClientPlayer) renderPlayerEvent.entityPlayer, renderPlayerEvent.x, renderPlayerEvent.y, renderPlayerEvent.z); - - - } - - @Override - public void onEntityRenderPost(RenderPlayerEvent.Post renderPlayerEvent) { - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureRepartyCommand.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureRepartyCommand.java deleted file mode 100644 index ac01610d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureRepartyCommand.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeatureRepartyCommand extends SimpleFeature { - public FeatureRepartyCommand() { - super("Party.Reparty", "Enable Reparty Command From DG", "if you disable, /dg reparty will still work, Auto reparty will still work\nRequires Restart to get applied", "qol.reparty"); - parameters.put("command", new FeatureParameter("command", "The Command", "Command that the reparty will be bound to", "reparty", "string")); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureTooltipDungeonStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureTooltipDungeonStat.java deleted file mode 100644 index 12100aac..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureTooltipDungeonStat.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; - -public class FeatureTooltipDungeonStat extends SimpleFeature implements TooltipListener { - public FeatureTooltipDungeonStat() { - super("Misc", "Dungeon Item Stats", "Shows quality of dungeon items (floor, percentage)", "tooltip.dungeonitem"); - } - - @Override - public void onTooltip(ItemTooltipEvent event) { - if (!isEnabled()) return; - - ItemStack hoveredItem = event.itemStack; - NBTTagCompound compound = hoveredItem.getTagCompound(); - if (compound == null) - return; - if (!compound.hasKey("ExtraAttributes")) - return; - NBTTagCompound nbtTagCompound = compound.getCompoundTag("ExtraAttributes"); - - int floor = nbtTagCompound.getInteger("item_tier"); - int percentage = nbtTagCompound.getInteger("baseStatBoostPercentage"); - - if (nbtTagCompound.hasKey("item_tier")) - event.toolTip.add("ยง7Obtained in: ยงc"+(floor == 0 ? "Entrance" : "Floor "+floor)); - if (nbtTagCompound.hasKey("baseStatBoostPercentage")) - event.toolTip.add("ยง7Stat Percentage: ยง"+(percentage == 50 ? "6ยงl":"c")+(percentage * 2)+"%"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureTooltipPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureTooltipPrice.java deleted file mode 100644 index 29299f46..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureTooltipPrice.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; -import kr.syeyoung.dungeonsguide.utils.AhUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import org.lwjgl.input.Keyboard; - -import java.util.Comparator; -import java.util.Set; -import java.util.TreeSet; - -public class FeatureTooltipPrice extends SimpleFeature implements TooltipListener { - public FeatureTooltipPrice() { - super("Misc.API Features", "Item Price", "Shows price of items", "tooltip.price"); - parameters.put("reqShift", new FeatureParameter("reqShift", "Require Shift", "If shift needs to be pressed in order for this feature to be activated", false, "boolean")); - setEnabled(false); - } - - @Override - public void onTooltip(ItemTooltipEvent event) { - if (!isEnabled()) return; - - boolean activated = !this.getParameter("reqShift").getValue() || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - - ItemStack hoveredItem = event.itemStack; - NBTTagCompound compound = hoveredItem.getTagCompound(); - if (compound == null) - return; - if (!compound.hasKey("ExtraAttributes")) - return; - if (!activated) { - event.toolTip.add("ยง7Shift to view price"); - return; - } - - final String id = compound.getCompoundTag("ExtraAttributes").getString("id"); - if (id.equals("ENCHANTED_BOOK")) { - final NBTTagCompound enchants = compound.getCompoundTag("ExtraAttributes").getCompoundTag("enchantments"); - Set keys = enchants.getKeySet(); - Set actualKeys = new TreeSet(new Comparator() { - public int compare(String o1, String o2) { - String id2 = id + "::" + o1 + "-" + enchants.getInteger(o1); - AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); - long price1 = (auctionData == null) ? 0 : auctionData.lowestBin; - String id3 = id + "::" + o2 + "-" + enchants.getInteger(o2); - AhUtils.AuctionData auctionData2 = AhUtils.auctions.get(id3); - long price2 = (auctionData2 == null) ? 0 : auctionData2.lowestBin; - return (compare2(price1, price2) == 0) ? o1.compareTo(o2) : compare2(price1, price2); - } - - public int compare2(long y, long x) { - return (x < y) ? -1 : ((x == y) ? 0 : 1); - } - }); - actualKeys.addAll(keys); - int totalLowestPrice = 0; - int iterations = 0; - for (String key : actualKeys) { - iterations++; - String id2 = id + "::" + key + "-" + enchants.getInteger(key); - AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); - if (auctionData == null) { - if (iterations < 10) - event.toolTip.add("ยงf"+ key + " " + enchants.getInteger(key) + "ยง7: ยงcn/a"); - continue; - } - if (iterations < 10) - event.toolTip.add("ยงf"+ key + " " + enchants.getInteger(key) + "ยง7: ยงe"+ TextUtils.format( auctionData.lowestBin)); - totalLowestPrice += auctionData.lowestBin; - } - if (iterations >= 10) - event.toolTip.add("ยง7"+ (iterations - 10) + " more enchants... "); - event.toolTip.add("ยงfTotal Lowestยง7: ยงe"+ TextUtils.format(totalLowestPrice)); - } else { - AhUtils.AuctionData auctionData = AhUtils.auctions.get(id); - event.toolTip.add(""); - if (auctionData == null) { - event.toolTip.add("ยงfLowest ah ยง7: ยงcn/a"); - event.toolTip.add("ยงfBazaar sell price ยง7: ยงcn/a"); - event.toolTip.add("ยงfBazaar buy price ยง7: ยงcn/a"); - } else { - event.toolTip.add("ยงfLowest ah ยง7: " + ((auctionData.lowestBin != -1) ? ("ยงe"+ TextUtils.format(auctionData.lowestBin)) : "ยงcn/a")); - event.toolTip.add("ยงfBazaar sell price ยง7: " + ((auctionData.sellPrice == -1) ? "ยงcn/a": ("ยงe"+ TextUtils.format(auctionData.sellPrice)))); - event.toolTip.add("ยงfBazaar buy price ยง7: " + ((auctionData.buyPrice == -1) ? "ยงcn/a": ("ยงe"+ TextUtils.format(auctionData.buyPrice)))); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureUpdateAlarm.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureUpdateAlarm.java deleted file mode 100644 index a3ee878c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureUpdateAlarm.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc; - -import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.StompConnectedListener; -import kr.syeyoung.dungeonsguide.features.listener.TickListener; -import kr.syeyoung.dungeonsguide.stomp.StompInterface; -import kr.syeyoung.dungeonsguide.stomp.StompMessageHandler; -import kr.syeyoung.dungeonsguide.stomp.StompPayload; -import kr.syeyoung.dungeonsguide.stomp.StompSubscription; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ChatComponentText; - -public class FeatureUpdateAlarm extends SimpleFeature implements StompConnectedListener, StompMessageHandler, TickListener { - public FeatureUpdateAlarm() { - super("Misc", "Update Alarm","Show a warning in chat when a version has been released.", "etc.updatealarm", true); - } - - private StompPayload stompPayload; - @Override - public void handle(StompInterface stompInterface, StompPayload stompPayload) { - this.stompPayload = stompPayload; - } - - @Override - public void onTick() { - if (stompPayload != null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(stompPayload.payload())); - stompPayload = null; - Minecraft.getMinecraft().thePlayer.playSound("random.successful_hit", 1f,1f); - } - } - - @Override - public void onStompConnected(StompConnectedEvent event) { - event.getStompInterface().subscribe(StompSubscription.builder() - .destination("/topic/updates") - .ackMode(StompSubscription.AckMode.AUTO) - .stompMessageHandler(this).build()); - event.getStompInterface().subscribe(StompSubscription.builder() - .destination("/user/queue/messages") - .ackMode(StompSubscription.AckMode.AUTO) - .stompMessageHandler(this).build()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java deleted file mode 100644 index 7b18a3f5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc.ability; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.TickListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.math.MathContext; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class FeatureAbilityCooldown extends TextHUDFeature implements ChatListener, TickListener { - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - public FeatureAbilityCooldown() { - super("Misc", "View Ability Cooldowns", "A handy hud for viewing cooldown abilities", "etc.abilitycd2", false, 100, getFontRenderer().FONT_HEIGHT * 5); - getStyles().add(new TextStyle("abilityname", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("unit",new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("ready",new AColor(0xDF, 0x00,0x67,255), new AColor(0, 0,0,0), false)); - this.parameters.put("disable", new FeatureParameter("disable", "Disable outside of dungeon", "Disable the feature when out of dungeon", false, "boolean")); - this.parameters.put("decimal", new FeatureParameter("decimal", "Decimal places", "ex) 2 -> Cooldown: 3.21 3-> Cooldown: 3.210", 0, "integer")); - } - - @Override - public boolean isHUDViewable() { - return skyblockStatus.isOnSkyblock() && (!this.getParameter("disable").getValue() || (this.getParameter("disable").getValue() && skyblockStatus.isOnDungeon())); - } - - @Override - public boolean doesScaleWithHeight() { - return false; - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("abilityname", "separator", "number", "unit", "ready"); - } - - private static final List dummy = new ArrayList<>(); - - static { - dummy.add(new StyledText("Random Ability", "abilityname")); - dummy.add(new StyledText(": ", "separator")); - dummy.add(new StyledText("10", "number")); - dummy.add(new StyledText("s\n", "unit")); - dummy.add(new StyledText("Random Ability2", "abilityname")); - dummy.add(new StyledText(": ", "separator")); - dummy.add(new StyledText("10", "number")); - dummy.add(new StyledText("m ", "unit")); - dummy.add(new StyledText("9", "number")); - dummy.add(new StyledText("s\n", "unit")); - dummy.add(new StyledText("Random Ability", "abilityname")); - dummy.add(new StyledText(": ", "separator")); - dummy.add(new StyledText("READY", "ready")); - } - - @Override - public List getDummyText() { - return dummy; - } - - private static final Map skyblockAbilities = new HashMap<>(); - private static final Map> skyblockAbilitiesByItemID = new HashMap<>(); - - static { - register(new SkyblockAbility("Disgusting Healing", -1, -1, "REAPER_MASK")); - register(new SkyblockAbility("Spirit Leap", -1, 5, "SPIRIT_LEAP")); - register(new SkyblockAbility("Farmer's Grace", -1, -1, "RANCHERS_BOOTS")); - register(new SkyblockAbility("Raise Souls", -1, 1, "SUMMONING_RING")); - register(new SkyblockAbility("Instant Heal", 70, -1, "FLORID_ZOMBIE_SWORD")); - register(new SkyblockAbility("Phantom Impel", -1, -1, "PHANTOM_ROD")); - register(new SkyblockAbility("Implosion", 300, 10, "IMPLOSION_SCROLL")); - register(new SkyblockAbility("Parley", -1, 5, "ASPECT_OF_THE_JERRY")); - register(new SkyblockAbility("Guided Bat", 250, -1, "BAT_WAND")); - register(new SkyblockAbility("Bat Swarm", -1, -1, "WITCH_MASK")); - register(new SkyblockAbility("Flay", -1, -1, "SOUL_WHIP")); - register(new SkyblockAbility("Instant Heal", 70, -1, "ZOMBIE_SWORD")); - register(new SkyblockAbility("Mithril's Protection", -1, -1, "MITHRIL_COAT")); - register(new SkyblockAbility("Second Wind", -1, 30, "SPIRIT_MASK")); - register(new SkyblockAbility("Love Tap", -1, -1, "ZOMBIE_SOLDIER_CUTLASS")); - register(new SkyblockAbility("Spiky", -1, -1, "PUFFERFISH_HAT")); - register(new SkyblockAbility("Jingle Bells", -1, 1, "JINGLE_BELLS")); - register(new SkyblockAbility("Wither Shield", 150, 10, "WITHER_SHIELD_SCROLL")); - register(new SkyblockAbility("Wither Impact", 150, 5, "WITHER_SHIELD_SCROLL")); - register(new SkyblockAbility("Brute Force", -1, -1, "WARDEN_HELMET")); - register(new SkyblockAbility("Growth", -1, 4, "GROWTH_LEGGINGS")); - register(new SkyblockAbility("Shadowstep", -1, 60, "SILENT_DEATH")); - register(new SkyblockAbility("Creeper Veil", -1, -1, "WITHER_CLOAK")); - register(new SkyblockAbility("Ice Bolt", 50, -1, "FROZEN_SCYTHE")); - register(new SkyblockAbility("Rapid-fire", 10, -1, "JERRY_STAFF")); - register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_HELMET_NEW")); - register(new SkyblockAbility("Mist Aura", -1, -1, "SORROW_BOOTS")); - register(new SkyblockAbility("Deploy", -1, -1, "RADIANT_POWER_ORB")); - register(new SkyblockAbility("Ice Spray", 50, 5, "ICE_SPRAY_WAND")); - register(new SkyblockAbility("Grand... Zapper?", -1, -1, "BLOCK_ZAPPER")); - register(new SkyblockAbility("Seek the King", -1, 5, "ROYAL_PIGEON")); - register(new SkyblockAbility("Mist Aura", -1, -1, "SORROW_CHESTPLATE")); - register(new SkyblockAbility("Healing Boost", -1, -1, "REVIVED_HEART")); - register(new SkyblockAbility("Deploy", -1, -1, "OVERFLUX_POWER_ORB")); - register(new SkyblockAbility("Swing", -1, -1, "BONE_BOOMERANG")); - register(new SkyblockAbility("Growth", -1, 4, "GROWTH_CHESTPLATE")); - register(new SkyblockAbility("Squash 'em", -1, -1, "RECLUSE_FANG")); - register(new SkyblockAbility("Roll em'", -1, -1, "PUMPKIN_DICER")); - register(new SkyblockAbility("Cleave", -1, -1, "SUPER_CLEAVER")); - register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_BOOTS_NEW")); - register(new SkyblockAbility("Farmer's Delight", -1, -1, "BASKET_OF_SEEDS")); - register(new SkyblockAbility("Block Damage", -1, 60, "GUARDIAN_CHESTPLATE")); - register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_LEGGINGS")); - register(new SkyblockAbility("Bone Shield", -1, -1, "SKELETON_HELMET")); - register(new SkyblockAbility("Iron Punch", 70, 3, "GOLEM_SWORD")); - register(new SkyblockAbility("Built-in Storage", -1, -1, "BUILDERS_WAND")); - register(new SkyblockAbility("Nasty Bite", -1, -1, "MOSQUITO_BOW")); - register(new SkyblockAbility("Ender Warp", 50, 45, "ENDER_BOW")); - register(new SkyblockAbility("Cleave", -1, -1, "CLEAVER")); - register(new SkyblockAbility("Party Time!", -1, -1, "PARTY_HAT_CRAB")); - register(new SkyblockAbility("Giant's Slam", 100, 30, "GIANTS_SWORD")); - register(new SkyblockAbility("Snow Placer", -1, -1, "SNOW_SHOVEL")); - register(new SkyblockAbility("Greed", -1, -1, "MIDAS_SWORD")); - register(new SkyblockAbility("Clownin' Around", -1, 316, "STARRED_BONZO_MASK")); - register(new SkyblockAbility("Weather", -1, 5, "WEATHER_STICK")); - register(new SkyblockAbility("ME SMASH HEAD", 100, -1, "EDIBLE_MACE")); - register(new SkyblockAbility("Splash", 10, 1, "FISH_HAT")); - register(new SkyblockAbility("Deploy", -1, -1, "PLASMAFLUX_POWER_ORB")); - register(new SkyblockAbility("Dragon Rage", 100, -1, "ASPECT_OF_THE_DRAGON")); - register(new SkyblockAbility("Burning Souls", 400, -1, "PIGMAN_SWORD")); - register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_CHESTPLATE_NEW")); - register(new SkyblockAbility("Fire Blast", 150, 30, "EMBER_ROD")); - register(new SkyblockAbility("Commander Whip", -1, -1, "ZOMBIE_COMMANDER_WHIP")); - register(new SkyblockAbility("Spooktacular", -1, -1, "GHOUL_BUSTER")); - register(new SkyblockAbility("Cleave", -1, -1, "HYPER_CLEAVER")); - register(new SkyblockAbility("Leap", 50, 1, "SILK_EDGE_SWORD")); - register(new SkyblockAbility("Throw", 150, 5, "LIVID_DAGGER")); - register(new SkyblockAbility("Raise Souls", -1, 1, "NECROMANCER_SWORD")); - register(new SkyblockAbility("Double Jump", 50, -1, "SPIDER_BOOTS")); - register(new SkyblockAbility("Speed Boost", 50, -1, "ROGUE_SWORD")); - register(new SkyblockAbility("Spirit Glide", 250, 60, "THORNS_BOOTS")); - register(new SkyblockAbility("Sting", 100, -1, "STINGER_BOW")); - register(new SkyblockAbility("Roll em'", -1, -1, "MELON_DICER")); - register(new SkyblockAbility("Explosive Shot", -1, -1, "EXPLOSIVE_BOW")); - register(new SkyblockAbility("Heat-Seeking Rose", 35, 1, "FLOWER_OF_TRUTH")); - register(new SkyblockAbility("Small Heal", 60, 1, "WAND_OF_HEALING")); - register(new SkyblockAbility("Dreadlord", 40, -1, "CRYPT_DREADLORD_SWORD")); - register(new SkyblockAbility("Shadow Fury", -1, 15, "STARRED_SHADOW_FURY")); - register(new SkyblockAbility("Double Jump", 40, -1, "TARANTULA_BOOTS")); - register(new SkyblockAbility("Acupuncture", 200, 5, "VOODOO_DOLL")); - register(new SkyblockAbility("Showtime", 100, -1, "STARRED_BONZO_STAFF")); - register(new SkyblockAbility("Heartstopper", -1, -1, "SCORPION_FOIL")); - register(new SkyblockAbility("Rapid Fire", -1, 100, "MACHINE_GUN_BOW")); - register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_HELMET")); - register(new SkyblockAbility("Alchemist's Bliss", -1, -1, "NETHER_WART_POUCH")); - register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_CHESTPLATE")); - register(new SkyblockAbility("Instant Heal", 70, -1, "ORNATE_ZOMBIE_SWORD")); - register(new SkyblockAbility("Shadow Fury", -1, 15, "SHADOW_FURY")); - register(new SkyblockAbility("Healing Boost", -1, -1, "ZOMBIE_HEART")); - register(new SkyblockAbility("Witherlord", 40, 3, "CRYPT_WITHERLORD_SWORD")); - register(new SkyblockAbility("Revive", -1, -1, "REVIVE_STONE")); - register(new SkyblockAbility("Raise Souls", -1, 1, "REAPER_SCYTHE")); - register(new SkyblockAbility("Rejuvenate", -1, -1, "VAMPIRE_MASK")); - register(new SkyblockAbility("Mist Aura", -1, -1, "SORROW_HELMET")); - register(new SkyblockAbility("Place Dirt", -1, -1, "INFINIDIRT_WAND")); - register(new SkyblockAbility("Clownin' Around", -1, 360, "BONZO_MASK")); - register(new SkyblockAbility("Shadow Warp", 300, 10, "SHADOW_WARP_SCROLL")); - register(new SkyblockAbility("Molten Wave", 500, 1, "MIDAS_STAFF")); - register(new SkyblockAbility("Growth", -1, 4, "GROWTH_HELMET")); - register(new SkyblockAbility("Howl", 150, 20, "WEIRD_TUBA")); - register(new SkyblockAbility("Medium Heal", 80, 1, "WAND_OF_MENDING")); - register(new SkyblockAbility("Throw", 20, -1, "AXE_OF_THE_SHREDDED")); - register(new SkyblockAbility("Ink Bomb", 60, 30, "INK_WAND")); - register(new SkyblockAbility("Whassup?", -1, -1, "AATROX_BATPHONE")); - register(new SkyblockAbility("Deploy", -1, -1, "MANA_FLUX_POWER_ORB")); - register(new SkyblockAbility("Extreme Focus", -1, -1, "END_STONE_BOW")); - register(new SkyblockAbility("Healing Boost", -1, -1, "CRYSTALLIZED_HEART")); - register(new SkyblockAbility("Mist Aura", -1, -1, "SORROW_LEGGINGS")); - register(new SkyblockAbility("Showtime", 100, -1, "BONZO_STAFF")); - register(new SkyblockAbility("Triple Shot", -1, -1, "RUNAANS_BOW")); - register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_LEGGINGS_NEW")); - register(new SkyblockAbility("Rejuvenate", -1, -1, "VAMPIRE_WITCH_MASK")); - register(new SkyblockAbility("Terrain Toss", 250, 1, "YETI_SWORD")); - register(new SkyblockAbility("Instant Transmission", 50, -1, "ASPECT_OF_THE_END")); - register(new SkyblockAbility("Detonate", -1, 60, "CREEPER_LEGGINGS")); - register(new SkyblockAbility("Extreme Focus", -1, -1, "END_STONE_SWORD")); - register(new SkyblockAbility("Leap", 50, 1, "LEAPING_SWORD")); - register(new SkyblockAbility("Fun Guy Bonus", -1, -1, "FUNGI_CUTTER")); - register(new SkyblockAbility("Cleave", -1, -1, "GIANT_CLEAVER")); - register(new SkyblockAbility("Tempest", -1, -1, "HURRICANE_BOW")); - register(new SkyblockAbility("Big Heal", 100, 1, "WAND_OF_RESTORATION")); - register(new SkyblockAbility("Growth", -1, 4, "GROWTH_BOOTS")); - register(new SkyblockAbility("Stinger", 150, -1, "SCORPION_BOW")); - register(new SkyblockAbility("Eye Beam", -1, -1, "PRECURSOR_EYE")); - register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_BOOTS")); - register(new SkyblockAbility("Mining Speed Boost", -1, 120, null)); - register(new SkyblockAbility("Pikobulus", -1, 110, null)); - // abilities - - register(new SkyblockAbility("Healing Circle", -1, 2, "DUNGEON_STONE")); - register(new SkyblockAbility("Wish", -1, 120, "DUNGEON_STONE")); - register(new SkyblockAbility("Guided Sheep", -1, 30, "DUNGEON_STONE")); - register(new SkyblockAbility("Thunderstorm", -1, 500, "DUNGEON_STONE")); - register(new SkyblockAbility("Throwing Axe", -1, 10, "DUNGEON_STONE")); - register(new SkyblockAbility("Ragnarok", -1, 60, "DUNGEON_STONE")); - register(new SkyblockAbility("Explosive Shot", -1, 40, "DUNGEON_STONE")); - register(new SkyblockAbility("Rapid Fire", -1, 100, "DUNGEON_STONE")); - register(new SkyblockAbility("Seismic Wave", -1, 15, "DUNGEON_STONE")); - register(new SkyblockAbility("Castle of Stone", -1, 150, "DUNGEON_STONE")); - } - - static void register(SkyblockAbility skyblockAbility) { - if (!skyblockAbilities.containsKey(skyblockAbility.getName())) - skyblockAbilities.put(skyblockAbility.getName(), skyblockAbility); - if (skyblockAbility.getItemId() != null && skyblockAbility.getCooldown() != -1) { - List skyblockAbility1 = skyblockAbilitiesByItemID.computeIfAbsent(skyblockAbility.getItemId(), (a) -> new ArrayList<>()); - skyblockAbility1.add(skyblockAbilities.get(skyblockAbility.getName())); - skyblockAbilitiesByItemID.put(skyblockAbility.getItemId(), skyblockAbility1); - } - } - - private final TreeSet usedAbilities = new TreeSet((c1, c2) -> { - int a = Comparator.comparingLong(UsedAbility::getCooldownEnd).compare(c1,c2); - return c1.getAbility().getName().equals(c2.getAbility().getName()) ? 0 : a; - }); - - @Override - public List getText() { - List cooldowns = new ArrayList<>(); - - for (UsedAbility usedAbility : usedAbilities) { - long end = usedAbility.getCooldownEnd(); - if (System.currentTimeMillis() >= end) { - if (System.currentTimeMillis() <= end + 20000) { - cooldowns.add(new StyledText(usedAbility.getAbility().getName(), "abilityname")); - cooldowns.add(new StyledText(": ", "separator")); - cooldowns.add(new StyledText("READY\n", "ready")); - } - } else { - cooldowns.add(new StyledText(usedAbility.getAbility().getName(), "abilityname")); - cooldowns.add(new StyledText(": ", "separator")); - long millies = end-System.currentTimeMillis(); - double decimalPlaces = (double ) Math.pow(10, 3- this.getParameter("decimal").getValue()); - if (decimalPlaces == 0) { - cooldowns.add(new StyledText( this.getParameter("decimal").getValue()+" decimal places? You'd be joking\n", "unit")); - continue; - } - millies = (long) (((millies-1) / decimalPlaces + 1) * decimalPlaces); - long hr = (long) (millies / (1000 * 60 * 60)); - long min = (long) (( millies / (1000*60)) % 60); - double seconds = (millies/1000.0 ) % 60; - String secondStr = String.format("%."+(this.getParameter("decimal").getValue())+"f", seconds); - - if (hr > 0) { - cooldowns.add(new StyledText(String.valueOf(hr), "number")); - cooldowns.add(new StyledText("h ", "unit")); - } - if (hr > 0 || min > 0) { - cooldowns.add(new StyledText(String.valueOf(min), "number")); - cooldowns.add(new StyledText("m ", "unit")); - } - if (hr > 0 || min > 0 || seconds > 0) { - cooldowns.add(new StyledText(secondStr, "number")); - cooldowns.add(new StyledText("s ", "unit")); - } - cooldowns.add(new StyledText("\n", "unit")); - } - } - return cooldowns; - } - - Pattern thePattern = Pattern.compile("ยงb-(\\d+) Mana \\(ยง6(.+)ยงb\\)"); - Pattern thePattern2 = Pattern.compile("ยงrยงaUsed (.+)ยงrยงa! ยงrยงb\\((1194) Mana\\)ยงr"); - Pattern thePattern3 = Pattern.compile("ยงrยงaUsed (.+)ยงrยงa!ยงr"); - - private String lastActionbarAbility; - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (clientChatReceivedEvent.type == 2) { - Matcher m = thePattern.matcher(clientChatReceivedEvent.message.getFormattedText()); - if (m.find()) { - String name = m.group(2); - if (!name.equalsIgnoreCase(lastActionbarAbility)) { - used(name); - } - lastActionbarAbility = name; - } else { - lastActionbarAbility = null; - } - } else { - String message = clientChatReceivedEvent.message.getFormattedText(); - if (message.equals("ยงrยงaYour ยงrยง9Bonzo's Mask ยงrยงasaved your life!ยงr")) { - used("Clownin' Around"); - } else { - Matcher m = thePattern2.matcher(message); - if (m.matches()) { - String abilityName = TextUtils.stripColor(m.group(1)); - used(abilityName); - } else { - Matcher m2 = thePattern3.matcher(message); - if (m2.matches()) { - String abilityName = TextUtils.stripColor(m2.group(1)); - used(abilityName); - } else if (message.startsWith("ยงrยงaYou used your ") || message.endsWith("ยงrยงaPickaxe Ability!ยงr")) { - String nocolor = TextUtils.stripColor(message); - String abilityName = nocolor.substring(nocolor.indexOf("your") + 5, nocolor.indexOf("Pickaxe") - 1); - used(abilityName); - } - } - } - } - } - - private void used(String ability) { - if (skyblockAbilities.containsKey(ability)) { - SkyblockAbility skyblockAbility = skyblockAbilities.get(ability); - if (skyblockAbility.getCooldown() > 0) { - UsedAbility usedAbility = new UsedAbility(skyblockAbility, System.currentTimeMillis() + skyblockAbility.getCooldown() * 1000); - for (int i = 0; i < 3; i++) usedAbilities.remove(usedAbility); - usedAbilities.add(usedAbility); - } - } else { - System.out.println("Unknown ability: "+ability); - } - } - - public void checkForCooldown(ItemStack itemStack) { - if (itemStack == null) return; - NBTTagCompound nbt = itemStack.getTagCompound(); - if (nbt == null) return; - NBTTagCompound extra = nbt.getCompoundTag("ExtraAttributes"); - if (extra == null) return; - String id = extra.getString("id"); - if (!skyblockAbilitiesByItemID.containsKey(id)) return; - List skyblockAbility = skyblockAbilitiesByItemID.get(id); - - NBTTagCompound display = nbt.getCompoundTag("display"); - if (display == null) return; - NBTTagList lore = display.getTagList("Lore", 8); - int thecd = -1; - SkyblockAbility currentAbility = null; - for (int i = 0; i < lore.tagCount(); i++) { - String specific = lore.getStringTagAt(i); - if (specific.startsWith("ยง8Cooldown: ยงa") && currentAbility != null) { - String thecdstr = TextUtils.stripColor(specific).substring(10).trim(); - thecdstr = thecdstr.substring(0, thecdstr.length() - 1); - thecd = Integer.parseInt(thecdstr); - currentAbility.setCooldown(thecd); - currentAbility = null; - } else if (specific.startsWith("ยง6Item Ability: ")) { - String ability = TextUtils.stripColor(specific).substring(14).trim(); - - for (SkyblockAbility skyblockAbility1 : skyblockAbility) { - if (skyblockAbility1.getName().equals(ability)) { - currentAbility = skyblockAbility1; - break; - } - } - } - } - } - - @Override - public void onTick() { - EntityPlayerSP sp = Minecraft.getMinecraft().thePlayer; - if (sp == null) return; - if (sp.inventory == null || sp.inventory.armorInventory == null) return; - for (ItemStack itemStack : sp.inventory.armorInventory) { - checkForCooldown(itemStack); - } - for (ItemStack itemStack : sp.inventory.mainInventory) { - checkForCooldown(itemStack); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/SkyblockAbility.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/SkyblockAbility.java deleted file mode 100644 index a7c8a0b9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/SkyblockAbility.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc.ability; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class SkyblockAbility { - private String name; - private int manaCost; - private int cooldown; - - private String itemId; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/UsedAbility.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/UsedAbility.java deleted file mode 100644 index baea7e44..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/UsedAbility.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.etc.ability; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@AllArgsConstructor -public class UsedAbility { - private SkyblockAbility ability; - @EqualsAndHashCode.Exclude - private long cooldownEnd; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/APIKey.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/APIKey.java deleted file mode 100644 index ceb4f407..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/APIKey.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party; - -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.ChatListenerGlobal; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -public class APIKey extends SimpleFeature implements ChatListenerGlobal { - - public APIKey() { - super("Misc.API Features", "API KEY", "Sets api key","partykicker.apikey"); - parameters.put("apikey", new FeatureParameter("apikey", "API Key", "API key", "","string")); - } - - public String getAPIKey() { - return this.getParameter("apikey").getValue(); - } - - - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - if (clientChatReceivedEvent.type == 2) return; - String str = clientChatReceivedEvent.message.getFormattedText(); - if (str.startsWith("ยงaYour new API key is ยงrยงb")) { - String apiKeys = TextUtils.stripColor(str.split(" ")[5]); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfAutomatically Configured Hypixel API Key")); - this.getParameter("apikey").setValue(apiKeys); - } - } - - @Override - public boolean isDisyllable() { - return false; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureGoodParties.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureGoodParties.java deleted file mode 100644 index 6d33ebc9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeatureGoodParties.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party; - -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Items; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.Slot; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.client.event.GuiScreenEvent; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -public class FeatureGoodParties extends SimpleFeature implements GuiPostRenderListener { - public FeatureGoodParties() { - super("Party Kicker", "Highlight parties in party viewer", "Highlight parties you can't join with red", "partykicker.goodparty",true); - } - - @Override - public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { - if (!isEnabled()) return; - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - ContainerChest cont = (ContainerChest) chest.inventorySlots; - String name = cont.getLowerChestInventory().getName(); - if (!"Party Finder".equals(name)) return; - - - int i = 222; - int j = i - 108; - int ySize = j + (((ContainerChest)(((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots)).getLowerChestInventory().getSizeInventory() / 9) * 18; - int left = (rendered.gui.width - 176) / 2; - int top = (rendered.gui.height - ySize ) / 2; - GlStateManager.pushMatrix(); - GlStateManager.disableDepth(); - GlStateManager.disableLighting(); - GlStateManager.colorMask(true, true, true, false); - GlStateManager.translate(left, top, 0); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - try { - - for (int i1 = 0; i1 < Integer.min(54, cont.inventorySlots.size()); i1++) { - Slot s = cont.inventorySlots.get(i1); - if (s.getStack() == null) continue; - if (s.getStack().getItem() != Items.skull) continue; - NBTTagCompound nbt = s.getStack().getTagCompound(); - if (nbt == null || nbt.hasNoTags()) continue; - NBTTagCompound display = nbt.getCompoundTag("display"); - if (display.hasNoTags()) return; - NBTTagList lore = display.getTagList("Lore", 8); - int classLvReq = 0; - int cataLvReq = 0; - boolean Req = false; - String note = ""; - for (int n = 0; n < lore.tagCount(); n++) { - String str = lore.getStringTagAt(n); - if (str.startsWith("ยง7Dungeon Level Required: ยงb")) cataLvReq = Integer.parseInt(str.substring(28)); - if (str.startsWith("ยง7Class Level Required: ยงb")) classLvReq = Integer.parseInt(str.substring(26)); - if (str.startsWith("ยง7ยง7Note:")) note = TextUtils.stripColor(str.substring(10)); - if (str.startsWith("ยงcRequires")) Req = true; - } - - int x = s.xDisplayPosition; - int y = s.yDisplayPosition; - if (Req) { - Gui.drawRect(x, y, x + 16, y + 16, 0x77AA0000); - } else { - - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (note.toLowerCase().contains("car")) { - fr.drawStringWithShadow("C", x + 1, y + 1, 0xFFFF0000); - } else if (note.toLowerCase().replace(" ", "").contains("s/s+")) { - fr.drawStringWithShadow("S+", x + 1, y + 1, 0xFFFFFF00); - } else if (note.toLowerCase().contains("s+")) { - fr.drawStringWithShadow("S+", x + 1, y + 1, 0xFF00FF00); - } else if (note.toLowerCase().contains(" s") || note.toLowerCase().contains(" s ")) { - fr.drawStringWithShadow("S", x + 1, y + 1, 0xFFFFFF00); - } else if (note.toLowerCase().contains("rush")) { - fr.drawStringWithShadow("R", x + 1, y + 1, 0xFFFF0000); - } - fr.drawStringWithShadow("ยงe"+Integer.max(classLvReq, cataLvReq), x + 1, y + fr.FONT_HEIGHT, 0xFFFFFFFF); - } - - - } - } catch (Throwable e) { - e.printStackTrace(); - } - GlStateManager.colorMask(true, true, true, true); - GlStateManager.popMatrix(); - GlStateManager.enableBlend(); - GlStateManager.enableLighting(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeaturePartyList.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeaturePartyList.java deleted file mode 100644 index ca466452..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeaturePartyList.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party; - -import kr.syeyoung.dungeonsguide.chat.PartyContext; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeaturePartyList extends TextHUDFeature { - public FeaturePartyList() { - super("Party","Party List", "Party List as GUI", "party.list", false, getFontRenderer().getStringWidth("Watcher finished spawning all mobs!"), getFontRenderer().FONT_HEIGHT*4); - getStyles().add(new TextStyle("name", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("player", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("allinvite", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - setEnabled(false); - } - - @Override - public boolean isHUDViewable() { - return PartyManager.INSTANCE.getPartyContext() != null; - } - - @Override - public java.util.List getUsedTextStyle() { - return Arrays.asList("name" ,"separator", "player", "allinvite"); - } - - private static final List dummyText = new ArrayList(); - static { - dummyText.add(new StyledText("Leader","name")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("syeyoung","player")); - dummyText.add(new StyledText("\nModerator","name")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("rioho, RaidShadowLegends, Tricked","player")); - dummyText.add(new StyledText("\nMember","name")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Everyone","player")); - dummyText.add(new StyledText("\nAll invite Off","allinvite")); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public boolean doesScaleWithHeight() { - return false; - } - - @Override - public List getText() { - PartyContext pc = PartyManager.INSTANCE.getPartyContext(); - List text= new ArrayList<>(); - text.add(new StyledText("Leader","name")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(pc.getPartyOwner()+"","player")); - text.add(new StyledText("\nModerator","name")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(pc.getPartyModerator() == null ? "????" : String.join(", ", pc.getPartyModerator()) + (pc.isModeratorComplete() ? "" : " ?"),"player")); - text.add(new StyledText("\nMember","name")); - text.add(new StyledText(": ","separator")); - text.add(new StyledText(pc.getPartyMember() == null ? "????" : String.join(", ", pc.getPartyMember()) + (pc.isMemberComplete() ? "" : " ?"),"player")); - if (pc.getAllInvite() != null && !pc.getAllInvite()) - text.add(new StyledText("\nAll invite Off","allinvite")); - else if (pc.getAllInvite() != null) - text.add(new StyledText("\nAll invite On","allinvite")); - else - text.add(new StyledText("\nAll invite Unknown","allinvite")); - return text; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeaturePartyReady.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeaturePartyReady.java deleted file mode 100644 index 51285ed9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/FeaturePartyReady.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.chat.PartyContext; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonEndListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonStartListener; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.*; - -public class FeaturePartyReady extends TextHUDFeature implements ChatListener, DungeonStartListener { - public FeaturePartyReady() { - super("Party","Party Ready List", "Check if your party member have said r or not", "party.readylist", false, getFontRenderer().getStringWidth("Watcher finished spawning all mobs!"), getFontRenderer().FONT_HEIGHT*4); - getStyles().add(new TextStyle("player", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("ready", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("notready", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("terminal", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - setEnabled(true); - } - - @Override - public boolean isHUDViewable() { - return PartyManager.INSTANCE.getPartyContext() != null && PartyManager.INSTANCE.getPartyContext().isPartyExistHypixel() && "Dungeon Hub".equals(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("separator", "player", "ready", "notready", "terminal"); - } - - private static final List dummyText = new ArrayList(); - static { - dummyText.add(new StyledText("syeyoung","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Ready","ready")); - dummyText.add(new StyledText(" 4","terminal")); - dummyText.add(new StyledText("\nrioho","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Ready","ready")); - dummyText.add(new StyledText(" 3","terminal")); - dummyText.add(new StyledText("\nRaidShadowLegends","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Not Ready","notready")); - dummyText.add(new StyledText(" 2t","terminal")); - dummyText.add(new StyledText("\nTricked","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Ready","ready")); - dummyText.add(new StyledText(" ss","terminal")); - dummyText.add(new StyledText("\nMr. Penguin","player")); - dummyText.add(new StyledText(": ","separator")); - dummyText.add(new StyledText("Not Ready","notready")); - dummyText.add(new StyledText(" 2b","terminal")); - } - - @Override - public List getDummyText() { - return dummyText; - } - - @Override - public boolean doesScaleWithHeight() { - return false; - } - - private Set ready = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); - private Map terminal = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - - @Override - public List getText() { - PartyContext pc = PartyManager.INSTANCE.getPartyContext(); - List text= new ArrayList<>(); - boolean first = true; - for (String partyRawMember : pc.getPartyRawMembers()) { - text.add(new StyledText((first ? "":"\n") + partyRawMember, "player")); - text.add(new StyledText(": ","separator")); - if (ready.contains(partyRawMember)) - text.add(new StyledText("Ready","ready")); - else - text.add(new StyledText("Not Ready","notready")); - if (terminal.get(partyRawMember) != null) { - text.add(new StyledText(" "+ terminal.get(partyRawMember), "terminal")); - } - first =false; - } - return text; - } - - private static final List readyPhrase = Arrays.asList("r", "rdy", "ready"); - private static final List negator = Arrays.asList("not ", "not", "n", "n "); - private static final List terminalPhrase = Arrays.asList("ss", "s1", "1", "2b", "2t", "3", "4", "s3", "s4", "s2", "2"); - private static final Map readynessIndicator = new HashMap<>(); - static { - readyPhrase.forEach(val -> readynessIndicator.put(val, true)); - for (String s : negator) { - readyPhrase.forEach(val -> readynessIndicator.put(s+val, false)); - } - readynessIndicator.put("dont start", false); - readynessIndicator.put("don't start", false); - readynessIndicator.put("dont go", false); - readynessIndicator.put("don't go", false); - readynessIndicator.put("start", true); - readynessIndicator.put("go", true); - } - - - @Override - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - String txt = clientChatReceivedEvent.message.getFormattedText(); - if (!txt.startsWith("ยงrยง9Party ยง8>")) return; - - String chat = TextUtils.stripColor(txt.substring(txt.indexOf(":")+1)).trim().toLowerCase(); - - - - String usernamearea = TextUtils.stripColor(txt.substring(13, txt.indexOf(":"))); - String username = null; - for (String s : usernamearea.split(" ")) { - if (s.isEmpty()) continue; - if (s.startsWith("[")) continue; - username = s; - break; - } - - - Boolean status = null; - String longestMatch = ""; - for (Map.Entry stringBooleanEntry : readynessIndicator.entrySet()) { - if (chat.startsWith(stringBooleanEntry.getKey()) || chat.endsWith(stringBooleanEntry.getKey()) || (stringBooleanEntry.getKey().length()>=3 && chat.contains(stringBooleanEntry.getKey()))) { - if (stringBooleanEntry.getKey().length() > longestMatch.length()) { - longestMatch = stringBooleanEntry.getKey(); - status = stringBooleanEntry.getValue(); - } - } - } - if (status == null); - else if (status) ready.add(username); - else ready.remove(username); - - - String term = ""; - for (String s : terminalPhrase) { - if (chat.equals(s) || chat.startsWith(s+" ") || chat.endsWith(" "+s) || chat.contains(" "+s+" ")) { - term += s+" "; - } - } - if (!term.isEmpty()) - terminal.put(username, term); - } - - @Override - public void onDungeonStart() { - ready.clear(); - terminal.clear(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/FeatureCustomPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/FeatureCustomPartyFinder.java deleted file mode 100644 index 37669835..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/FeatureCustomPartyFinder.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.customgui; - -import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.*; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.client.event.GuiOpenEvent; - -import java.util.HashSet; -import java.util.Set; - -public class FeatureCustomPartyFinder extends SimpleFeature implements GuiOpenListener, GuiUpdateListener { - public FeatureCustomPartyFinder() { - super("Party","Custom Party Finder","Custom Party Finder", "party.customfinder", true); - } - - @Getter - @Setter - private String whitelist = "", blacklist = "", highlight ="", blacklistClass = ""; - @Getter - @Setter - private int minimumCata; - - @Getter @Setter - private String lastClass = ""; - - GuiCustomPartyFinder guiCustomPartyFinder; - @Override - public void onGuiOpen(GuiOpenEvent event) { - if (event.gui == null) guiCustomPartyFinder = null; - if (!isEnabled()) return; - if (!(event.gui instanceof GuiChest)) return; - GuiChest chest = (GuiChest) event.gui; - if (!(chest.inventorySlots instanceof ContainerChest)) return; - ContainerChest containerChest = (ContainerChest) chest.inventorySlots; - IInventory lower = containerChest.getLowerChestInventory(); - if (lower == null || !lower.getName().equals("Party Finder")) return; - - if (guiCustomPartyFinder == null) { - guiCustomPartyFinder = new GuiCustomPartyFinder(); - } - guiCustomPartyFinder.setGuiChest(chest); - - event.gui = guiCustomPartyFinder; - } - - @Override - public void onGuiUpdate(WindowUpdateEvent windowUpdateEvent) { - if (guiCustomPartyFinder != null) { - guiCustomPartyFinder.onChestUpdate(windowUpdateEvent); - } - - if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { - GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; - - if (!(chest.inventorySlots instanceof ContainerChest)) return; - ContainerChest containerChest = (ContainerChest) chest.inventorySlots; - IInventory lower = containerChest.getLowerChestInventory(); - if (lower == null || !lower.getName().equals("Catacombs Gate")) return; - - ItemStack item = null; - if (windowUpdateEvent.getWindowItems() != null) { - item = windowUpdateEvent.getWindowItems().getItemStacks()[47]; - } else if (windowUpdateEvent.getPacketSetSlot() != null) { - if (windowUpdateEvent.getPacketSetSlot().func_149173_d() != 47) return; - item = windowUpdateEvent.getPacketSetSlot().func_149174_e(); - } - if (item == null) return; - - NBTTagCompound stackTagCompound = item.getTagCompound(); - if (stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); - - if (nbttagcompound.getTagId("Lore") == 9) { - NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); - - for (int i = 0; i < nbttaglist1.tagCount(); i++) { - String str = nbttaglist1.getStringTagAt(i); - if (str.startsWith("ยงaCurrently Selected")) { - lastClass = str.substring(24); - } - } - } - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/GuiCustomPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/GuiCustomPartyFinder.java deleted file mode 100644 index 98b733e5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/GuiCustomPartyFinder.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.customgui; - -import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; -import kr.syeyoung.dungeonsguide.gui.MGui; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.util.MathHelper; - -import java.awt.*; - -public class GuiCustomPartyFinder extends MGui { - @Getter - private GuiChest guiChest; - - public void setGuiChest(GuiChest guiChest) { - if (this.guiChest != null) this.guiChest.onGuiClosed(); - this.guiChest = guiChest; - panelPartyFinder.onChestUpdate(null); - guiChest.setWorldAndResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); - guiChest.initGui(); - } - - public void onChestUpdate(WindowUpdateEvent windowUpdateEvent) { - panelPartyFinder.onChestUpdate(windowUpdateEvent); - } - - private PanelPartyFinder panelPartyFinder; - public GuiCustomPartyFinder() { - panelPartyFinder = new PanelPartyFinder(this); - getMainPanel().add(panelPartyFinder); - } - - @Override - public void initGui() { - super.initGui(); - int width = 3*Minecraft.getMinecraft().displayWidth/5; - width = Math.max(width, 1000); - int height = 3*Minecraft.getMinecraft().displayHeight/5; - height = Math.max(height, 600); - - panelPartyFinder.setBounds(new Rectangle((Minecraft.getMinecraft().displayWidth-width)/2, (Minecraft.getMinecraft().displayHeight-height)/2, width, height)); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawDefaultBackground(); - super.drawScreen(mouseX, mouseY, partialTicks); - - } - - @Override - public void onGuiClosed() { - guiChest.onGuiClosed(); - guiChest = null; - super.onGuiClosed(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinder.java deleted file mode 100644 index eef360b2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinder.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.customgui; - -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfigV2; -import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.discord.invteTooltip.MTooltipInvite; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.rpc.RichPresenceManager; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.inventory.Slot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; - -import java.awt.*; -import java.util.HashMap; -import java.util.Map; - -public class PanelPartyFinder extends MPanel { - @Getter - private GuiCustomPartyFinder guiCustomPartyFinder; - - private PanelPartyFinderSettings panelPartyFinderSettings; - - private MScrollablePanel scrollablePanel; - private MList list; - - private MButton goBack; - - private MPanelScaledGUI navigation; - - private MButton previous; - private MButton next; - private MButton settings, discordInvite; - private int page = 1; - - private Map panelPartyListElementMap = new HashMap<>(); - - public PanelPartyFinder(GuiCustomPartyFinder guiCustomPartyFinder) { - this.guiCustomPartyFinder = guiCustomPartyFinder; - - scrollablePanel = new MScrollablePanel(1); - panelPartyFinderSettings = new PanelPartyFinderSettings(this); - - - list = new MList() { - @Override - public void resize(int parentWidth, int parentHeight) { - setSize(new Dimension(parentWidth, 9999)); - realignChildren(); - } - }; - list.setGap(1); - - scrollablePanel.add(list); - - add(scrollablePanel); - add(panelPartyFinderSettings); - - previous = new MButton(); next = new MButton(); - previous.setText("Prev"); next.setText("Next"); - previous.setEnabled(false); next.setEnabled(false); - next.setOnActionPerformed(() -> { - GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*2+8, 0, 0, Minecraft.getMinecraft().thePlayer); - }); - previous.setOnActionPerformed(() -> { - GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*2, 0, 0, Minecraft.getMinecraft().thePlayer); - }); - goBack = new MButton(); - goBack.setBackground(RenderUtils.blendAlpha(0xFF141414, 0.05f)); - goBack.setText("<"); - goBack.setOnActionPerformed(() -> { - GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+3, 0, 0, Minecraft.getMinecraft().thePlayer); - }); - add(goBack); - settings = new MButton(); - settings.setBackground(RenderUtils.blendAlpha(0xFF141414, 0.05f)); - settings.setText("Settings"); - settings.setOnActionPerformed(() -> { - GuiConfigV2 guiConfigV2 = new GuiConfigV2(); - guiConfigV2.getRootConfigPanel().setCurrentPageAndPushHistory("ROOT."+ FeatureRegistry.PARTYKICKER_CUSTOM.getCategory()); - Minecraft.getMinecraft().displayGuiScreen(guiConfigV2); - }); - discordInvite = new MButton(); - discordInvite.setText("Invite Discord Friends"); - discordInvite.setOnActionPerformed(() -> { - if (RichPresenceManager.INSTANCE.getLastSetupCode() == -9999) { - MModalMessage mTooltipInvite = new MModalMessage("Error", "Discord GameSDK has been disabled, or it failed to load", () -> {}); - mTooltipInvite.setScale( new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor()); - mTooltipInvite.open(this); - } else if (PartyManager.INSTANCE.getAskToJoinSecret() != null) { - MTooltipInvite mTooltipInvite = new MTooltipInvite(); - mTooltipInvite.setScale( new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor()); - mTooltipInvite.open(this); - } else { - MModalMessage mTooltipInvite = new MModalMessage("Error", "You need to have Ask To Join Enabled to use this feature. Run /dg atj to enable ask to join", () -> {}); - mTooltipInvite.setScale( new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor()); - mTooltipInvite.open(this); - } - }); - discordInvite.setBackground(RenderUtils.blendAlpha(0xFF141414, 0.05f)); - add(discordInvite); - add(settings); - navigation = new MPanelScaledGUI() { - @Override - public void onBoundsUpdate() { - super.onBoundsUpdate(); - Dimension dimension = getEffectiveDimension(); - previous.setBounds(new Rectangle(0,0,50,dimension.height)); - next.setBounds(new Rectangle(dimension.width-50,0,50,dimension.height)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - Gui.drawRect(0,0,getEffectiveDimension().width, getEffectiveDimension().height, RenderUtils.blendAlpha(0xFF141414, 0.08f)); - fr.drawString("Page "+page, (getEffectiveDimension().width-fr.getStringWidth("Page "+page))/2, (getEffectiveDimension().height-fr.FONT_HEIGHT)/2, -1); - } - }; - navigation.add(next); navigation.add(previous); - add(navigation); - } - - public String getHighlightNote() { - return panelPartyFinderSettings.getHighlightText(); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - panelPartyFinderSettings.setBounds(new Rectangle(3*bounds.width/5+1, fr.FONT_HEIGHT*2+21, 2*bounds.width/5 -1, (bounds.height-fr.FONT_HEIGHT*2-21))); - panelPartyFinderSettings.setScale(scaledResolution.getScaleFactor()); - - navigation.setBounds(new Rectangle(0,fr.FONT_HEIGHT*2 + 21, 3*bounds.width/5, 20*scaledResolution.getScaleFactor())); - navigation.setScale(scaledResolution.getScaleFactor()); - scrollablePanel.setBounds(new Rectangle(0, navigation.getBounds().y+navigation.getBounds().height, 3*bounds.width/5, bounds.height - (navigation.getBounds().y+navigation.getBounds().height))); - goBack.setBounds(new Rectangle(0,0, fr.FONT_HEIGHT*2+20, fr.FONT_HEIGHT*2+20)); - settings.setBounds(new Rectangle(bounds.width - 75, 0, 75, fr.FONT_HEIGHT*2+20)); - discordInvite.setBounds(new Rectangle(bounds.width-275, 0, 200, fr.FONT_HEIGHT*2+20)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - // background - Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0xFF141414, 0.0f)); - // top bar - Gui.drawRect(0,0,getBounds().width, fr.FONT_HEIGHT*2+21, RenderUtils.blendAlpha(0xFF141414, 0.05f)); - // lines - Gui.drawRect(0,fr.FONT_HEIGHT*2+20,getBounds().width, fr.FONT_HEIGHT*2+21, -1); - Gui.drawRect(panelPartyFinderSettings.getBounds().x-1,fr.FONT_HEIGHT*2+20,panelPartyFinderSettings.getBounds().x, getBounds().height, -1); - // prev next bar - - GlStateManager.pushMatrix(); - GlStateManager.translate(fr.FONT_HEIGHT*2+21, 0,0); - GlStateManager.scale(2,2,1); - fr.drawString("Party Finder", 5,5,-1); - GlStateManager.popMatrix(); - } - - public synchronized void onChestUpdate(WindowUpdateEvent windowUpdateEvent) { - if (windowUpdateEvent == null) { - GuiChest guiChest = guiCustomPartyFinder.getGuiChest(); - if (guiChest == null) { - panelPartyListElementMap.clear(); - } else { - for (int x = 1; x<=7; x++) { - for (int y = 1; y <= 3; y++) { - int i = y * 9 + x; - Slot s = guiChest.inventorySlots.getSlot(i); - PanelPartyListElement prev = panelPartyListElementMap.remove(i); - if (s == null || !s.getHasStack()) { continue; } - if (!filter(s.getStack())) continue; - - if (prev == null) prev = new PanelPartyListElement(this, i); - panelPartyListElementMap.put(i, prev); - } - } - - { - Slot next = guiChest.inventorySlots.getSlot(9 * 2 + 8); - if (next.getStack() != null && next.getStack().getItem() == Items.arrow) { - this.next.setEnabled(true); - extractPage(next.getStack()); - } else { - this.next.setEnabled(false); - } - - Slot prev = guiChest.inventorySlots.getSlot(9 * 2 + 0); - if (prev.getStack() != null && prev.getStack().getItem() == Items.arrow) { - this.previous.setEnabled(true); - extractPage(prev.getStack()); - } else { - this.previous.setEnabled(false); - } - - Slot delist = guiChest.inventorySlots.getSlot(9 * 5 + 7); - panelPartyFinderSettings.setDelistable(delist.getStack() != null && delist.getStack().getItem() == Item.getItemFromBlock(Blocks.bookshelf)); - } - } - } else { - if (windowUpdateEvent.getPacketSetSlot() != null) { - int i = windowUpdateEvent.getPacketSetSlot().func_149173_d(); - - ItemStack stack = windowUpdateEvent.getPacketSetSlot().func_149174_e(); - if (i == 9*2+8) { - if (stack != null && stack.getItem() == Items.arrow) { - this.next.setEnabled(true); - extractPage(stack); - } else { - this.next.setEnabled(false); - } - } else if (i == 9*2) { - if (stack != null && stack.getItem() == Items.arrow) { - this.previous.setEnabled(true); - extractPage(stack); - } else { - this.previous.setEnabled(false); - } - } else if (i == 9*5+7) { - panelPartyFinderSettings.setDelistable(stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)); - } - - if (i%9 == 0 || i%9 == 8 || i/9 == 0 || i/9 >= 4) { - return; - } - - PanelPartyListElement prev = panelPartyListElementMap.remove(i); - if (filter(stack)) { - if (prev == null) prev = new PanelPartyListElement(this, i); - panelPartyListElementMap.put(i, prev); - } - } else if (windowUpdateEvent.getWindowItems() != null) { - for (int x = 1; x<=7; x++) { - for (int y = 1; y <= 3; y++) { - int i = y * 9 + x; - ItemStack item = windowUpdateEvent.getWindowItems().getItemStacks()[i]; - PanelPartyListElement prev = panelPartyListElementMap.remove(i); - if (!filter(item)) continue; - - if (prev == null) prev = new PanelPartyListElement(this, i); - panelPartyListElementMap.put(i, prev); - } - } - - { - ItemStack next = windowUpdateEvent.getWindowItems().getItemStacks()[9 * 2 + 8]; - if (next != null && next.getItem() == Items.arrow) { - this.next.setEnabled(true); - extractPage(next); - } else { - this.next.setEnabled(false); - } - - ItemStack prev = windowUpdateEvent.getWindowItems().getItemStacks()[9 * 2]; - if (prev != null && prev.getItem() == Items.arrow) { - this.previous.setEnabled(true); - extractPage(prev); - } else { - this.previous.setEnabled(false); - } - - ItemStack delist = windowUpdateEvent.getWindowItems().getItemStacks()[9*5+7]; - panelPartyFinderSettings.setDelistable(delist != null && delist.getItem() == Item.getItemFromBlock(Blocks.bookshelf)); - } - } - } - - addItems(); - } - - public boolean filter(ItemStack item) { - return !(item == null || item.getItem() == null || item.getItem() == Item.getItemFromBlock(Blocks.air)) && panelPartyFinderSettings.filter(item); - } - - public void extractPage(ItemStack itemStack) { - NBTTagCompound stackTagCompound = itemStack.getTagCompound(); - if (stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); - - if (nbttagcompound.getTagId("Lore") == 9) { - NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); - - for (int i = 0; i < nbttaglist1.tagCount(); i++) { - String str = nbttaglist1.getStringTagAt(i); - if (str.startsWith("ยงePage ")) { - int pg = Integer.parseInt(str.substring(7)); - if (itemStack.getDisplayName().equals("ยงaPrevious Page")) page = pg+1; - else page = pg-1; - } - } - } - } - } - - public void addItems() { - for (MPanel childComponent : list.getChildComponents()) { - list.remove(childComponent); - } - for (Map.Entry value : panelPartyListElementMap.entrySet()) { - list.add(value.getValue()); - } - scrollablePanel.evalulateContentArea(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java deleted file mode 100644 index fe719de2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyFinderSettings.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.customgui; - -import kr.syeyoung.dungeonsguide.chat.ChatProcessor; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Items; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.EnumChatFormatting; - -import java.awt.*; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class PanelPartyFinderSettings extends MPanelScaledGUI { - private PanelPartyFinder panelPartyFinder; - - private MButton refresh = new MButton(), createNew = new MButton(), settings = new MButton(); - private MPassiveLabelAndElement filterCantjoin, filterWhitelistNote, filterBlacklistNote, plaeHighlightNote, cataLv,blacklistClass; private MToggleButton filterCantjoinButton; - private MTextField filterWhitelist, filterBlacklist, highlightNote, blacklistClassTxt; - private MIntegerSelectionButton integerSelection; - - @Getter @Setter - boolean delistable = false; - - public void setDelistable(boolean delistable) { - this.delistable = delistable; - updateCreateNew(); - } - - public void updateCreateNew() { - createNew.setText((PartyManager.INSTANCE.getPartyContext() != null && !PartyManager.INSTANCE.isLeader()) ? "Leave Party" : (delistable ? "De-list" : "Create New")); - } - - public PanelPartyFinderSettings(PanelPartyFinder panelPartyFinder) { - this.panelPartyFinder = panelPartyFinder; - - createNew.setOnActionPerformed(this::createNew); - createNew.setBackground(0xFF00838F); - createNew.setHover(0xFF00ACC1); - createNew.setClicked(0xFF0097A7); - add(createNew); - updateCreateNew(); - refresh.setText("Refresh"); - refresh.setOnActionPerformed(this::refresh); - add(refresh); - - settings.setText("Search Settings"); - settings.setOnActionPerformed(this::settings); - add(settings); - - { - filterCantjoinButton = new MToggleButton(); - filterCantjoin = new MPassiveLabelAndElement("Filter Unjoinable", filterCantjoinButton); - filterCantjoin.setDivideRatio(0.7); - filterCantjoinButton.setOnToggle(() -> panelPartyFinder.onChestUpdate(null)); - add(filterCantjoin); - } - { - filterWhitelist = new MTextField() { - @Override - public void edit(String str) { - panelPartyFinder.onChestUpdate(null); - FeatureRegistry.PARTYKICKER_CUSTOM.setWhitelist(str); - } - }; - filterBlacklist = new MTextField() { - @Override - public void edit(String str) { - FeatureRegistry.PARTYKICKER_CUSTOM.setBlacklist(str); - panelPartyFinder.onChestUpdate(null); - } - }; - highlightNote = new MTextField() { - @Override - public void edit(String str) { - super.edit(str); - FeatureRegistry.PARTYKICKER_CUSTOM.setHighlight(str); - } - }; - blacklistClassTxt = new MTextField() { - @Override - public void edit(String str) { - super.edit(str); - FeatureRegistry.PARTYKICKER_CUSTOM.setBlacklistClass(str); - panelPartyFinder.onChestUpdate(null); - } - }; - - filterWhitelist.setText(FeatureRegistry.PARTYKICKER_CUSTOM.getWhitelist()); - filterBlacklist.setText(FeatureRegistry.PARTYKICKER_CUSTOM.getBlacklist()); - highlightNote.setText(FeatureRegistry.PARTYKICKER_CUSTOM.getHighlight()); - blacklistClassTxt.setText(FeatureRegistry.PARTYKICKER_CUSTOM.getBlacklistClass()); - - filterWhitelistNote = new MPassiveLabelAndElement("Whitelist Note", filterWhitelist); - filterBlacklistNote = new MPassiveLabelAndElement("Blacklist Note", filterBlacklist); - plaeHighlightNote = new MPassiveLabelAndElement("Highlight Note", highlightNote); - blacklistClass = new MPassiveLabelAndElement("Blacklist Class", blacklistClassTxt); - - filterWhitelistNote.setDivideRatio(0.5); - filterBlacklistNote.setDivideRatio(0.5); - plaeHighlightNote.setDivideRatio(0.5); - blacklistClass.setDivideRatio(0.5); - add(filterWhitelistNote); - add(filterBlacklistNote); - add(plaeHighlightNote); - add(blacklistClass); - } - { - integerSelection = new MIntegerSelectionButton(FeatureRegistry.PARTYKICKER_CUSTOM.getMinimumCata()); - integerSelection.setOnUpdate(() -> { - FeatureRegistry.PARTYKICKER_CUSTOM.setMinimumCata(integerSelection.getData()); - panelPartyFinder.onChestUpdate(null); - }); - cataLv = new MPassiveLabelAndElement("Minimum Cata Lv", integerSelection); - cataLv.setDivideRatio(0.5); add(cataLv); - } - } - - private void createNew() { - if (PartyManager.INSTANCE.getPartyContext() != null && !PartyManager.INSTANCE.isLeader()) { - ChatProcessor.INSTANCE.addToChatQueue("/p leave ", () -> {}, true); - return; - } - GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); - if (delistable) - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+7, 0, 0, Minecraft.getMinecraft().thePlayer); - else - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+0, 0, 0, Minecraft.getMinecraft().thePlayer); - - } - - public String getHighlightText() { - return highlightNote.getText(); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - - - GuiCustomPartyFinder guiCustomPartyFinder = panelPartyFinder.getGuiCustomPartyFinder(); - if (guiCustomPartyFinder.getGuiChest() == null) return; - Slot s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(9*5+5); - ItemStack itemStack = s.getStack(); - if (itemStack == null) return; - - String dungeon="", floor="", text=""; - { - NBTTagCompound stackTagCompound = itemStack.getTagCompound(); - if (stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); - - if (nbttagcompound.getTagId("Lore") == 9) { - NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); - - for (int i = 0; i < nbttaglist1.tagCount(); i++) { - String str = nbttaglist1.getStringTagAt(i); - if (str.startsWith("ยงaDungeon: ")) { - dungeon = str.substring(11); - } else if (str.startsWith("ยงaFloor: ")) { - floor = str.substring(9); - } else if (str.startsWith("ยงaSearch text: ")) { - text = str.substring(15); - } - } - } - } - } - fontRenderer.drawString("ยงaSearching: "+dungeon+" ยง7- "+floor, 5,155,-1); - fontRenderer.drawString("ยงaSearch text: "+text, 5,155+fontRenderer.FONT_HEIGHT,-1); - - Gui.drawRect(0,160+fontRenderer.FONT_HEIGHT*2,getBounds().width, 161+fontRenderer.FONT_HEIGHT*2, -1); - GlStateManager.translate(5,165+fontRenderer.FONT_HEIGHT*2,0); - - s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(9*5+8); - itemStack = s.getStack(); - if (itemStack == null || itemStack.getItem() != Items.skull) return; - - List list = itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); - for (int i = 0; i < list.size(); ++i) { - if (i == 0) { - list.set(i, itemStack.getRarity().rarityColor + list.get(i)); - } else { - list.set(i, EnumChatFormatting.GRAY + list.get(i)); - } - } - for (int i = 0; i < list.size(); i++) { - fontRenderer.drawString(list.get(i), 0, (i)*fontRenderer.FONT_HEIGHT, -1); - } - } - - public void refresh() { - GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+1, 0, 0, Minecraft.getMinecraft().thePlayer); - } - public void settings() { - GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+5, 0, 0, Minecraft.getMinecraft().thePlayer); - } - - @Override - public void onBoundsUpdate() { - Dimension bounds = getEffectiveDimension(); - refresh.setBounds(new Rectangle(5,5,(bounds.width-10)/2,15)); - createNew.setBounds(new Rectangle(bounds.width/2,5,(bounds.width-10)/2,15)); - filterCantjoin.setBounds(new Rectangle(5,22,bounds.width-10,15)); - filterWhitelistNote.setBounds(new Rectangle(5,39,bounds.width-10,15)); - filterBlacklistNote.setBounds(new Rectangle(5,56,bounds.width-10,15)); - plaeHighlightNote.setBounds(new Rectangle(5,73,bounds.width-10,15)); - cataLv.setBounds(new Rectangle(5,90,bounds.width-10,15)); - blacklistClass.setBounds(new Rectangle(5,107,bounds.width-10,15)); - settings.setBounds(new Rectangle(5,124,bounds.width-10,15)); - } - - public boolean filter(ItemStack itemStack) { - NBTTagCompound stackTagCompound = itemStack.getTagCompound(); - String note = ""; - int dLV = 0; - Set invalidClasses = new HashSet<>(); - for (String s : blacklistClassTxt.getText().split(",")) { - invalidClasses.add(s.toLowerCase()); - } - if (stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); - - if (nbttagcompound.getTagId("Lore") == 9) { - NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); - - for (int i = 0; i < nbttaglist1.tagCount(); i++) { - String str = nbttaglist1.getStringTagAt(i); - if (str.startsWith("ยงcRequires ") && filterCantjoinButton.isEnabled()) return false; - if (str.startsWith("ยง7ยง7Note:")) { - note = str.substring(12); - } - if (str.startsWith("ยง7Dungeon Level Required: ยงb")) { - dLV = Integer.parseInt(str.substring(28)); - } - if (str.startsWith(" ") && str.contains(":")) { - String clazz = TextUtils.stripColor(str).trim().split(" ")[1]; - if (invalidClasses.contains(clazz.toLowerCase())) return false; - } - } - } - } - if (integerSelection.getData() >dLV) return false; - - if (!filterBlacklist.getText().isEmpty()) { - for (String s1 : filterBlacklist.getText().split(",")) { - if (note.toLowerCase().contains(s1.toLowerCase())) return false; - } - } - if (!filterWhitelist.getText().isEmpty()) { - boolean s = false; - for (String s1 : filterWhitelist.getText().split(",")) { - if (note.toLowerCase().contains(s1.toLowerCase())) { - s = true; break; - } - } - if (!s) return false; - } - return true; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java deleted file mode 100644 index 663cde9f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.customgui; - -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; -import kr.syeyoung.dungeonsguide.gui.elements.MTooltipText; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.Slot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.EnumChatFormatting; - -import java.awt.*; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; - -public class PanelPartyListElement extends MPanel { - private PanelPartyFinder panelPartyFinder; - private int slot; - - public PanelPartyListElement(PanelPartyFinder panelPartyFinder, int slot) { - this.panelPartyFinder = panelPartyFinder; - this.slot = slot; - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(-1, 32); - } - - private MTooltip mTooltip; - - private ItemStack lastStack; - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - GuiCustomPartyFinder guiCustomPartyFinder = panelPartyFinder.getGuiCustomPartyFinder(); - if (guiCustomPartyFinder.getGuiChest() == null) return; - Slot s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(slot); - ItemStack itemStack = s.getStack(); - if (itemStack == null && lastStack == null) return; - if (itemStack != null) - lastStack = itemStack; - else - itemStack = lastStack; - int color = RenderUtils.blendAlpha(0x141414, 0.0f); - - String note = ""; - boolean notfound = false; - boolean cantjoin = false; - if (itemStack.getItem() == Item.getItemFromBlock(Blocks.bedrock)) { - cantjoin = true; - notfound = true; - } - int minClass = -1, minDungeon = -1; - int pplIn = 0; - Set dungeonClasses = new HashSet<>(); - { - NBTTagCompound stackTagCompound = itemStack.getTagCompound(); - if (stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); - - if (nbttagcompound.getTagId("Lore") == 9) { - NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); - - for (int i = 0; i < nbttaglist1.tagCount(); i++) { - String str = nbttaglist1.getStringTagAt(i); - if (str.startsWith("ยง7ยง7Note:")) { - note = str.substring(12); - } else if (str.startsWith("ยง7Class Level Required: ยงb")) { - minClass = Integer.parseInt(str.substring(26)); - } else if (str.startsWith("ยง7Dungeon Level Required: ยงb")) { - minDungeon = Integer.parseInt(str.substring(28)); - } else if (str.startsWith("ยงcRequires ")) cantjoin = true; - if (str.endsWith("ยงb)")) pplIn ++; - - if (str.startsWith(" ") && str.contains(":")) { - String clazz = TextUtils.stripColor(str).trim().split(" ")[1]; - dungeonClasses.add(clazz); - } - } - } - } - } - - boolean nodupe = note.toLowerCase().contains("nodupe") || note.toLowerCase().contains("no dupe") || (note.toLowerCase().contains("nd") && (note.toLowerCase().indexOf("nd") == 0 || note.charAt(note.toLowerCase().indexOf("nd")-1) == ' ')); - - note = note.replaceAll("(?i)(S\\+)", "ยง6$1ยงr"); - note = note.replaceAll("(?i)(carry)", "ยง4$1ยงr"); - - try { - if (!panelPartyFinder.getHighlightNote().isEmpty()) { - for (String s1 : panelPartyFinder.getHighlightNote().split(",")) { - note = note.replaceAll("(?i)(" + s1 + ")", "ยงeยงl$1ยงr"); - } - } - } catch (Exception e) {} - - if (cantjoin) {} - else if (clicked) { - color = RenderUtils.blendAlpha(0x141414, 0.10f); - } else if (lastAbsClip.contains(absMousex, absMousey) && (getTooltipsOpen() == 0 || (mTooltip != null && mTooltip.isOpen()))) { - color = RenderUtils.blendAlpha(0x141414, 0.12f); - } - if (cantjoin) {} - else if (note.contains("ยงe")) { - color = RenderUtils.blendTwoColors(color, 0x44FFFF00); - } else if (note.contains("ยง6")){ - color = RenderUtils.blendTwoColors(color, 0x44FFAA00); - } - - if (nodupe && dungeonClasses.contains(FeatureRegistry.PARTYKICKER_CUSTOM.getLastClass())) { - color = RenderUtils.blendTwoColors(color, 0x44FF0000); - note = note.replace("nodupe", "ยงcnodupeยงr").replace("no dupe", "ยงcno dupeยงr").replace("nd", "ยงcndยงr"); - } - Gui.drawRect(0,0,getBounds().width,getBounds().height,color); - - RenderItem renderItem= Minecraft.getMinecraft().getRenderItem(); - GlStateManager.pushMatrix(); - RenderHelper.disableStandardItemLighting(); - RenderHelper.enableGUIStandardItemLighting(); - GlStateManager.scale(2,2,1); - GlStateManager.enableDepth(); - renderItem.renderItemAndEffectIntoGUI(itemStack, 0,0); - GlStateManager.popMatrix(); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.pushMatrix(); - GlStateManager.translate(37,(32 - 2*fr.FONT_HEIGHT)/2,0); - GlStateManager.scale(2,2,1); - String name = itemStack.getDisplayName(); - if (name.contains("'")) - name = name.substring(0, name.indexOf("'")); - fr.drawString(name, 0,0,-1); - - if (!notfound) - note = "ยง7("+pplIn+") ยงf"+note; - fr.drawString(note, fr.getStringWidth("AAAAAAAAAAAAAAAA")+5, 0,-1); - GlStateManager.popMatrix(); - GlStateManager.pushMatrix(); - String sideNote = ""; - if (minClass != -1) sideNote += "ยง7CLv โ‰ฅยงb"+minClass+" "; - if (minDungeon != -1) sideNote += "ยง7DLv โ‰ฅยงb"+minDungeon+" "; - if (cantjoin && !notfound) sideNote = "ยงcCan't join"; - sideNote = sideNote.trim(); - - GlStateManager.translate(getBounds().width,(32 - 2*fr.FONT_HEIGHT)/2,0); - GlStateManager.scale(2,2,0); - GlStateManager.translate(-fr.getStringWidth(sideNote), 0,0); - fr.drawString(sideNote, 0,0,-1); - - GlStateManager.popMatrix(); - if (lastAbsClip.contains(absMousex, absMousey) && (mTooltip == null || !mTooltip.isOpen()) && getTooltipsOpen() == 0) { - if (mTooltip != null) mTooltip.close(); - List list = itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); - for (int i = 0; i < list.size(); ++i) { - if (i == 0) { - list.set(i, itemStack.getRarity().rarityColor + list.get(i)); - } else { - list.set(i, EnumChatFormatting.GRAY + list.get(i)); - } - } - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - mTooltip = new MTooltipText(list); - mTooltip.setScale(scaledResolution.getScaleFactor()); - mTooltip.open(this); - } else if (!lastAbsClip.contains(absMousex, absMousey)){ - if (mTooltip != null) - mTooltip.close(); - mTooltip = null; - } - } - - @Override - public void setParent(MPanel parent) { - super.setParent(parent); - if (parent == null && mTooltip != null) { - mTooltip.close(); - mTooltip = null; - } - } - - boolean clicked = false; - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY)&& (getTooltipsOpen() == 0 || (mTooltip != null && mTooltip.isOpen()))) { - clicked = true; - - GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); - Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, slot, 0, 0, Minecraft.getMinecraft().thePlayer); - } - } - - @Override - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - clicked = false; - } - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (lastAbsClip.contains(absMouseX, absMouseY) && (getTooltipsOpen() == 0 || (mTooltip != null && mTooltip.isOpen()))) { - setCursor(EnumCursor.POINTING_HAND); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FakePlayer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FakePlayer.java deleted file mode 100644 index ec8a29d9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FakePlayer.java +++ /dev/null @@ -1,101 +0,0 @@ -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; - -import com.google.common.base.Objects; -import com.mojang.authlib.GameProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.SkinFetcher; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Team; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; - -public class FakePlayer extends EntityOtherPlayerMP { - @Setter - @Getter - private PlayerProfile skyblockProfile; - private final SkinFetcher.SkinSet skinSet; - private final PlayerProfile.Armor armor; - @Getter - private final int profileNumber; - - private FakePlayer(World w) { - super(w, null); - throw new UnsupportedOperationException("what"); - } - - public FakePlayer(GameProfile playerProfile, SkinFetcher.SkinSet skinSet, PlayerProfile skyblockProfile, int profileNumber) { - super(Minecraft.getMinecraft().theWorld, playerProfile); - this.profileNumber = profileNumber; - this.skyblockProfile = skyblockProfile; - this.skinSet = skinSet; - armor = skyblockProfile.getCurrentArmor(); - this.inventory.armorInventory = skyblockProfile.getCurrentArmor().getArmorSlots(); - - int highestDungeonScore = Integer.MIN_VALUE; - if (skyblockProfile.getInventory() != null) { - ItemStack highestItem = null; - for (ItemStack itemStack : skyblockProfile.getInventory()) { - if (itemStack == null) continue; - NBTTagCompound display = itemStack.getTagCompound().getCompoundTag("display"); - if (display == null) continue; - NBTTagList nbtTagList = display.getTagList("Lore", 8); - if (nbtTagList == null) continue; - for (int i = 0; i < nbtTagList.tagCount(); i++) { - String str = nbtTagList.getStringTagAt(i); - if (TextUtils.stripColor(str).startsWith("Gear")) { - int dungeonScore = Integer.parseInt(TextUtils.keepIntegerCharactersOnly(TextUtils.stripColor(str).split(" ")[2])); - if (dungeonScore > highestDungeonScore) { - highestItem = itemStack; - highestDungeonScore = dungeonScore; - } - } - } - } - - this.inventory.mainInventory[0] = highestItem; - this.inventory.currentItem = 0; - } - } - - public String getSkinType() { - return this.skinSet == null ? DefaultPlayerSkin.getSkinType(getGameProfile().getId()) : this.skinSet.getSkinType(); - } - - public ResourceLocation getLocationSkin() { - return Objects.firstNonNull(skinSet.getSkinLoc(), DefaultPlayerSkin.getDefaultSkin(getGameProfile().getId())); - } - - public ResourceLocation getLocationCape() { - return skinSet.getCapeLoc(); - } - - @Override - public ItemStack[] getInventory() { - return this.inventory.armorInventory; - } - - @Override - public boolean isInvisibleToPlayer(EntityPlayer player) { - return true; - } - - @Override - public Team getTeam() { - return new ScorePlayerTeam(null, null) { - @Override - public EnumVisible getNameTagVisibility() { - return EnumVisible.NEVER; - } - }; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java deleted file mode 100644 index 74beb42f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java +++ /dev/null @@ -1,703 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; - -import com.mojang.authlib.GameProfile; -import io.github.moulberry.hychat.HyChat; -import io.github.moulberry.hychat.chat.ChatManager; -import io.github.moulberry.hychat.gui.GuiChatBox; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.chat.ChatProcessor; -import kr.syeyoung.dungeonsguide.chat.PartyContext; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; -import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.ApiFetcher; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.PlayerSkyblockData; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.SkinFetcher; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.DataRendererEditor; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.DataRendererRegistry; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener; -import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.event.HoverEvent; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.common.Loader; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.List; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -public class FeatureViewPlayerStatsOnJoin extends SimpleFeature implements GuiPostRenderListener, ChatListener, GuiClickListener { - - public FeatureViewPlayerStatsOnJoin() { - super("Party", "View player stats when join", "view player rendering when joining/someone joins the party", "partykicker.viewstats", true); - - - this.parameters.put("datarenderers", new FeatureParameter>("datarenderers", "DataRenderers", "Datarenderssdasd", new ArrayList<>(Arrays.asList( - "catalv", "selected_class_lv", "dungeon_catacombs_higheststat", "dungeon_master_catacombs_higheststat", "skill_combat_lv", "skill_foraging_lv", "skill_mining_lv", "fairysouls", "dummy" - )), "stringlist")); - - - - - } - - - ChangeProfileWidget profileButtonWidget = new ChangeProfileWidget(); - - static Minecraft mc = Minecraft.getMinecraft(); - protected Rectangle popupRect; - private String lastuid; // actually current uid - private CompletableFuture> profileFuture; - private Future> gameProfileFuture; - private Future skinFuture; - private FakePlayer fakePlayer; - private boolean shouldDraw = false; - - - @Override - public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { - if (!(mc.currentScreen instanceof GuiChat)) { - cancelRender(); - return; - } - - ScaledResolution scaledResolution = new ScaledResolution(mc); - - IChatComponent ichatcomponent = getHoveredComponent(scaledResolution); - String uid = null; - if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() instanceof HoverEventRenderPlayer) { - uid = ((HoverEventRenderPlayer) ichatcomponent.getChatStyle().getChatHoverEvent()).getUuid(); - } - - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int mouseX = Mouse.getX() * width / mc.displayWidth; - int mouseY = height - Mouse.getY() * height / mc.displayHeight - 1; - - shouldCancelRendering(uid, mouseX, mouseY); - - if (lastuid == null) return; - - - if (popupRect == null) { - popupRect = new Rectangle(mouseX, mouseY, 220, 220); - if (popupRect.y + popupRect.height > scaledResolution.getScaledHeight()) { - popupRect.y -= popupRect.y + popupRect.height - scaledResolution.getScaledHeight(); - } - } - - if (profileFuture == null) { - profileFuture = ApiFetcher.fetchMostRecentProfileAsync(lastuid, FeatureRegistry.PARTYKICKER_APIKEY.getAPIKey()); - } - - if (gameProfileFuture == null) { - gameProfileFuture = ApiFetcher.getSkinGameProfileByUUIDAsync(lastuid); - } - boolean plsSetAPIKEY = false; - if (skinFuture == null && gameProfileFuture.isDone()) { - try { - skinFuture = SkinFetcher.getSkinSet(gameProfileFuture.get().orElse(null)); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - - try { - if (fakePlayer == null && skinFuture != null && profileFuture != null && skinFuture.isDone() && profileFuture.isDone() && profileFuture.get().isPresent()) { - if (profileButtonWidget.getCurrentrySelectedProfile(profileFuture.get().get()) != null) { - if (skinFuture.get() != null) { - profileButtonWidget.setCurrentyselectedprofile(profileFuture.get().get().getLastestprofileArrayIndex()); - fakePlayer = new FakePlayer(gameProfileFuture.get().orElse(null), skinFuture.get(), profileButtonWidget.getCurrentrySelectedProfile(profileFuture.get().get()), profileButtonWidget.getCurrentyselectedprofile()); - } - } - } else if (fakePlayer != null) { - if (fakePlayer.getProfileNumber() != profileButtonWidget.getCurrentyselectedprofile()) { - fakePlayer = new FakePlayer(gameProfileFuture.get().orElse(null), skinFuture.get(), profileButtonWidget.getCurrentrySelectedProfile(profileFuture.get().get()), profileButtonWidget.getCurrentyselectedprofile()); - } - } - } catch (InterruptedException | ExecutionException e) { - plsSetAPIKEY = true; - } - - - Optional playerProfile; - if (plsSetAPIKEY || !profileFuture.isDone()) { - playerProfile = null; - } else { - PlayerSkyblockData data = null; - try { - data = profileFuture.get().get(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - PlayerProfile currentlySelectedProfile = profileButtonWidget.getCurrentrySelectedProfile(data); - playerProfile = Optional.ofNullable(currentlySelectedProfile); - } - - - draw(scaledResolution, mouseX, mouseY, plsSetAPIKEY, playerProfile); - } - - - private void draw(ScaledResolution scaledResolution, int mouseX, int mouseY, boolean plsSetAPIKEY, Optional playerProfile) { - GlStateManager.pushMatrix(); - GlStateManager.translate(popupRect.x, popupRect.y, 0); - int backroundGuiColor = 0xFF23272a; - Gui.drawRect(0, 0, popupRect.width, popupRect.height, backroundGuiColor); - Gui.drawRect(2, 2, popupRect.width - 2, popupRect.height - 2, 0XFF2c2f33); - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (plsSetAPIKEY) { - mc.fontRendererObj.drawString("Please set API KEY on /dg -> Party Kicker", 5, 5, 0xFFFFFFFF); - GlStateManager.popMatrix(); - } else if (playerProfile == null) { - mc.fontRendererObj.drawString("Fetching data...", 5, 5, 0xFFFFFFFF); - GlStateManager.popMatrix(); - } else if (!playerProfile.isPresent()) { - mc.fontRendererObj.drawString("User could not be found", 5, 5, 0xFFFFFFFF); - GlStateManager.popMatrix(); - } else { - int relX = mouseX - popupRect.x; - int relY = mouseY - popupRect.y; - FontRenderer fr = mc.fontRendererObj; - GL11.glEnable(GL11.GL_SCISSOR_TEST); - clip(scaledResolution, popupRect.x, popupRect.y, popupRect.width, popupRect.height); - - Gui.drawRect(0, 168, 90, 195, backroundGuiColor); - Gui.drawRect(2, 170, 88, 193, new Rectangle(2, 170, 86, 23).contains(relX, relY) ? 0xFFff7777 : 0xFFFF3333); - - Gui.drawRect(0, 193, 90, 220, backroundGuiColor); - Gui.drawRect(2, 195, 88, 218, new Rectangle(2, 195, 86, 23).contains(relX, relY) ? 0xFF859DF0 : 0xFF7289da); - - - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Kick", (90 - fr.getStringWidth("Kick")) / 2, (364 - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - fr.drawString("Invite", (90 - fr.getStringWidth("Invite")) / 2, (414 - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - - GlStateManager.pushMatrix(); - GlStateManager.translate(95, 5, 0); - int culmutativeY = 5; - IDataRenderer dataRendererToHover = null; - for (String datarenderers : this.>getParameter("datarenderers").getValue()) { - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); - Dimension dim; - if (dataRenderer == null) { - fr.drawString("Couldn't find Datarenderer", 0, 0, 0xFFFF0000); - fr.drawString(datarenderers, 0, fr.FONT_HEIGHT, 0xFFFF0000); - dim = new Dimension(0, fr.FONT_HEIGHT * 2); - } else { - GlStateManager.pushMatrix(); - dim = dataRenderer.renderData(playerProfile.get()); - GlStateManager.popMatrix(); - } - if (relX >= 95 && relX <= popupRect.width && relY >= culmutativeY && relY < culmutativeY + dim.height && dataRenderer != null) { - dataRendererToHover = dataRenderer; - } - culmutativeY += dim.height; - GlStateManager.translate(0, dim.height, 0); - } - GlStateManager.popMatrix(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - Gui.drawRect(0, 0, 90, 170, backroundGuiColor); - Gui.drawRect(2, 2, 88, 168, 0xFF444444); - - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - - profileButtonWidget.drawChangeProfileButton(relX, relY); - - - Gui.drawRect(78, 156, 90, 170, backroundGuiColor); - fr.drawString("ยงeI", 82, 159, -1); - - - - GlStateManager.color(1, 1, 1, 1.0F); - if (fakePlayer != null) { - drawFakePlayer(scaledResolution, mouseX, mouseY, playerProfile, relX, relY, fr); - } else { - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Loading", 5, 35, 0xFFEFFF00); - } - GlStateManager.popMatrix(); - GL11.glDisable(GL11.GL_SCISSOR_TEST); - if (dataRendererToHover != null && !shouldDraw) { - dataRendererToHover.onHover(playerProfile.get(), mouseX, mouseY); - } - GL11.glEnable(GL11.GL_SCISSOR_TEST); - GlStateManager.pushMatrix(); - GlStateManager.translate(popupRect.x, popupRect.y, 0); - if (shouldDraw) { - int startX = 81; - int startY = 86; - clip(scaledResolution, popupRect.x + startX - 1, popupRect.y + startY - 1, 164, 74); - GlStateManager.translate(startX, startY, 1); - Gui.drawRect(-1, -1, 163, 73, 0xFF000000); - GlStateManager.disableLighting(); - ItemStack toHover = null; - int rx = relX - startX; - int ry = relY - startY; - - if (playerProfile.get().getInventory() != null) { - GlStateManager.disableRescaleNormal(); - RenderHelper.enableGUIStandardItemLighting(); - GlStateManager.disableLighting(); - for (int i = 0; i < playerProfile.get().getInventory().length; i++) { - int x = (i % 9) * 18; - int y = (i / 9) * 18; - if (x <= rx && rx < x + 18 && y <= ry && ry < y + 18) { - toHover = playerProfile.get().getInventory()[(i + 9) % 36]; - } - Gui.drawRect(x, y, x + 18, y + 18, 0xFF000000); - Gui.drawRect(x + 1, y + 1, x + 17, y + 17, 0xFF666666); - GlStateManager.color(1, 1, 1, 1.0F); - - mc.getRenderItem().renderItemAndEffectIntoGUI(playerProfile.get().getInventory()[(i + 9) % 36], (i % 9) * 18 + 1, (i / 9) * 18 + 1); - } - - if (toHover != null) { - drawItemStackToolTip(scaledResolution, mouseX, mouseY, fr, toHover); - } - } else { - Gui.drawRect(0, 0, 162, 72, 0xFF666666); - fr.drawSplitString("Player has disabled Inventory API", 5, 5, 142, -1); - } - - } - GL11.glDisable(GL11.GL_SCISSOR_TEST); - GlStateManager.popMatrix(); // 33 66 108 130 154 // 5 75 - } - - - } - - private void drawFakePlayer(ScaledResolution scaledResolution, int mouseX, int mouseY, Optional playerProfile, int relX, int relY, FontRenderer fr) { - clip(scaledResolution, popupRect.x + 2, popupRect.y + 2, 86, 166); - GuiInventory.drawEntityOnScreen(45, 150, 60, -(mouseX - popupRect.x - 75), 0, fakePlayer); - - String toDraw = fakePlayer.getName(); - List activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayer().get(UUID.fromString(TextUtils.insertDashUUID(playerProfile.get().getMemberUID()))); - CosmeticData prefix = null; - CosmeticData color = null; - if (activeCosmetics != null) { - for (ActiveCosmetic activeCosmetic : activeCosmetics) { - CosmeticData cosmeticData = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData != null) { - if (cosmeticData.getCosmeticType().equals("prefix")) prefix = cosmeticData; - if (cosmeticData.getCosmeticType().equals("color")) color = cosmeticData; - } - } - } - toDraw = (color == null ? "ยงe" : color.getData().replace("&", "ยง")) + toDraw; - if (prefix != null) toDraw = prefix.getData().replace("&", "ยง") + " " + toDraw; - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - - - String profileName = "on ยง6" + playerProfile.get().getProfileName(); - fr.drawString(profileName, (90 - fr.getStringWidth(profileName)) / 2, 15, -1); - - - fr.drawString(toDraw, (90 - fr.getStringWidth(toDraw)) / 2, 10 - (fr.FONT_HEIGHT / 2), -1); - - ItemStack toHover = null; - if (relX > 20 && relX < 70) { - if (33 <= relY && relY <= 66) { - toHover = fakePlayer.getInventory()[3]; - } else if (66 <= relY && relY <= 108) { - toHover = fakePlayer.getInventory()[2]; - } else if (108 <= relY && relY <= 130) { - toHover = fakePlayer.getInventory()[1]; - } else if (130 <= relY && relY <= 154) { - toHover = fakePlayer.getInventory()[0]; - } - } else if (relX > 0 && relX <= 20) { - if (80 <= relY && relY <= 120) { - toHover = fakePlayer.inventory.mainInventory[fakePlayer.inventory.currentItem]; - } - } - - if (toHover != null) { - drawItemStackToolTip(scaledResolution, mouseX, mouseY, fr, toHover); - GlStateManager.translate(popupRect.x, popupRect.y, 0); - } - clip(scaledResolution, popupRect.x, popupRect.y, popupRect.width, popupRect.height); - } - - public void drawItemStackToolTip(ScaledResolution scaledResolution, int mouseX, int mouseY, FontRenderer fr, ItemStack toHover) { - List list = toHover.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips); - for (int i = 0; i < list.size(); ++i) { - if (i == 0) { - list.set(i, toHover.getRarity().rarityColor + list.get(i)); - } else { - list.set(i, EnumChatFormatting.GRAY + list.get(i)); - } - } - FontRenderer font = toHover.getItem().getFontRenderer(toHover); - GlStateManager.popMatrix(); - GL11.glDisable(GL11.GL_SCISSOR_TEST); - FontRenderer theRenderer = (font == null ? fr : font); - GuiUtils.drawHoveringText(list, mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, theRenderer); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - GlStateManager.pushMatrix(); - } - - - class ChangeProfileWidget { - public ChangeProfileWidget(){ - fr = Minecraft.getMinecraft().fontRendererObj; - stringWidth = fr.getStringWidth(buttonText); - textx = ((83 - stringWidth) / 2); - texty = (324 - fr.FONT_HEIGHT) / 2; - blockWidth = stringWidth + 3; - blockHeight = fr.FONT_HEIGHT + 2; - } - - FontRenderer fr; - - @Getter @Setter - int currentyselectedprofile = 0; - - String buttonText = "Switch Profile"; - - int stringWidth; - int textx; - int texty; - - int blockWidth; - int blockHeight; - - void drawChangeProfileButton(float relX, float relY){ - - boolean contains = isWithinButtonRec(relX, relY); - - Gui.drawRect(textx - 5, texty - 1, textx + blockWidth, texty + blockHeight, contains ? 0xFFFFFFFF : 0xFF30afd3); - - fr.drawString(buttonText, textx, texty + 2, contains ? 0x30afd3 : 0xFFFFFF); - } - - - Rectangle getButtonRec(){ - return new Rectangle(textx - 5, texty - 1, blockWidth, blockHeight); - } - - boolean isWithinButtonRec(float relX, float relY){ - return getButtonRec().contains(relX, relY); - } - - long clickDeBounce = 0; - void handleClickProfileButton(PlayerSkyblockData playerData){ - - if(System.currentTimeMillis() <= clickDeBounce){ - return; - } else { - clickDeBounce = System.currentTimeMillis() + 200; - } - - ScaledResolution scaledResolution = new ScaledResolution(mc); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int mouseX = Mouse.getX() * width / mc.displayWidth; - int mouseY = height - Mouse.getY() * height / mc.displayHeight - 1; - - int relX = mouseX - popupRect.x; - int relY = mouseY - popupRect.y; - - if (isWithinButtonRec(relX, relY)) { - if (profileButtonWidget.currentyselectedprofile + 1 >= playerData.getPlayerProfiles().length) { - profileButtonWidget.currentyselectedprofile = 0; - } else { - profileButtonWidget.currentyselectedprofile++; - } - } - } - - PlayerProfile getCurrentrySelectedProfile(PlayerSkyblockData data) { - if (data == null) return null; - if (data.getPlayerProfiles() == null) return null; - if (data.getPlayerProfiles().length == 0) return null; - if (data.getPlayerProfiles().length < currentyselectedprofile) return null; - return data.getPlayerProfiles()[currentyselectedprofile]; - } - } - - - - - private void shouldCancelRendering(String uid, int mouseX, int mouseY) { - if (!((popupRect != null && (popupRect.contains(mouseX, mouseY) || shouldDraw)) || uid != null && uid.equals(lastuid))) { - cancelRender(); - } - - if (uid != null && !uid.equals(lastuid) && (popupRect==null || (!popupRect.contains(mouseX, mouseY) && !shouldDraw)) ) { - cancelRender(); - lastuid = uid; - } - } - - public void cancelRender() { - popupRect = null; - profileFuture = null; - lastuid = null; - gameProfileFuture = null; - skinFuture = null; - fakePlayer = null; - shouldDraw = false; - } - - - public static void clip(ScaledResolution resolution, int x, int y, int width, int height) { - if (width < 0 || height < 0) return; - - int scale = resolution.getScaleFactor(); - GL11.glScissor((x) * scale, mc.displayHeight - (y + height) * scale, (width) * scale, height * scale); - } - - @Override - public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { - ScaledResolution scaledResolution = new ScaledResolution(mc); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int mouseX = Mouse.getX() * width / mc.displayWidth; - int mouseY = height - Mouse.getY() * height / mc.displayHeight - 1; - - if (Mouse.getEventButton() != -1 && Mouse.isButtonDown(Mouse.getEventButton()) && shouldDraw) shouldDraw = false; - if (popupRect == null || !popupRect.contains(mouseX, mouseY)) return; - - mouseInputEvent.setCanceled(true); - - int relX = mouseX - popupRect.x; - int relY = mouseY - popupRect.y; - - try { - PlayerSkyblockData playerData; - - if (profileFuture.isDone()) { - playerData = profileFuture.get().orElse(null); - } else { - return; - } - - if (playerData == null) { - return; - } - - if (Mouse.getEventButton() == -1 && !Mouse.isButtonDown(Mouse.getEventButton())) return; - - if (new Rectangle(2, 195, 86, 23).contains(relX, relY)) { - // invite - ChatProcessor.INSTANCE.addToChatQueue("/p invite " + ApiFetcher.fetchNicknameAsync(profileButtonWidget.getCurrentrySelectedProfile(playerData).getMemberUID()).get().orElse("-"), () -> { - }, true); - } - - else if (new Rectangle(2, 170, 86, 23).contains(relX, relY)) { - // kick - ChatProcessor.INSTANCE.addToChatQueue("/p kick " + ApiFetcher.fetchNicknameAsync(profileButtonWidget.getCurrentrySelectedProfile(playerData).getMemberUID()).get().orElse("-"), () -> { - }, true); - } - - - - else if (new Rectangle(80, 159, 10, 11).contains(relX, relY)) { - shouldDraw = true; - } - - - this.profileButtonWidget.handleClickProfileButton(playerData); - - - - } catch (InterruptedException | ExecutionException e) { - } - - - } - - - - public IChatComponent getHoveredComponent(ScaledResolution scaledResolution) { - IChatComponent ichatcomponent = null; - if (Loader.isModLoaded("hychat")) { - try { - ChatManager chatManager = HyChat.getInstance().getChatManager(); - GuiChatBox guiChatBox = chatManager.getFocusedChat(); - - int x = guiChatBox.getX(scaledResolution); - int y = guiChatBox.getY(scaledResolution); - ichatcomponent = guiChatBox.chatArray.getHoveredComponent(guiChatBox.getSelectedTab().getChatLines(), Mouse.getX(), Mouse.getY(), x, y); - } catch (Throwable t) {} - } - if (ichatcomponent == null) { - ichatcomponent = Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY()); - } - return ichatcomponent; - -// return Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY()); - } - - @Override - public void onChat(ClientChatReceivedEvent event) { - if (!isEnabled()) return; - String str = event.message.getFormattedText(); - if (str.contains("ยงrยงejoined the dungeon group! (ยงrยงb")) { - String username = TextUtils.stripColor(str).split(" ")[3]; - if (username.equalsIgnoreCase(mc.getSession().getUsername())) { - PartyManager.INSTANCE.requestPartyList(context -> { - if (context == null) { - mc.thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcBugged Dungeon Party ")); - } else { - processPartyMembers(context); - } - }); - } else { - ApiFetcher.fetchUUIDAsync(username) - .thenAccept(a -> { - if (a == null) { - mc.thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + username + "ยงf's Profile ยงcCouldn't fetch uuid")); - return; - } - ApiFetcher.fetchMostRecentProfileAsync(a.get(), FeatureRegistry.PARTYKICKER_APIKEY.getAPIKey()); - mc.thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + username + "ยงf's Profile ").appendSibling(new ChatComponentText("ยง7view").setChatStyle(new ChatStyle().setChatHoverEvent(new FeatureViewPlayerStatsOnJoin.HoverEventRenderPlayer(a.orElse(null)))))); - }); - } - } - } - - public static void processPartyMembers(PartyContext context) { - for (String member : context.getPartyRawMembers()) { - ApiFetcher.fetchUUIDAsync(member) - .thenAccept(a -> { - if (a == null) { - mc.thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + member + "ยงf's Profile ยงcCouldn't fetch uuid")); - } else { - ApiFetcher.fetchMostRecentProfileAsync(a.get(), FeatureRegistry.PARTYKICKER_APIKEY.getAPIKey()); - mc.thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + member + "ยงf's Profile ").appendSibling(new ChatComponentText("ยง7view").setChatStyle(new ChatStyle().setChatHoverEvent(new HoverEventRenderPlayer(a.orElse(null)))))); - } - }); - } - } - - - public static class HoverEventRenderPlayer extends HoverEvent { - @Getter - private final String uuid; - - public HoverEventRenderPlayer(String uuid) { - super(Action.SHOW_TEXT, new ChatComponentText("")); - this.uuid = uuid; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - HoverEventRenderPlayer that = (HoverEventRenderPlayer) o; - return Objects.equals(uuid, that.uuid); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), uuid); - } - - private IChatComponent cached; - - @Override - public IChatComponent getValue() { - if (cached == null) { - cached = new ChatComponentText("") - .setChatStyle( - new ChatStyle() - .setChatHoverEvent( - new HoverEvent( - Action.SHOW_TEXT, - new ChatComponentText(uuid) - ) - ) - ); - return cached; - } - return cached; - } - } - - - @Override - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey(), () -> { - - MFeatureEdit featureEdit = new MFeatureEdit(FeatureViewPlayerStatsOnJoin.this, rootConfigPanel); - featureEdit.addParameterEdit("datarenderers", new DataRendererEditor(FeatureViewPlayerStatsOnJoin.this)); - for (FeatureParameter parameter : getParameters()) { - if (parameter.getKey().equals("datarenderers")) continue; - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureViewPlayerStatsOnJoin.this, parameter, rootConfigPanel)); - } - return featureEdit; - }); - return "base." + getKey(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/ApiFetcher.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/ApiFetcher.java deleted file mode 100644 index c11bc404..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/ApiFetcher.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.mojang.authlib.GameProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfileParser; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import org.apache.commons.io.IOUtils; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class ApiFetcher { - - private ApiFetcher(){} - - private static final Gson gson = new Gson(); - - private static final Map> playerProfileCache = new ConcurrentHashMap<>(); - private static final Map> nicknameToUID = new ConcurrentHashMap<>(); - private static final Map> UIDtoNickname = new ConcurrentHashMap<>(); - private static final Map> UIDtoGameProfile = new ConcurrentHashMap<>(); - - private static final ExecutorService ex = Executors.newFixedThreadPool(4); - - private static final Set invalidKeys = new HashSet<>(); - - public static void purgeCache() { - playerProfileCache.clear(); - nicknameToUID.clear(); - UIDtoNickname.clear(); - UIDtoGameProfile.clear(); - - completableFutureMap.clear(); - completableFutureMap2.clear(); - completableFutureMap3.clear(); - completableFutureMap4.clear(); - invalidKeys.clear(); - PlayerProfileParser.constants = null; - - ex.submit(PlayerProfileParser::getLilyWeightConstants); - } - - static { - ex.submit(PlayerProfileParser::getLilyWeightConstants); - } - - public static JsonObject getJson(String url) throws IOException { - URLConnection connection = new URL(url).openConnection(); - connection.setConnectTimeout(10000); - connection.setReadTimeout(10000); - InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream()); - String serverres = IOUtils.toString(inputStreamReader); - return gson.fromJson(serverres, JsonObject.class); - } - - public static JsonArray getJsonArr(String url) throws IOException { - URLConnection connection = new URL(url).openConnection(); - connection.setConnectTimeout(10000); - connection.setReadTimeout(10000); - return gson.fromJson(new InputStreamReader(connection.getInputStream()), JsonArray.class); - } - - private static final Map>> completableFutureMap4 = new ConcurrentHashMap<>(); - - public static CompletableFuture> getSkinGameProfileByUUIDAsync(String uid) { - if (UIDtoGameProfile.containsKey(uid)) { - CachedData cachedData = UIDtoGameProfile.get(uid); - if (cachedData.getExpire() > System.currentTimeMillis()) { - return CompletableFuture.completedFuture(Optional.ofNullable(cachedData.getData())); - } - UIDtoGameProfile.remove(uid); - } - if (completableFutureMap4.containsKey(uid)) return completableFutureMap4.get(uid); - - CompletableFuture> completableFuture = new CompletableFuture<>(); - fetchNicknameAsync(uid).thenAccept(nick -> { - if (!nick.isPresent()) { - completableFuture.complete(Optional.empty()); - return; - } - ex.submit(() -> { - try { - Optional playerProfile = getSkinGameProfileByUUID(uid, nick.get()); - UIDtoGameProfile.put(uid, new CachedData(System.currentTimeMillis() + 1000 * 60 * 30, playerProfile.orElse(null))); - completableFuture.complete(playerProfile); - completableFutureMap4.remove(uid); - return; - } catch (IOException e) { - e.printStackTrace(); - } - completableFuture.complete(Optional.empty()); - completableFutureMap4.remove(uid); - }); - }); - completableFutureMap4.put(uid, completableFuture); - return completableFuture; - } - - public static Optional getSkinGameProfileByUUID(String uid, String nickname) throws IOException { - GameProfile gameProfile = new GameProfile(UUID.fromString(uid), nickname); - GameProfile newProf = Minecraft.getMinecraft().getSessionService().fillProfileProperties(gameProfile, true); - return newProf == gameProfile ? Optional.empty() : Optional.of(newProf); - } - - - private static final Map>> completableFutureMap = new ConcurrentHashMap<>(); - - public static CompletableFuture> fetchMostRecentProfileAsync(String uid, String apiKey) { - if (playerProfileCache.containsKey(uid)) { - CachedData cachedData = playerProfileCache.get(uid); - if (cachedData.getExpire() > System.currentTimeMillis()) { - return CompletableFuture.completedFuture(Optional.ofNullable(cachedData.getData())); - } - playerProfileCache.remove(uid); - } - if (completableFutureMap.containsKey(uid)) { - return completableFutureMap.get(uid); - } - if (invalidKeys.contains(apiKey)) { - CompletableFuture cf = new CompletableFuture(); - cf.completeExceptionally(new IOException("403 for url")); - return cf; - } - CompletableFuture> completableFuture = new CompletableFuture<>(); - ex.submit(() -> { - try { - Optional playerProfile = fetchPlayerProfiles(uid, apiKey); - playerProfileCache.put(uid, new CachedData<>(System.currentTimeMillis() + 1000 * 60 * 30, playerProfile.orElse(null))); - completableFuture.complete(playerProfile); - completableFutureMap.remove(uid); - } catch (IOException e) { - if (e.getMessage().contains("403 for URL")) { - completableFuture.completeExceptionally(e); - completableFutureMap.remove(uid); - invalidKeys.add(apiKey); - } else { - completableFuture.completeExceptionally(e); - completableFutureMap.remove(uid); - } - e.printStackTrace(); - } - }); - completableFutureMap.put(uid, completableFuture); - return completableFuture; - } - - private static final Map>> completableFutureMap3 = new ConcurrentHashMap<>(); - - public static CompletableFuture> fetchNicknameAsync(String uid) { - if (UIDtoNickname.containsKey(uid)) { - CachedData cachedData = UIDtoNickname.get(uid); - if (cachedData.getExpire() > System.currentTimeMillis()) { - return CompletableFuture.completedFuture(Optional.ofNullable(cachedData.getData())); - } - UIDtoNickname.remove(uid); - } - if (completableFutureMap3.containsKey(uid)) return completableFutureMap3.get(uid); - - - CompletableFuture> completableFuture = new CompletableFuture<>(); - - ex.submit(() -> { - try { - Optional playerProfile = fetchNickname(uid); - UIDtoNickname.put(uid, new CachedData(System.currentTimeMillis() + 1000 * 60 * 60 * 12, playerProfile.orElse(null))); - if (playerProfile.isPresent()) - nicknameToUID.put(playerProfile.orElse(null), new CachedData<>(System.currentTimeMillis() + 1000 * 60 * 60 * 12, uid)); - completableFuture.complete(playerProfile); - completableFutureMap3.remove(uid); - return; - } catch (IOException e) { - e.printStackTrace(); - } - completableFuture.complete(Optional.empty()); - completableFutureMap3.remove(uid); - }); - completableFutureMap3.put(uid, completableFuture); - - return completableFuture; - } - - private static final Map>> completableFutureMap2 = new ConcurrentHashMap<>(); - - public static CompletableFuture> fetchUUIDAsync(String nickname) { - if (nicknameToUID.containsKey(nickname)) { - CachedData cachedData = nicknameToUID.get(nickname); - if (cachedData.getExpire() > System.currentTimeMillis()) { - return CompletableFuture.completedFuture(Optional.ofNullable(cachedData.getData())); - } - nicknameToUID.remove(nickname); - } - if (completableFutureMap2.containsKey(nickname)) return completableFutureMap2.get(nickname); - - - CompletableFuture> completableFuture = new CompletableFuture<>(); - - ex.submit(() -> { - try { - Optional playerProfile = fetchUUID(nickname); - nicknameToUID.put(nickname, new CachedData(System.currentTimeMillis() + 1000 * 60 * 60 * 12, playerProfile.orElse(null))); - if (playerProfile.isPresent()) - UIDtoNickname.put(playerProfile.orElse(null), new CachedData<>(System.currentTimeMillis() + 1000 * 60 * 60 * 12, nickname)); - - completableFuture.complete(playerProfile); - completableFutureMap2.remove(nickname); - return; - } catch (IOException e) { - e.printStackTrace(); - } - completableFuture.complete(Optional.empty()); - completableFutureMap2.remove(nickname); - }); - completableFutureMap2.put(nickname, completableFuture); - - return completableFuture; - } - - public static Optional fetchUUID(String nickname) throws IOException { - JsonObject json = getJson("https://api.mojang.com/users/profiles/minecraft/" + nickname); - if (json.has("error")) return Optional.empty(); - return Optional.of(TextUtils.insertDashUUID(json.get("id").getAsString())); - } - - public static Optional fetchNickname(String uuid) throws IOException { - try { - JsonArray json = getJsonArr("https://api.mojang.com/user/profiles/" + uuid.replace("-", "") + "/names"); - return Optional.of(json.get(json.size() - 1).getAsJsonObject().get("name").getAsString()); - } catch (Exception e) { - return Optional.empty(); - } - } - - - public static Optional getNumberOfSecretsFromAchievement(String uid, String apiKey) throws IOException { - JsonObject responce = getJson("https://api.hypixel.net/player?uuid=" + uid + "&key=" + apiKey); - if (responce.has("player")) { - JsonObject treasures = responce.getAsJsonObject("player"); - if (treasures.has("achievements")) { - treasures = treasures.getAsJsonObject("achievements"); - if (treasures.has("skyblock_treasure_hunter")) { - return Optional.of(treasures.get("skyblock_treasure_hunter").getAsInt()); - } - } - } - return Optional.empty(); - } - - - public static int getArrayIndex(Object[] arr,Object value) { - int k=0; - for(int i=0;i fetchPlayerProfiles(String uid, String apiKey) throws IOException { - System.out.println("Featching player profiles"); - JsonObject json = getJson("https://api.hypixel.net/skyblock/profiles?uuid=" + uid + "&key=" + apiKey); - if (!json.get("success").getAsBoolean()) return Optional.empty(); - System.out.println("Downloaded data from api"); - JsonArray profiles = json.getAsJsonArray("profiles"); - String dashTrimmed = uid.replace("-", ""); - - - PlayerSkyblockData pp = new PlayerSkyblockData(); - ArrayList playerProfiles = new ArrayList<>(); - System.out.println("Saving and parsing data"); - float lastSave = Long.MIN_VALUE; - PlayerProfile lastest = null; - for (JsonElement jsonElement : profiles) { - JsonObject semiProfile = jsonElement.getAsJsonObject(); - if (!semiProfile.get("members").getAsJsonObject().has(dashTrimmed)) { - System.out.println("Profile does not appear to have the player???"); - continue; - } - - System.out.println("Parsing profile"); - PlayerProfile e = PlayerProfileParser.parseProfile(semiProfile, dashTrimmed); - - System.out.println("Finished Parsing Profile"); - - - System.out.println("Getting nm of secrets from achivment"); - getNumberOfSecretsFromAchievement(uid, apiKey).ifPresent(e::setTotalSecrets); - System.out.println("finished getting secrets from achivment"); - - - System.out.println("Gettign last save"); - JsonElement last_save = semiProfile.get("last_save"); - if(last_save != null){ - float lastSave2 = last_save.getAsLong(); - if (lastSave2 > lastSave) { - lastest = e; - lastSave = lastSave2; - } - } - System.out.println("Finished getting last save"); - - playerProfiles.add(e); - } - System.out.println("THE AMMOUT OF PLAYER PROFILES: " + playerProfiles.size()); - PlayerProfile[] p = new PlayerProfile[playerProfiles.size()]; - pp.setLastestprofileArrayIndex(getArrayIndex(p, lastest)); - pp.setPlayerProfiles(playerProfiles.toArray(p)); - return Optional.of(pp); - } - - public static Optional fetchMostRecentProfile(String uid, String apiKey) throws IOException { - JsonObject json = getJson("https://api.hypixel.net/skyblock/profiles?uuid=" + uid + "&key=" + apiKey); - if (!json.get("success").getAsBoolean()) return Optional.empty(); - JsonArray profiles = json.getAsJsonArray("profiles"); - String dashTrimmed = uid.replace("-", ""); - - JsonObject profile = null; - float lastSave = Long.MIN_VALUE; - for (JsonElement jsonElement : profiles) { - JsonObject semiProfile = jsonElement.getAsJsonObject(); - if (!semiProfile.getAsJsonObject("members").has(dashTrimmed)) { - continue; - } - JsonElement last_save = semiProfile.get("last_save"); - - JsonElement cute_name = semiProfile.get("cute_name"); - if (cute_name != null) { - System.out.println(cute_name.getAsString()); - } else { - System.out.println("THIS SHOULD NOT HAPPEN"); - } - - if (last_save == null) { - return Optional.empty(); - } - float lastSave2 = last_save.getAsLong(); - if (lastSave2 > lastSave) { - - profile = semiProfile; - lastSave = lastSave2; - } - } - - - if (profile == null) { - return Optional.empty(); - } - - PlayerProfile pp = PlayerProfileParser.parseProfile(profile, dashTrimmed); - - getNumberOfSecretsFromAchievement(uid, apiKey).ifPresent(pp::setTotalSecrets); - - return Optional.of(pp); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/CachedData.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/CachedData.java deleted file mode 100644 index e3a98eaa..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/CachedData.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class CachedData { - private final long expire; - private final T data; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/PlayerSkyblockData.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/PlayerSkyblockData.java deleted file mode 100644 index 72b28e61..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/PlayerSkyblockData.java +++ /dev/null @@ -1,10 +0,0 @@ -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import lombok.Data; - -@Data -public class PlayerSkyblockData { - PlayerProfile[] playerProfiles; - int lastestprofileArrayIndex; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/SkinFetcher.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/SkinFetcher.java deleted file mode 100644 index 5d9afa4a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/SkinFetcher.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.client.resources.SkinManager; -import net.minecraft.util.ResourceLocation; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; - -public class SkinFetcher { - - private SkinFetcher(){} - - private static final Map> skinSetMap = new ConcurrentHashMap<>(); - - private static final Map> currentReq = new HashMap<>(); - - public static CompletableFuture getSkinSet(GameProfile gameProfile) { - if (gameProfile == null) { - return CompletableFuture.completedFuture(new SkinSet(DefaultPlayerSkin.getDefaultSkinLegacy(), null, "default")); - } - if (skinSetMap.containsKey(gameProfile.getId().toString())) { - CachedData ss = skinSetMap.get(gameProfile.getId().toString()); - if (ss.getExpire() > System.currentTimeMillis()) - CompletableFuture.completedFuture(skinSetMap.get(gameProfile.getId().toString()).getData()); - skinSetMap.remove(gameProfile.getId().toString()); - } - if (currentReq.containsKey(gameProfile.getId().toString())) - return currentReq.get(gameProfile.getId().toString()); - - SkinSet skinSet = new SkinSet(); - CompletableFuture skinSet2 = new CompletableFuture<>(); - currentReq.put(gameProfile.getId().toString(), skinSet2); - Minecraft.getMinecraft().getSkinManager().loadProfileTextures(gameProfile, new SkinManager.SkinAvailableCallback() { - public void skinAvailable(MinecraftProfileTexture.Type p_180521_1_, ResourceLocation location, MinecraftProfileTexture profileTexture) { - switch (p_180521_1_) { - case SKIN: - skinSet.setSkinLoc(location); - skinSet.setSkinType(profileTexture.getMetadata("model")); - if (skinSet.getSkinType() == null) { - skinSet.setSkinType("default"); - } - skinSet2.complete(skinSet); - skinSetMap.put(gameProfile.getId().toString(), new CachedData<>(System.currentTimeMillis() + 1000*60*60*3, skinSet)); - currentReq.get(gameProfile.getId().toString()); - break; - case CAPE: - skinSet.setCapeLoc(location); - } - } - }, true); - - return skinSet2; - } - - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class SkinSet { - private ResourceLocation skinLoc; - private ResourceLocation capeLoc; - private String skinType; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/PlayerProfile.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/PlayerProfile.java deleted file mode 100644 index 95cd000f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/PlayerProfile.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.*; -import lombok.Data; -import net.minecraft.item.ItemStack; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Data -public class PlayerProfile { - private String profileUID; - private String memberUID; - private String profileName; - - private long lastSave; - - private int fairySouls; - private int fairyExchanges; - - private Armor currentArmor; - private List wardrobe = new ArrayList<>(); - private int selectedWardrobe = -1; - - private ItemStack[] inventory; - private ItemStack[] enderchest; - private ItemStack[] talismans; - - private int totalSecrets; - - @Data - public static class Armor { - private final ItemStack[] armorSlots = new ItemStack[4]; - - public ItemStack getHelmet() { return armorSlots[3]; } - public ItemStack getChestPlate() { return armorSlots[2]; } - public ItemStack getLeggings() { return armorSlots[1]; } - public ItemStack getBoots() { return armorSlots[0]; } - } - - private Map> dungeonStats = new HashMap<>(); - - private Map> playerClassData = new HashMap<>(); - private DungeonClass selectedClass; - @Data - public static class PlayerClassData { - private double experience; - } - - private Map skillXp; - - private List pets = new ArrayList<>(); - - - private Map additionalProperties = new HashMap<>(); - - private LilyWeight lilyWeight; - - @Data - public static class LilyWeight { - private double skill_base; - private double skill_overflow; - private double catacombs_base; - private double catacombs_master; - private double catacombs_exp; - private double slayer; - - public double getTotal() { - return skill_base + skill_overflow + catacombs_base + catacombs_exp + catacombs_master + slayer; - } - } -} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/PlayerProfileParser.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/PlayerProfileParser.java deleted file mode 100644 index b19e1e36..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/PlayerProfileParser.java +++ /dev/null @@ -1,449 +0,0 @@ -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonNull; -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.ApiFetcher; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.*; -import kr.syeyoung.dungeonsguide.utils.XPUtils; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.function.BiFunction; -import java.util.stream.Collectors; - -public class PlayerProfileParser { - - public static volatile JsonObject constants; - - public static JsonObject getLilyWeightConstants() { - if (constants != null) return constants; - try { - JsonObject jsonObject = ApiFetcher.getJson("https://raw.githubusercontent.com/Antonio32A/lilyweight/master/lib/constants.json"); - constants = jsonObject; - } catch (Exception e) { - throw new RuntimeException(e); - } - return constants; - } - - public static int getOrDefault(JsonObject jsonObject, String key, int value) { - if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; - return jsonObject.get(key).getAsInt(); - } - - public static long getOrDefault(JsonObject jsonObject, String key, long value) { - if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; - return jsonObject.get(key).getAsLong(); - } - - public static double getOrDefault(JsonObject jsonObject, String key, double value) { - if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; - return jsonObject.get(key).getAsDouble(); - } - - public static String getOrDefault(JsonObject jsonObject, String key, String value) { - if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; - return jsonObject.get(key).getAsString(); - } - - public static Double getOrDefaultNullable(JsonObject jsonObject, String key, Double value) { - if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; - return jsonObject.get(key).getAsDouble(); - } - - public static NBTTagCompound parseBase64NBT(String nbt) throws IOException { - return CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(nbt))); - } - - public static ItemStack deserializeNBT(NBTTagCompound nbtTagCompound) { - if (nbtTagCompound.hasNoTags()) return null; - ItemStack itemStack = new ItemStack(Blocks.stone); - itemStack.deserializeNBT(nbtTagCompound); - return itemStack; - } - - public static PlayerProfile parseProfile(JsonObject profile, String dashTrimmed) throws IOException { - PlayerProfile playerProfile = new PlayerProfile(); - playerProfile.setProfileUID(getOrDefault(profile, "profile_id", "")); - playerProfile.setMemberUID(dashTrimmed); - playerProfile.setProfileName(getOrDefault(profile, "cute_name", "")); - - JsonObject playerData = profile.getAsJsonObject("members").getAsJsonObject(dashTrimmed); - playerProfile.setLastSave(getOrDefault(playerData, "last_save", 0L)); - playerProfile.setFairySouls(getOrDefault(playerData, "fairy_souls_collected", 0)); - playerProfile.setFairyExchanges(getOrDefault(playerData, "fairy_exchanges", 0)); - - if (playerData.has("inv_armor")) { - playerProfile.setCurrentArmor(new PlayerProfile.Armor()); - NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("inv_armor") - .get("data") - .getAsString()); - NBTTagList array = armor.getTagList("i", 10); - for (int i = 0; i < 4; i++) { - NBTTagCompound item = array.getCompoundTagAt(i); - playerProfile.getCurrentArmor().getArmorSlots()[i] = deserializeNBT(item); - } - } - - if (playerData.has("wardrobe_contents")) { - NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("wardrobe_contents").get("data").getAsString()); - NBTTagList array = armor.getTagList("i", 10); - for (int i = 0; i < array.tagCount(); i++) { - if (i % 4 == 0) playerProfile.getWardrobe().add(new PlayerProfile.Armor()); - NBTTagCompound item = array.getCompoundTagAt(i); - playerProfile.getWardrobe().get(i / 4).getArmorSlots()[i % 4] = deserializeNBT(item); - } - - } - playerProfile.setSelectedWardrobe(getOrDefault(playerData, "wardrobe_equipped_slot", -1)); - - if (playerData.has("inv_contents")) { - NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("inv_contents").get("data").getAsString()); - NBTTagList array = armor.getTagList("i", 10); - playerProfile.setInventory(new ItemStack[array.tagCount()]); - for (int i = 0; i < array.tagCount(); i++) { - NBTTagCompound item = array.getCompoundTagAt(i); - playerProfile.getInventory()[i] = deserializeNBT(item); - } - } - if (playerData.has("ender_chest_contents")) { - NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("ender_chest_contents").get("data").getAsString()); - NBTTagList array = armor.getTagList("i", 10); - playerProfile.setEnderchest(new ItemStack[array.tagCount()]); - for (int i = 0; i < array.tagCount(); i++) { - NBTTagCompound item = array.getCompoundTagAt(i); - playerProfile.getEnderchest()[i] = deserializeNBT(item); - } - } - if (playerData.has("talisman_bag")) { - NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("talisman_bag").get("data").getAsString()); - NBTTagList array = armor.getTagList("i", 10); - playerProfile.setTalismans(new ItemStack[array.tagCount()]); - for (int i = 0; i < array.tagCount(); i++) { - NBTTagCompound item = array.getCompoundTagAt(i); - playerProfile.getTalismans()[i] = deserializeNBT(item); - } - } - - playerProfile.setSkillXp(new HashMap<>()); - for (Skill value : Skill.values()) { - playerProfile.getSkillXp().put(value, getOrDefaultNullable(playerData, "experience_skill_" + value.getJsonName(), null)); - } - - if (playerData.has("pets")) { - for (JsonElement pets : playerData.getAsJsonArray("pets")) { - JsonObject pet = pets.getAsJsonObject(); - Pet petObj = new Pet(); - petObj.setActive(pet.get("active").getAsBoolean()); - petObj.setExp(getOrDefault(pet, "exp", 0.0)); - petObj.setHeldItem(getOrDefault(pet, "heldItem", null)); - petObj.setSkin(getOrDefault(pet, "skin", null)); - petObj.setType(getOrDefault(pet, "type", null)); - petObj.setUuid(getOrDefault(pet, "uuid", null)); - - playerProfile.getPets().add(petObj); - } - } - - if (playerData.has("dungeons") && playerData.getAsJsonObject("dungeons").has("dungeon_types")) { - JsonObject types = playerData.getAsJsonObject("dungeons") - .getAsJsonObject("dungeon_types"); - for (DungeonType value : DungeonType.values()) { - DungeonStat dungeonStat = new DungeonStat(); - DungeonSpecificData dungeonSpecificData = new DungeonSpecificData<>(value, dungeonStat); - playerProfile.getDungeonStats().put(value, dungeonSpecificData); - - if (!types.has(value.getJsonName())) continue; - - JsonObject dungeonObj = types.getAsJsonObject(value.getJsonName()); - - dungeonStat.setHighestCompleted(getOrDefault(dungeonObj, "highest_tier_completed", -1)); - - for (Integer validFloor : value.getValidFloors()) { - DungeonStat.PlayedFloor playedFloor = new DungeonStat.PlayedFloor(); - playedFloor.setBestScore(getOrDefault(dungeonObj.getAsJsonObject("best_score"), "" + validFloor, 0)); - playedFloor.setCompletions(getOrDefault(dungeonObj.getAsJsonObject("tier_completions"), "" + validFloor, 0)); - playedFloor.setFastestTime(getOrDefault(dungeonObj.getAsJsonObject("fastest_time"), "" + validFloor, -1)); - playedFloor.setFastestTimeS(getOrDefault(dungeonObj.getAsJsonObject("fastest_time_s"), "" + validFloor, -1)); - playedFloor.setFastestTimeSPlus(getOrDefault(dungeonObj.getAsJsonObject("fastest_time_s_plus"), "" + validFloor, -1)); - playedFloor.setMobsKilled(getOrDefault(dungeonObj.getAsJsonObject("mobs_killed"), "" + validFloor, 0)); - playedFloor.setMostMobsKilled(getOrDefault(dungeonObj.getAsJsonObject("most_mobs_killed"), "" + validFloor, 0)); - playedFloor.setMostHealing(getOrDefault(dungeonObj.getAsJsonObject("most_healing"), "" + validFloor, 0)); - playedFloor.setTimes_played(getOrDefault(dungeonObj.getAsJsonObject("times_played"), "" + validFloor, 0)); - playedFloor.setWatcherKills(getOrDefault(dungeonObj.getAsJsonObject("watcher_kills"), "" + validFloor, 0)); - - for (DungeonClass dungeonClass : DungeonClass.values()) { - DungeonStat.PlayedFloor.ClassStatistics classStatistics = new DungeonStat.PlayedFloor.ClassStatistics(); - classStatistics.setMostDamage(getOrDefault(dungeonObj.getAsJsonObject("most_damage_" + dungeonClass.getJsonName()), "" + validFloor, 0)); - ClassSpecificData classStatisticsClassSpecificData = new ClassSpecificData<>(dungeonClass, classStatistics); - - playedFloor.getClassStatistics().put(dungeonClass, classStatisticsClassSpecificData); - } - - FloorSpecificData playedFloorFloorSpecificData = new FloorSpecificData<>(validFloor, playedFloor); - dungeonStat.getPlays().put(validFloor, playedFloorFloorSpecificData); - } - - dungeonStat.setExperience(getOrDefault(dungeonObj, "experience", 0)); - - - } - } - if (playerData.has("dungeons") && playerData.getAsJsonObject("dungeons").has("player_classes")) { - JsonObject classes = playerData.getAsJsonObject("dungeons") - .getAsJsonObject("player_classes"); - for (DungeonClass dungeonClass : DungeonClass.values()) { - PlayerProfile.PlayerClassData classStatistics = new PlayerProfile.PlayerClassData(); - classStatistics.setExperience(getOrDefault(classes.getAsJsonObject(dungeonClass.getJsonName()), "experience", 0)); - ClassSpecificData classStatisticsClassSpecificData = new ClassSpecificData<>(dungeonClass, classStatistics); - - playerProfile.getPlayerClassData().put(dungeonClass, classStatisticsClassSpecificData); - } - } - if (playerData.has("dungeons")) { - String id = getOrDefault(playerData.getAsJsonObject("dungeons"), "selected_dungeon_class", null); - DungeonClass dungeonClass = DungeonClass.getClassByJsonName(id); - playerProfile.setSelectedClass(dungeonClass); - } - try { - calculateLilyWeight(playerProfile, playerData); - } catch (Exception e) { - e.printStackTrace(); - } - return playerProfile; - } - - private static void calculateLilyWeight(PlayerProfile playerProfile, JsonObject playerData) throws ExecutionException, InterruptedException { - JsonObject constants = getLilyWeightConstants(); - double[] slayerXP = new double[4]; - if (playerData.has("slayer_bosses")) { - slayerXP[0] = getOrDefault(playerData.getAsJsonObject("slayer_bosses").getAsJsonObject("zombie"), "xp", 0); - slayerXP[1] = getOrDefault(playerData.getAsJsonObject("slayer_bosses").getAsJsonObject("spider"), "xp", 0); - slayerXP[2] = getOrDefault(playerData.getAsJsonObject("slayer_bosses").getAsJsonObject("wolf"), "xp", 0); - slayerXP[3] = getOrDefault(playerData.getAsJsonObject("slayer_bosses").getAsJsonObject("enderman"), "xp", 0); - } - double skillWeight = 0; - double overflowWeight = 0; - { - JsonObject srw = constants.getAsJsonObject("skillRatioWeight"); - int skillMaxXP = constants.get("skillMaxXP").getAsInt(); - JsonArray overflowMultiplier = constants.getAsJsonArray("skillOverflowMultipliers"); - JsonArray skillFactor = constants.getAsJsonArray("skillFactors"); - - double skillAvg = playerProfile.getSkillXp().entrySet().stream() - .filter(a -> a.getValue() != null) - .filter(a -> srw.has(a.getKey().getJsonName())) - .map(a -> XPUtils.getSkillXp(a.getKey(), a.getValue()).getLevel()).collect(Collectors.averagingInt(a -> a)); - - double n = 12 * (skillAvg / 60) * (skillAvg / 60); - double r2 = Math.sqrt(2); - - for (Map.Entry skillDoubleEntry : playerProfile.getSkillXp().entrySet()) { - String jsonName = skillDoubleEntry.getKey().getJsonName(); - JsonArray temp_srw = srw.getAsJsonArray(jsonName); - if (temp_srw == null) continue; - int lv = XPUtils.getSkillXp(skillDoubleEntry.getKey(), skillDoubleEntry.getValue()).getLevel(); - skillWeight += n * temp_srw.get(lv).getAsDouble() - * temp_srw.get(temp_srw.size() - 1).getAsDouble(); - skillWeight += temp_srw.get(temp_srw.size() - 1).getAsDouble() * Math.pow(lv / 60.0, r2); - } - - int cnt = 0; - for (Map.Entry skillNames : constants.getAsJsonObject("skillNames").entrySet()) { - Skill s = getSkillByLilyName(skillNames.getKey()); - double factor = skillFactor.get(cnt).getAsDouble(); - double effectiveOver; - Double xp = playerProfile.getSkillXp().get(s); - if (xp == null) continue; - xp -= skillMaxXP; - { - if (xp < skillMaxXP) effectiveOver = xp; - else { - double remainingXP = xp; - double z = 0; - for (int i = 0; i <= xp / skillMaxXP; i++) { - if (remainingXP >= skillMaxXP) { - remainingXP -= skillMaxXP; - z += Math.pow(factor, i); - } - } - effectiveOver = z * skillMaxXP; - } - } - double rating = effectiveOver / skillMaxXP; - double overflowMult = overflowMultiplier.get(cnt).getAsDouble(); - double t = rating * overflowMult; - if (t > 0) overflowWeight += t; - cnt++; - } - } - double cataCompWeight, masterCompWeight; - { - JsonArray completionFactor = constants.getAsJsonArray("dungeonCompletionWorth"); - JsonObject dungeonCompletionBuffs = constants.getAsJsonObject("dungeonCompletionBuffs"); - double max1000 = 0; - double mMax1000 = 0; - for (int i = 0; i < completionFactor.size(); i++) { - if (i < 8) max1000 += completionFactor.get(i).getAsDouble(); - else mMax1000 += completionFactor.get(i).getAsDouble(); - } - - max1000 *= 1000; - mMax1000 *= 1000; - - double upperBound = 1500; - double score = 0; - - DungeonStat dStat = playerProfile.getDungeonStats().get(DungeonType.CATACOMBS).getData(); - for (FloorSpecificData value : dStat.getPlays().values()) { - int runs = value.getData().getCompletions(); - int excess = 0; - if (runs > 1000) { - excess = runs - 1000; - runs = 1000; - } - - double floorScore = runs * completionFactor.get(value.getFloor()).getAsDouble(); - if (excess > 0) - floorScore *= Math.log10(excess / 1000.0 + 1) / Math.log10(7.5) + 1; - score += floorScore; - } - cataCompWeight = (score / max1000 * upperBound); - - dStat = playerProfile.getDungeonStats().get(DungeonType.MASTER_CATACOMBS).getData(); - for (FloorSpecificData value : dStat.getPlays().values()) { - if (dungeonCompletionBuffs.has(value.getFloor() + "")) { - double threshold = 20; - if (value.getData().getCompletions() >= threshold) - upperBound += dungeonCompletionBuffs.get(value.getFloor() + "").getAsDouble(); - else - upperBound += dungeonCompletionBuffs.get(value.getFloor() + "").getAsDouble() * Math.pow(value.getData().getCompletions() / threshold, 1.840896416); - } - } - score = 0; - for (FloorSpecificData value : dStat.getPlays().values()) { - int runs = value.getData().getCompletions(); - int excess = 0; - if (runs > 1000) { - excess = runs - 1000; - runs = 1000; - } - - double floorScore = runs * completionFactor.get(value.getFloor() + 7).getAsDouble(); - if (excess > 0) - floorScore *= Math.log10(excess / 1000.0 + 1) / Math.log10(5) + 1; - score += floorScore; - } - - masterCompWeight = score / mMax1000 * upperBound; - } - double dungeonXPWeight = 0; - { - double dungeonOverall = constants.get("dungeonOverall").getAsDouble(); - double dungeonMaxXP = constants.get("dungeonMaxXP").getAsDouble(); - - double cataXP = playerProfile.getDungeonStats().get(DungeonType.CATACOMBS).getData().getExperience(); - XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(cataXP); - double level = xpCalcResult.getLevel(); - if (xpCalcResult.getLevel() != 50) { - double progress = Math.floor(xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp() * 1000) / 1000.0; - level += progress; - } - - double n; - double tempLevel = 0; - if (cataXP < dungeonMaxXP) - n = 0.2 * Math.pow(level / 50.0, 2.967355422); - else { - double part = 142452410; - tempLevel = 50 + (cataXP - dungeonMaxXP) / part; - n = 0.2 * Math.pow(1 + ((tempLevel - 50) / 50), 2.967355422); - } - if (level != 0) { - if (cataXP < 569809640) - dungeonXPWeight = dungeonOverall * (Math.pow(1.18340401286164044, (level + 1)) - 1.05994990217254) * (1 + n); - else dungeonXPWeight = 4000 * (n / 0.15465244570598540); - } else dungeonXPWeight = 0; - } - double slayerWeight = 0; - { - JsonArray slayerDeprecationScaling = constants.getAsJsonArray("slayerDeprecationScaling"); - BiFunction getSlayerWeight = (xp, type) -> { - double score = 0; - { - double d = xp / 100000; - if (xp >= 6416) { - double D = (d - Math.pow(3, (-5 / 2.0))) * (d + Math.pow(3, -5 / 2.0)); - double u = Math.cbrt(3 * (d + Math.sqrt(D))); - double v = Math.cbrt(3 * (d - Math.sqrt(D))); - score = u + v - 1; - } else { - score = Math.sqrt(4 / 3.0) * Math.cos(Math.acos(d * Math.pow(3, 5 / 2.0)) / 3) - 1; - } - } - score = Math.floor(score); - double scaling = slayerDeprecationScaling.get(type).getAsDouble(); - double effectiveXP = 0; - for (int i = 1; i <= score; i++) - effectiveXP += (i * i + i) * Math.pow(scaling, i); - effectiveXP = Math.round((1000000 * effectiveXP * (0.05 / scaling)) * 100) / 100.0; - double actualXP = ((score * score * score / 6) + (score * score / 2) + (score / 3)) * 100000; - double distance = xp - actualXP; - double effectiveDistance = distance * Math.pow(scaling, score); - return effectiveXP + effectiveDistance; - }; - - double zombie = getSlayerWeight.apply(slayerXP[0], 0); - double spider = getSlayerWeight.apply(slayerXP[1], 1); - double wolf = getSlayerWeight.apply(slayerXP[2], 2); - double enderman = getSlayerWeight.apply(slayerXP[3], 3); - double individual = zombie / 7000 + spider / 4800 + wolf / 2200 + enderman / 1000; - double extra = (slayerXP[0] + 1.6 * slayerXP[1] + 3.6 * slayerXP[2] + 10 * slayerXP[3]) / 900000; - slayerWeight = (individual + extra); - } - - PlayerProfile.LilyWeight lilyWeight = new PlayerProfile.LilyWeight(); - lilyWeight.setCatacombs_base(cataCompWeight); - lilyWeight.setCatacombs_master(masterCompWeight); - lilyWeight.setCatacombs_exp(dungeonXPWeight); - lilyWeight.setSkill_base(skillWeight); - lilyWeight.setSkill_overflow(overflowWeight); - lilyWeight.setSlayer(slayerWeight); - - playerProfile.setLilyWeight(lilyWeight); - } - - private static Skill getSkillByLilyName(String lilyName) { - switch (lilyName) { - case "experience_skill_enchanting": - return Skill.ENCHANTING; - case "experience_skill_taming": - return Skill.TAMING; - case "experience_skill_alchemy": - return Skill.ALCHEMY; - case "experience_skill_mining": - return Skill.MINING; - case "experience_skill_farming": - return Skill.FARMING; - case "experience_skill_foraging": - return Skill.FORAGING; - case "experience_skill_combat": - return Skill.COMBAT; - case "experience_skill_fishing": - return Skill.FISHING; - default: - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/ClassSpecificData.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/ClassSpecificData.java deleted file mode 100644 index 3496f3a9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/ClassSpecificData.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@AllArgsConstructor -@Getter -public class ClassSpecificData { - private final DungeonClass dungeonClass; - private final T data; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonClass.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonClass.java deleted file mode 100644 index fc569b57..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonClass.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -@Getter -@AllArgsConstructor -public enum DungeonClass { - MAGE("mage", "Mage"), ARCHER("archer","Archer"), HEALER("healer", "Healer"), TANK("tank", "Tank"), BERSERK("berserk", "Berserk"); - - - private final String jsonName; - private final String familarName; - private static final Map jsonNameToClazz = new HashMap<>(); - static { - for (DungeonClass value : values()) { - jsonNameToClazz.put(value.getJsonName(), value); - } - } - - public static DungeonClass getClassByJsonName(String name) { - return jsonNameToClazz.get(name); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonSpecificData.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonSpecificData.java deleted file mode 100644 index 05975767..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonSpecificData.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class DungeonSpecificData { - private final DungeonType type; - private final T data; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonStat.java deleted file mode 100644 index be42a509..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonStat.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses; - -import lombok.Data; - -import java.util.HashMap; -import java.util.Map; - -@Data -public class DungeonStat { - private int highestCompleted; - private double experience; - - private Map> plays = new HashMap<>(); - @Data - public static class PlayedFloor { - private int times_played; - private int completions; - private int watcherKills; - - private int fastestTime; - private int fastestTimeS; - private int fastestTimeSPlus; - private int bestScore; - - private int mostMobsKilled; - private int mobsKilled; - - private Map> classStatistics = new HashMap<>(); - @Data - public static class ClassStatistics { - private double mostDamage; - } - - private double mostHealing; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonType.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonType.java deleted file mode 100644 index a394214d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses; - -import com.google.common.collect.Sets; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Set; - -@Getter -@AllArgsConstructor -public enum DungeonType { - CATACOMBS("catacombs", "The Catacombs", - Sets.newHashSet(0,1,2,3,4,5,6,7)), - MASTER_CATACOMBS("master_catacombs", "MasterMode Catacombs", Sets.newHashSet( - 1,2,3,4,5,6 - )); - - private final String jsonName; - private final String familiarName; - private final Set validFloors ; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/FloorSpecificData.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/FloorSpecificData.java deleted file mode 100644 index e31d5034..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/FloorSpecificData.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class FloorSpecificData { - private final int floor; - private final T data; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/Pet.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/Pet.java deleted file mode 100644 index 40f15e49..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/Pet.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses; - -import lombok.Data; - -@Data -public class Pet { - private String uuid; - private String type; - private double exp; - private boolean active; - private String heldItem; - private String skin; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/Skill.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/Skill.java deleted file mode 100644 index 4ccc1e2d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/api/playerprofile/dataclasses/Skill.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum Skill { - RUNECRAFTING("runecrafting", "Runecrafting"), COMBAT("combat", "Combat"), MINING("mining", "Mining"), ALCHEMY("alchemy", "Alchemy"), FARMING("farming", "Farming"), TAMING("taming", "Taming"), ENCHANTING("enchanting", "Enchanting"), FISHING("fishing", "Fishing"), FORAGING("foraging", "Foraging"), CARPENTRY("carpentry", "Carpentry"); - - private final String jsonName; - private final String friendlyName; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/DataRendererEditor.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/DataRendererEditor.java deleted file mode 100644 index 02ab6ea1..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/DataRendererEditor.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerStatsOnJoin; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class DataRendererEditor extends MPanel { - private final FeatureViewPlayerStatsOnJoin feature; - - public DataRendererEditor(FeatureViewPlayerStatsOnJoin featureViewPlayerStatsOnJoin) { - this.feature = featureViewPlayerStatsOnJoin; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10, 260)); - } - - private String currentlySelected; - private int selectedX; - private int selectedY; - private int lastX; - private int lastY; - private int scrollY; - private final int baseWidth = 120; - private final int hamburgerWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth("=="); - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f)); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Available", (310 + baseWidth + hamburgerWidth -fr.getStringWidth("Available")) / 2, 4, 0xFFFFFFFF); - fr.drawString("Current", (baseWidth + hamburgerWidth+10 -fr.getStringWidth("Current")) /2 , 4, 0xFFFFFFFF); - Gui.drawRect(4,4 + fr.FONT_HEIGHT + 3,baseWidth + hamburgerWidth+6 + 1, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); - Gui.drawRect(5,5+ fr.FONT_HEIGHT + 3,baseWidth + hamburgerWidth + 5 + 1, 235+ fr.FONT_HEIGHT + 3, RenderUtils.blendAlpha(0x141414, 0.15f)); - Gui.drawRect(5 + hamburgerWidth,4+ fr.FONT_HEIGHT + 3,6 + hamburgerWidth, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); - - Gui.drawRect(154,4 + fr.FONT_HEIGHT + 3,150 + baseWidth + hamburgerWidth + 6+1, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); - Gui.drawRect(155,5+ fr.FONT_HEIGHT + 3,150 + baseWidth + hamburgerWidth + 5+1, 235+ fr.FONT_HEIGHT + 3, RenderUtils.blendAlpha(0x141414, 0.15f)); - Gui.drawRect(155 + hamburgerWidth,4 + fr.FONT_HEIGHT + 3,156 + hamburgerWidth, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); - - GlStateManager.pushMatrix(); - clip(scissor.x + 6+hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); - GlStateManager.translate(6+hamburgerWidth, 5+fr.FONT_HEIGHT+3, 0); - int culmutativeY = 0; - int relSelectedY = selectedY - (5+ fr.FONT_HEIGHT + 3); - boolean drewit = false; - for (String datarenderers : feature.>getParameter("datarenderers").getValue()) { - - if (0 <= selectedX && selectedX <= hamburgerWidth+11 && currentlySelected != null) { - IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); - Dimension dim; - if (dataRenderer == null) dim = new Dimension(0,fr.FONT_HEIGHT*2); - else dim = dataRenderer.getDimension(); - - if (culmutativeY + dim.height > relSelectedY && relSelectedY >= culmutativeY && !drewit) { - clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (dataRenderer == null) { - fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); - fr.drawString(currentlySelected, 0,fr.FONT_HEIGHT, 0xFFFF0000); - dim = new Dimension(0, fr.FONT_HEIGHT * 2); - } else { - GlStateManager.pushMatrix(); - dim = dataRenderer.renderDummy(); - GlStateManager.popMatrix(); - } - clip(scissor.x, scissor.y, scissor.width, scissor.height); - GlStateManager.translate(-hamburgerWidth-1, 0, 0); - Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFF777777); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - GlStateManager.translate(hamburgerWidth+1,dim.height,0); - drewit = true; - } - } - - IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); - clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); - Dimension dim; - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (dataRenderer == null) { - fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); - fr.drawString(datarenderers, 0,fr.FONT_HEIGHT, 0xFFFF0000); - dim = new Dimension(0, fr.FONT_HEIGHT * 2); - } else { - GlStateManager.pushMatrix(); - dim = dataRenderer.renderDummy(); - GlStateManager.popMatrix(); - } - clip(scissor.x, scissor.y, scissor.width, scissor.height); - GlStateManager.translate(-hamburgerWidth-1, 0, 0); - Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - GlStateManager.translate(hamburgerWidth+1,dim.height,0); - - culmutativeY += dim.height; - } - - if (currentlySelected != null && new Rectangle(0,5+fr.FONT_HEIGHT + 3, hamburgerWidth+11, 232).contains(selectedX, selectedY) && !drewit) { - IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); - Dimension dim; - clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (dataRenderer == null) { - fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); - fr.drawString(currentlySelected, 0,fr.FONT_HEIGHT, 0xFFFF0000); - dim = new Dimension(0, fr.FONT_HEIGHT * 2); - } else { - GlStateManager.pushMatrix(); - dim = dataRenderer.renderDummy(); - GlStateManager.popMatrix(); - } - clip(scissor.x, scissor.y, scissor.width, scissor.height); - GlStateManager.translate(-hamburgerWidth-1, 0, 0); - Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFF777777); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - GlStateManager.translate(hamburgerWidth+1,dim.height,0); - } - GlStateManager.popMatrix(); - - - GlStateManager.pushMatrix(); - GlStateManager.translate(156+hamburgerWidth, 5+fr.FONT_HEIGHT+3 - scrollY, 0); - - Set rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); - rest.removeAll( feature.>getParameter("datarenderers").getValue()); - rest.remove(currentlySelected); - for (String datarenderers : rest) { - IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); - clip(scissor.x + 156 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); - Dimension dim; - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (dataRenderer == null) { - fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); - fr.drawString(datarenderers, 0,fr.FONT_HEIGHT, 0xFFFF0000); - dim = new Dimension(0, fr.FONT_HEIGHT * 2); - } else { - GlStateManager.pushMatrix(); - dim = dataRenderer.renderDummy(); - GlStateManager.popMatrix(); - } - clip(scissor.x + 155, scissor.y + 5+fr.FONT_HEIGHT+3, hamburgerWidth, 230); - GlStateManager.translate(-hamburgerWidth-1, 0, 0); - Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - GlStateManager.translate(hamburgerWidth+1,dim.height,0); - } - GlStateManager.popMatrix(); - clip(0,0,sr.getScaledWidth(), sr.getScaledHeight()); - { - if (currentlySelected != null) { - GlStateManager.pushMatrix(); - GlStateManager.translate(selectedX+hamburgerWidth+1, selectedY, 0); - IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); - Dimension dim; - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (dataRenderer == null) { - fr.drawString("Couldn't find Datarenderer", 0, 0, 0xFFFF0000); - fr.drawString(currentlySelected, 0, fr.FONT_HEIGHT, 0xFFFF0000); - dim = new Dimension(0, fr.FONT_HEIGHT * 2); - } else { - GlStateManager.pushMatrix(); - dim = dataRenderer.renderDummy(); - GlStateManager.popMatrix(); - } - GlStateManager.translate(-hamburgerWidth-1, 0, 0); - Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - GlStateManager.popMatrix(); - } - } - clip(scissor.x, scissor.y, scissor.width, scissor.height); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - super.mouseClicked(absMouseX, absMouseY, relMouseX, relMouseY, mouseButton); - lastX = relMouseX; - lastY = relMouseY; - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int legitRelY = relMouseY - (5+fr.FONT_HEIGHT+3); - if (new Rectangle(155,5+fr.FONT_HEIGHT + 3, hamburgerWidth, 230).contains(relMouseX, relMouseY)) { - Set rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); - rest.removeAll( feature.>getParameter("datarenderers").getValue()); - rest.remove(currentlySelected); - int culmutativeY = -scrollY; - for (String datarenderers : rest) { - IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); - Dimension dim; - if (dataRenderer == null) { - dim = new Dimension(0, fr.FONT_HEIGHT * 2); - } else { - GlStateManager.pushMatrix(); - dim = dataRenderer.getDimension(); - GlStateManager.popMatrix(); - } - culmutativeY += dim.height; - - if (legitRelY < culmutativeY) { - currentlySelected = datarenderers; - selectedX = 155; - selectedY = culmutativeY - dim.height + 5+fr.FONT_HEIGHT + 3; - break; - } - } - } - if (new Rectangle(5,5+fr.FONT_HEIGHT + 3, hamburgerWidth, 230).contains(relMouseX, relMouseY)) { - List rest = feature.>getParameter("datarenderers").getValue(); - int culmutativeY = 0; - for (String datarenderers : rest) { - IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); - Dimension dim; - if (dataRenderer == null) { - dim = new Dimension(0, fr.FONT_HEIGHT * 2); - } else { - GlStateManager.pushMatrix(); - dim = dataRenderer.getDimension(); - GlStateManager.popMatrix(); - } - culmutativeY += dim.height; - - if (legitRelY < culmutativeY) { - currentlySelected = datarenderers; - selectedX = 5; - selectedY = culmutativeY - dim.height + 5+fr.FONT_HEIGHT + 3; - rest.remove(datarenderers); - break; - } - } - } - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - super.mouseClickMove(absMouseX, absMouseY, relMouseX, relMouseY, clickedMouseButton, timeSinceLastClick); - if (currentlySelected != null) { - int dx = relMouseX - lastX; - int dy = relMouseY - lastY; - selectedX += dx; - selectedY += dy; - } - lastX = relMouseX; - lastY = relMouseY; - } - - @Override - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - super.mouseReleased(absMouseX, absMouseY, relMouseX, relMouseY, state); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int legitRelY = selectedY - (5+fr.FONT_HEIGHT+3); - if (currentlySelected != null && new Rectangle(0,5+fr.FONT_HEIGHT + 3, hamburgerWidth+11, 232).contains(selectedX, selectedY)) { - Set rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); - int culmutativeY = 0; - List asdasdkasd = feature.>getParameter("datarenderers").getValue(); - int index = asdasdkasd.size(); - for (int i = 0; i 0) scrollY -= 20; - if (scrollY < 0) scrollY = 0; - - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/DataRendererRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/DataRendererRegistry.java deleted file mode 100644 index b2187511..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/DataRendererRegistry.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonClass; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonType; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.Skill; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl.*; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -public class DataRendererRegistry { - private static final Map dataRendererMap = new HashMap<>(); - - public static IDataRenderer getDataRenderer(String id) { - return dataRendererMap.get(id); - } - - public static Set getValidDataRenderer() { - return dataRendererMap.keySet(); - } - - static { - dataRendererMap.put("catalv", new DataRendererDungeonLv(DungeonType.CATACOMBS)); - for (DungeonClass value : DungeonClass.values()) { - dataRendererMap.put("class_"+value.getJsonName()+"_lv", new DataRendererClassLv(value)); - } - dataRendererMap.put("selected_class_lv", new DataRendererSelectedClassLv()); - for (Skill value : Skill.values()) { - dataRendererMap.put("skill_"+value.getJsonName()+"_lv", new DataRendererSkillLv(value)); - } - for (DungeonType value : DungeonType.values()) { - for (Integer validFloor : value.getValidFloors()) { - dataRendererMap.put("dungeon_"+value.getJsonName()+"_"+validFloor+"_stat", new DataRenderDungeonFloorStat(value, validFloor)); - } - dataRendererMap.put("dungeon_"+value.getJsonName()+"_higheststat", new DataRenderDungeonHighestFloorStat(value)); - } - dataRendererMap.put("fairysouls", new DataRendererFairySouls()); - dataRendererMap.put("secrets", new DataRendererSecrets()); - - dataRendererMap.put("dummy", new DataRendererSetUrOwn()); - - dataRendererMap.put("talismans", new DataRendererTalismans()); - dataRendererMap.put("weight", new DataRendererLilyWeight()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/IDataRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/IDataRenderer.java deleted file mode 100644 index 3f2d0ad2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/IDataRenderer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; - -import java.awt.*; - -public interface IDataRenderer { - Dimension renderData(PlayerProfile playerProfile); - void onHover(PlayerProfile playerProfile, int mouseX, int mouseY); - - - Dimension renderDummy(); - - Dimension getDimension(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonFloorStat.java deleted file mode 100644 index f2cf4a38..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonFloorStat.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonSpecificData; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonStat; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonType; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.FloorSpecificData; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.Arrays; - -public class DataRenderDungeonFloorStat implements IDataRenderer { - private final DungeonType dungeonType; - private final int floor; - public DataRenderDungeonFloorStat(DungeonType dungeonType, int floor) { - this.dungeonType = dungeonType; - this.floor = floor; - } - - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; - - boolean flag = false; - DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); - if (dungeonStatDungeonSpecificData != null) { - FloorSpecificData playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(floor); - if (playedFloorFloorSpecificData != null) { - flag = true; - fr.drawString("ยงb" + floorName + " ยงa" + playedFloorFloorSpecificData.getData().getBestScore() + " ยงf" + playedFloorFloorSpecificData.getData().getCompletions() + "ยง7/ยงf" + playedFloorFloorSpecificData.getData().getWatcherKills() + "ยง7/ยงf" + playedFloorFloorSpecificData.getData().getTimes_played() + " ยง7(" + (int) (playedFloorFloorSpecificData.getData().getCompletions()*100 / (double) playedFloorFloorSpecificData.getData().getWatcherKills()) + "%)", 0, 0, -1); - fr.drawString("ยง6S+ ยงe" + (playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "ยง7N/A") + " ยง6S ยงe" + (playedFloorFloorSpecificData.getData().getFastestTimeS() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "ยง7N/A"), 0, fr.FONT_HEIGHT, -1); - } - } - if (!flag) { - fr.drawString("ยงcNo Stat for "+floorName, 0,0,-1); - } - - return getDimension(); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; - - - fr.drawString("ยงb"+floorName+" ยงa305 ยงf10ยง7/ยงf35ยง7/ยงf50 ยง7("+(int)(1000.0/35.0)+"%)", 0,0,-1); - fr.drawString("ยง6S+ ยงe10m 53s ยง6S ยงe15m 13s", 0, fr.FONT_HEIGHT, -1); - return getDimension(); - } - - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - - DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); - if (dungeonStatDungeonSpecificData == null) return; - FloorSpecificData playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(floor); - if (playedFloorFloorSpecificData == null) return; - String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GuiUtils.drawHoveringText(Arrays.asList( - "ยงbFloor "+floorName, - "ยงbBest Scoreยง7: ยงf"+playedFloorFloorSpecificData.getData().getBestScore(), - "ยงbTotal Completionsยง7: ยงf"+playedFloorFloorSpecificData.getData().getCompletions(), - "ยงbTotal Watcher killsยง7: ยงf"+playedFloorFloorSpecificData.getData().getWatcherKills(), - "ยงbTotal Runsยง7: ยงf"+playedFloorFloorSpecificData.getData().getTimes_played(), - "ยงbFastest S+ยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "ยง7N/A"), - "ยงbFastest Sยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTimeS() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "ยง7N/A"), - "ยงbFastest Runยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTime() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTime()) : "ยง7N/A"), - "ยงbMost Mobs Killedยง7: ยงf"+playedFloorFloorSpecificData.getData().getMostMobsKilled(), - "ยงbTotal Mobs Killedยง7: ยงf"+playedFloorFloorSpecificData.getData().getMobsKilled() - ), mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonHighestFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonHighestFloorStat.java deleted file mode 100644 index 8daba7eb..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonHighestFloorStat.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonSpecificData; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonStat; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonType; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.FloorSpecificData; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.Arrays; - -public class DataRenderDungeonHighestFloorStat implements IDataRenderer { - private final DungeonType dungeonType; - public DataRenderDungeonHighestFloorStat(DungeonType dungeonType) { - this.dungeonType = dungeonType; - } - - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - boolean flag = false; - DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); - if (dungeonStatDungeonSpecificData != null) { - if (dungeonStatDungeonSpecificData.getData().getHighestCompleted() != -1) { - FloorSpecificData playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(dungeonStatDungeonSpecificData.getData().getHighestCompleted()); - String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + dungeonStatDungeonSpecificData.getData().getHighestCompleted(); - if (playedFloorFloorSpecificData != null) { - flag = true; - fr.drawString("ยงbH: " + floorName + " ยงa" + playedFloorFloorSpecificData.getData().getBestScore() + " ยงf" + playedFloorFloorSpecificData.getData().getCompletions() + "ยง7/ยงf" + playedFloorFloorSpecificData.getData().getWatcherKills() + "ยง7/ยงf" + playedFloorFloorSpecificData.getData().getTimes_played() + " ยง7(" + (int) (playedFloorFloorSpecificData.getData().getCompletions() *100/ (double) playedFloorFloorSpecificData.getData().getWatcherKills()) + "%)", 0, 0, -1); - fr.drawString("ยง6S+ ยงe" + (playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "ยง7N/A") + " ยง6S ยงe" + (playedFloorFloorSpecificData.getData().getFastestTimeS() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "ยง7N/A"), 0, fr.FONT_HEIGHT, -1); - } - } - } - if (!flag) { - fr.drawString("ยงcNo Highest Floor for ", 0,0,-1); - fr.drawString("ยงc"+dungeonType.getFamiliarName(), 0,fr.FONT_HEIGHT,-1); - } - - return getDimension(); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + "9"; - - - fr.drawString("ยงbH: "+floorName+" ยงa305 ยงf10ยง7/ยงf35ยง7/ยงf50 ยง7("+(int)(1000.0/35.0)+"%)", 0,0,-1); - fr.drawString("ยง6S+ ยงe10m 53s ยง6S ยงe15m 13s", 0, fr.FONT_HEIGHT, -1); - return getDimension(); - } - - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - - DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); - if (dungeonStatDungeonSpecificData == null) return; - if (dungeonStatDungeonSpecificData.getData().getHighestCompleted() == -1) return; - FloorSpecificData playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get( dungeonStatDungeonSpecificData.getData().getHighestCompleted()); - if (playedFloorFloorSpecificData == null) return; - String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + dungeonStatDungeonSpecificData.getData().getHighestCompleted(); - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GuiUtils.drawHoveringText(Arrays.asList( - "ยงbFloor "+floorName, - "ยงbBest Scoreยง7: ยงf"+playedFloorFloorSpecificData.getData().getBestScore(), - "ยงbTotal Completionsยง7: ยงf"+playedFloorFloorSpecificData.getData().getCompletions(), - "ยงbTotal Watcher killsยง7: ยงf"+playedFloorFloorSpecificData.getData().getWatcherKills(), - "ยงbTotal Runsยง7: ยงf"+playedFloorFloorSpecificData.getData().getTimes_played(), - "ยงbFastest S+ยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "ยง7N/A"), - "ยงbFastest Sยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTimeS() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "ยง7N/A"), - "ยงbFastest Runยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTime() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTime()) : "ยง7N/A"), - "ยงbMost Mobs Killedยง7: ยงf"+playedFloorFloorSpecificData.getData().getMostMobsKilled(), - "ยงbTotal Mobs Killedยง7: ยงf"+playedFloorFloorSpecificData.getData().getMobsKilled() - ), mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererClassLv.java deleted file mode 100644 index 8a798eee..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererClassLv.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.ClassSpecificData; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonClass; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.XPUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.Arrays; - -public class DataRendererClassLv implements IDataRenderer { - private final DungeonClass dungeonClass; - public DataRendererClassLv(DungeonClass dungeonClass) { - this.dungeonClass = dungeonClass; - } - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - ClassSpecificData dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(dungeonClass); - boolean selected = playerProfile.getSelectedClass() == dungeonClass; - if (dungeonStatDungeonSpecificData == null) { - fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); - fr.drawString("Unknown", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); - if (selected) - fr.drawString("โ˜…", fr.getStringWidth(dungeonClass.getFamilarName()+" Unknown "),0,0xFFAAAAAA); - } else { - XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); - fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); - fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); - if (selected) - fr.drawString("โ˜…", fr.getStringWidth(dungeonClass.getFamilarName()+" "+xpCalcResult.getLevel()+" "),0,0xFFAAAAAA); - - RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp())); - } - - return new Dimension(100, fr.FONT_HEIGHT*2); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); - fr.drawString("99", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); - fr.drawString("โ˜…", fr.getStringWidth(dungeonClass.getFamilarName()+" 99 "),0,0xFFAAAAAA); - RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); - return new Dimension(100, fr.FONT_HEIGHT*2); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - ClassSpecificData dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(dungeonClass); - if (dungeonStatDungeonSpecificData == null) return; - XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - - GuiUtils.drawHoveringText(Arrays.asList("ยงbCurrent Lvยง7: ยงe"+xpCalcResult.getLevel(),"ยงbExpยง7: ยงe"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "ยง7/ยงe"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "ยงbTotal Xpยง7: ยงe"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, - scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererDungeonLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererDungeonLv.java deleted file mode 100644 index 5cc37fa6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererDungeonLv.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonSpecificData; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonStat; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonType; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.XPUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.Arrays; - -public class DataRendererDungeonLv implements IDataRenderer { - private final DungeonType dungeonType; - public DataRendererDungeonLv(DungeonType dungeonType) { - this.dungeonType = dungeonType; - } - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); - if (dungeonStatDungeonSpecificData == null) { - fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); - fr.drawString("Unknown", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); - } else { - XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); - fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); - fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); - - RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp())); - } - - return new Dimension(100, fr.FONT_HEIGHT*2); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); - fr.drawString("99", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); - RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); - return new Dimension(100, fr.FONT_HEIGHT*2); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); - if (dungeonStatDungeonSpecificData == null) return; - XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GuiUtils.drawHoveringText(Arrays.asList("ยงbCurrent Lvยง7: ยงe"+xpCalcResult.getLevel(),"ยงbExpยง7: ยงe"+TextUtils.format((long)xpCalcResult.getRemainingXp()) + "ยง7/ยงe"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "ยงbTotal Xpยง7: ยงe"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, - scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererFairySouls.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererFairySouls.java deleted file mode 100644 index 5b8f4d8e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererFairySouls.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - -import java.awt.*; - -public class DataRendererFairySouls implements IDataRenderer { - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("ยงeFairy Souls ยงf"+playerProfile.getFairySouls(), 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("ยงeFairy Souls ยงf300", 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererLilyWeight.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererLilyWeight.java deleted file mode 100644 index ef57f955..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererLilyWeight.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.Arrays; - -public class DataRendererLilyWeight implements IDataRenderer { - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - if (playerProfile.getLilyWeight() == null) - fr.drawString("ยงeLily Weight ยงcAPI DISABLED", 0,0,-1); - else - fr.drawString("ยงeLily Weight ยงb"+String.format("%.3f", playerProfile.getLilyWeight().getTotal()), 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("ยงeLily Weight ยงb300", 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - PlayerProfile.LilyWeight lilyWeight= playerProfile.getLilyWeight(); - if (lilyWeight == null) return; - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GuiUtils.drawHoveringText(Arrays.asList( - "ยงbDungeon Weightsยง7: ยงe"+ String.format("%.3f",lilyWeight.getCatacombs_base()+lilyWeight.getCatacombs_master()+lilyWeight.getCatacombs_exp()), - " ยงbCatacomb Completionยง7: ยงe"+String.format("%.3f",lilyWeight.getCatacombs_base()), - " ยงbMaster Completionยง7: ยงe"+String.format("%.3f", lilyWeight.getCatacombs_master()), - " ยงbExperienceยง7: ยงe"+String.format("%.3f", lilyWeight.getCatacombs_exp()), - "ยงbSkill Weightsยง7: ยงe"+ String.format("%.3f", lilyWeight.getSkill_base() + lilyWeight.getSkill_overflow()), - " ยงbSkill Weightยง7: ยงe"+String.format("%.3f", lilyWeight.getSkill_base()), - " ยงbOverflow Weightยง7: ยงe"+String.format("%.3f", lilyWeight.getSkill_overflow()), - "ยงbSlayer Weightยง7: ยงe"+String.format("%.3f", lilyWeight.getSlayer()), - "ยงbTotalยง7: ยงe"+String.format("%.3f", lilyWeight.getTotal()) - ),mouseX, mouseY, - scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSecrets.java deleted file mode 100644 index bacbc598..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSecrets.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - -import java.awt.*; - -public class DataRendererSecrets implements IDataRenderer { - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - double theint = playerProfile.getTotalSecrets()/ (double)playerProfile.getDungeonStats().values().stream().flatMap(s -> s.getData().getPlays().values().stream()) - .map(fs -> fs.getData().getWatcherKills()).reduce(0, Integer::sum); - fr.drawString("ยงeSecrets ยงb"+playerProfile.getTotalSecrets()+" ยง7("+ - String.format("%.2f", theint)+"/run)", 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("ยงeSecrets ยงb99999 ยง7(X/run)", 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSelectedClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSelectedClassLv.java deleted file mode 100644 index d8d3a292..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSelectedClassLv.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.ClassSpecificData; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.XPUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.Arrays; - -public class DataRendererSelectedClassLv implements IDataRenderer { - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - ClassSpecificData dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(playerProfile.getSelectedClass()); - if (dungeonStatDungeonSpecificData == null) { - fr.drawString("Unknown Selected", 0,0, 0xFF55ffff); - } else { - XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); - fr.drawString(playerProfile.getSelectedClass().getFamilarName(), 0,0, 0xFF55ffff); - fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(playerProfile.getSelectedClass().getFamilarName()+" "),0,0xFFFFFFFF); - fr.drawString("โ˜…", fr.getStringWidth(playerProfile.getSelectedClass().getFamilarName()+" "+xpCalcResult.getLevel()+" "),0,0xFFAAAAAA); - - RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp())); - } - - return new Dimension(100, fr.FONT_HEIGHT*2); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("SelectedClass", 0,0, 0xFF55ffff); - fr.drawString("99", fr.getStringWidth("SelectedClass "),0,0xFFFFFFFF); - fr.drawString("โ˜…", fr.getStringWidth("SelectedClass 99 "),0,0xFFAAAAAA); - RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); - return new Dimension(100, fr.FONT_HEIGHT*2); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - ClassSpecificData dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(playerProfile.getSelectedClass()); - if (dungeonStatDungeonSpecificData == null) return; - XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GuiUtils.drawHoveringText(Arrays.asList("ยงbCurrent Lvยง7: ยงe"+xpCalcResult.getLevel(),"ยงbExpยง7: ยงe"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "ยง7/ยงe"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "ยงbTotal Xpยง7: ยงe"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, - scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSetUrOwn.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSetUrOwn.java deleted file mode 100644 index 3d5e94cc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSetUrOwn.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - -import java.awt.*; - -public class DataRendererSetUrOwn implements IDataRenderer { - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("ยงaCustomize at /dg", 0,0,-1); - fr.drawString("ยงa-> Party Kicker", 0,fr.FONT_HEIGHT,-1); - fr.drawString("ยงa-> View Player Stats", 0,fr.FONT_HEIGHT*2,-1); - fr.drawString("ยงa-> Edit", 0,fr.FONT_HEIGHT*3,-1); - return new Dimension(100, fr.FONT_HEIGHT*4); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("ยงaCustomize at /dg", 0,0,-1); - fr.drawString("ยงa-> Party Kicker", 0,fr.FONT_HEIGHT,-1); - fr.drawString("ยงa-> View Player Stats", 0,fr.FONT_HEIGHT*2,-1); - fr.drawString("ยงa-> Edit", 0,fr.FONT_HEIGHT*3,-1); - return new Dimension(100, fr.FONT_HEIGHT*4); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*4); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSkillLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSkillLv.java deleted file mode 100644 index ea83a74e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererSkillLv.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.Skill; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.utils.XPUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.Arrays; - -public class DataRendererSkillLv implements IDataRenderer { - private final Skill skill; - public DataRendererSkillLv(Skill skill) { - this.skill = skill; - } - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - Double xp = playerProfile.getSkillXp().get(skill); - if (xp == null) { - fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); - fr.drawString("ยงcSkill API Disabled", 0, fr.FONT_HEIGHT,0xFFFFFFFF); - } else { - XPUtils.XPCalcResult xpCalcResult = XPUtils.getSkillXp(skill, xp); - fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); - fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(skill.getFriendlyName()+" "),0,0xFFFFFFFF); - - RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp())); - } - - return new Dimension(100, fr.FONT_HEIGHT*2); - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); - fr.drawString("99", fr.getStringWidth(skill.getFriendlyName()+" "),0,0xFFFFFFFF); - RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); - return new Dimension(100, fr.FONT_HEIGHT*2); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - Double xp = playerProfile.getSkillXp().get(skill); - if (xp == null) return; - XPUtils.XPCalcResult xpCalcResult = XPUtils.getSkillXp(skill, xp); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GuiUtils.drawHoveringText(Arrays.asList("ยงbCurrent Lvยง7: ยงe"+xpCalcResult.getLevel(),"ยงbExpยง7: ยงe"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "ยง7/ยงe"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "ยงbTotal Xpยง7: ยงe"+ TextUtils.format(xp.longValue())),mouseX, mouseY, - scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererTalismans.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererTalismans.java deleted file mode 100644 index 9630e2be..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/datarenders/impl/DataRendererTalismans.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.impl; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.datarenders.IDataRenderer; -import lombok.AllArgsConstructor; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -public class DataRendererTalismans implements IDataRenderer { - @Override - public Dimension renderData(PlayerProfile playerProfile) { - boolean apiDisabled = playerProfile.getTalismans() == null || playerProfile.getInventory() == null; - if (!playerProfile.getAdditionalProperties().containsKey("talismanCnt") && !apiDisabled) { - int[] cnts = new int[Rarity.values().length]; - for (ItemStack talisman : playerProfile.getTalismans()) { - if (talisman == null) continue; - Rarity r = getRarity(talisman); - if (r != null) cnts[r.ordinal()]++; - } - for (ItemStack itemStack : playerProfile.getInventory()) { - if (itemStack == null) continue; - Rarity r = getRarity(itemStack); - if (r != null) cnts[r.ordinal()]++; - } - playerProfile.getAdditionalProperties().put("talismanCnt", cnts); - } - int[] rawData = (int[]) playerProfile.getAdditionalProperties().get("talismanCnt"); - - String str = ""; - if (rawData != null) - for (Rarity r : Rarity.values()) { - str = r.color+rawData[r.idx] +" "+ str; - } - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - if (apiDisabled) - fr.drawString("ยงeTalis ยงcAPI DISABLED", 0,0,-1); - else - fr.drawString("ยงeTalis ยงf"+str, 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - - private Rarity getRarity(ItemStack itemStack) { - NBTTagCompound display = itemStack.getTagCompound().getCompoundTag("display"); - if (display == null) return null; - NBTTagList lore = display.getTagList("Lore", 8); - if (lore == null) return null; - for (int i = 0; i < lore.tagCount(); i++) { - String line = lore.getStringTagAt(i); - for (Rarity value : Rarity.values()) { - if (line.startsWith(value.getColor()) && line.contains("CCESSORY")) return value; - } - } - return null; - } - - @Override - public Dimension renderDummy() { - String str = ""; - for (Rarity r : Rarity.values()) { - str = r.color+(r.idx+5)*2+" "+str; - } - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("ยงeTalis ยงf"+str, 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - int[] rawData = (int[]) playerProfile.getAdditionalProperties().get("talismanCnt"); - if (rawData == null) return; - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - List list = new ArrayList<>(); - - for (Rarity r : Rarity.values()) { - list.add(r.getColor()+r.name()+"ยง7: ยงe"+rawData[r.idx]); - } - GuiUtils.drawHoveringText(list,mouseX, mouseY, - scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); - } - - - @AllArgsConstructor @Getter - public static enum Rarity { - COMMON("ยงf", 0), UNCOMMON("ยงa",1), RARE("ยง9",2), EPIC("ยง5",3), LEGENDARY("ยง6",4), MYTHIC("ยงd",5); - - private String color; - private int idx; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java deleted file mode 100644 index 0b9744ea..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.text.StyledText; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.features.text.TextStyle; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class FeatureActions extends TextHUDFeature { - public FeatureActions() { - super("Dungeon Secrets", "Action Viewer", "View List of actions that needs to be taken", "secret.actionview", false, 200, getFontRenderer().FONT_HEIGHT * 10); - - getStyles().add(new TextStyle("pathfinding", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("mechanic", new AColor(0x55, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("state", new AColor(0x55, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("current", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("number", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("dot", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("action", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); - getStyles().add(new TextStyle("afterline", new AColor(0xAA, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - @Override - public boolean doesScaleWithHeight() { - return false; - } - - @Override - public boolean isHUDViewable() { - if (!skyblockStatus.isOnDungeon()) return false; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return false; - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) return false; - return dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor; - } - - private static final List dummyText= new ArrayList(); - static { - dummyText.add(new StyledText("Pathfinding ","pathfinding")); - dummyText.add(new StyledText("Secret ","mechanic")); - dummyText.add(new StyledText("-> ","separator")); - dummyText.add(new StyledText("Found\n","state")); - dummyText.add(new StyledText("> ","current")); - dummyText.add(new StyledText("1","number")); - dummyText.add(new StyledText(". ","dot")); - dummyText.add(new StyledText("Move ","action")); - dummyText.add(new StyledText("OffsetPoint{x=1,y=42,z=1} \n","afterline")); - dummyText.add(new StyledText(" ","current")); - dummyText.add(new StyledText("2","number")); - dummyText.add(new StyledText(". ","dot")); - dummyText.add(new StyledText("Click ","action")); - dummyText.add(new StyledText("OffsetPoint{x=1,y=42,z=1} \n","afterline")); - dummyText.add(new StyledText(" ","current")); - dummyText.add(new StyledText("3","number")); - dummyText.add(new StyledText(". ","dot")); - dummyText.add(new StyledText("Profit ","action")); - } - - @Override - public List getUsedTextStyle() { - return Arrays.asList("pathfinding","mechanic","separator","state","current", "number", "dot", "action", "afterline"); - } - - @Override - public List getDummyText() { - return dummyText; - } - - - @Override - public List getText() { - List actualBit = new ArrayList(); - - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - - for (ActionRoute path : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getPath().values()) { - actualBit.add(new StyledText("Pathfinding ","pathfinding")); - actualBit.add(new StyledText(path.getMechanic()+" ","mechanic")); - actualBit.add(new StyledText("-> ","separator")); - actualBit.add(new StyledText(path.getState()+"\n","state")); - - for (int i = Math.max(0,path.getCurrent()-2); i < path.getActions().size(); i++) { - actualBit.add(new StyledText((i == path.getCurrent() ? ">" : " ") +" ","current")); - actualBit.add(new StyledText(i+"","number")); - actualBit.add(new StyledText(". ","dot")); - Action action = path.getActions().get(i); - String[] str = action.toString().split("\n"); - actualBit.add(new StyledText(str[0] + " ","action")); - actualBit.add(new StyledText("(","afterline")); - for (int i1 = 1; i1 < str.length; i1++) { - String base = str[i1].trim(); - if (base.startsWith("-")) - base = base.substring(1); - base = base.trim(); - actualBit.add(new StyledText(base+" ","afterline")); - } - actualBit.add(new StyledText(")\n","afterline")); - } - } - return actualBit; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureBloodRush.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureBloodRush.java deleted file mode 100644 index a0a86bcd..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureBloodRush.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.KeybindPressedListener; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ChatComponentText; -import org.lwjgl.input.Keyboard; - -public class FeatureBloodRush extends SimpleFeature implements KeybindPressedListener { - public FeatureBloodRush() { - super("Dungeon Secrets.Blood Rush", "Blood Rush Mode", "Auto pathfind to witherdoors. \nCan be toggled with key set in settings", "secret.bloodrush", false); - this.parameters.put("key", new FeatureParameter("key", "Key", "Press to toggle Blood Rush", Keyboard.KEY_NONE, "keybind")); - } - - @Override - public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { - if (keyBindPressedEvent.getKey() == this.getParameter("key").getValue()) { - setEnabled(!isEnabled()); - try { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfToggled Blood Rush to ยงe"+(FeatureRegistry.SECRET_BLOOD_RUSH.isEnabled() ? "on":"off"))); - } catch (Exception ignored) {} - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureCreateRefreshLine.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureCreateRefreshLine.java deleted file mode 100644 index 1c49b636..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureCreateRefreshLine.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MKeyEditButton; -import org.lwjgl.input.Keyboard; - -import java.util.LinkedHashMap; - -public class FeatureCreateRefreshLine extends SimpleFeature { - public FeatureCreateRefreshLine() { - super("Dungeon Secrets.Keybinds", "Refresh pathfind line or Trigger pathfind", "A keybind for creating or refresh pathfind lines for pathfind contexts that doesn't have line, or contexts that has refresh rate set to -1.\nPress settings to edit the key", "secret.refreshPathfind", true); - this.parameters = new LinkedHashMap<>(); - this.parameters.put("key", new FeatureParameter("key", "Key","Press to refresh or create pathfind line", Keyboard.KEY_NONE, "keybind")); - this.parameters.put("pathfind", new FeatureParameter("pathfind", "Enable Pathfinding", "Force Enable pathfind for future actions when used", false, "boolean")); - this.parameters.put("refreshrate", new FeatureParameter("refreshrate", "Line Refreshrate", "Ticks to wait per line refresh, to be overriden. If the line already has pathfind enabled, this value does nothing. Specify it to -1 to don't refresh line at all", 10, "integer")); - } - public int getKeybind() {return this.getParameter("key").getValue();} - public boolean isPathfind() { - return this.getParameter("pathfind").getValue(); - } - public int getRefreshRate() { - return this.getParameter("refreshrate").getValue(); - } - - - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { - @Override - public MPanel get() { - MFeatureEdit featureEdit = new MFeatureEdit(FeatureCreateRefreshLine.this, rootConfigPanel); - for (FeatureParameter parameter: getParameters()) { - if (parameter.getKey().equals("refreshrate")) - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureCreateRefreshLine.this, parameter, rootConfigPanel, a -> !isPathfind())); - else - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureCreateRefreshLine.this, parameter, rootConfigPanel, a -> false)); - } - return featureEdit; - } - }); - return "base." + getKey() ; - } - - - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java deleted file mode 100644 index e492bd1c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.KeybindPressedListener; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MKeyEditButton; -import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.util.ChatComponentText; -import org.lwjgl.input.Keyboard; - -public class FeatureFreezePathfind extends SimpleFeature implements KeybindPressedListener { - public FeatureFreezePathfind() { - super("Dungeon Secrets.Keybinds", "Global Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move.\nPress settings to edit the key", "secret.freezepathfind", false); - this.parameters.put("key", new FeatureParameter("key", "Key", "Press to toggle freeze pathfind", Keyboard.KEY_NONE, "keybind")); - } - - @Override - public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { - if (keyBindPressedEvent.getKey() == this.getParameter("key").getValue()) { - setEnabled(!isEnabled()); - try { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfToggled Pathfind Freeze to ยงe"+(FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() ? "on":"off"))); - } catch (Exception ignored) {} - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindStrategy.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindStrategy.java deleted file mode 100644 index 9c732dbf..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindStrategy.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import com.google.common.base.Supplier; -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.text.PanelTextParameterConfig; -import kr.syeyoung.dungeonsguide.features.text.StyledTextRenderer; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; -import lombok.Data; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.awt.*; -import java.util.Arrays; -import java.util.stream.Collectors; - -public class FeaturePathfindStrategy extends SimpleFeature { - public FeaturePathfindStrategy() { - super("Dungeon Secrets", "Pathfind Algorithm", "Select pathfind algorithm used by paths", "secret.secretpathfind.algorithm", true); - this.parameters.put("strategy", new FeatureParameter("strategy", "Pathfind Strategy", "Pathfind Strategy", "THETA_STAR", "string")); - - } - - @Override - public boolean isDisyllable() { - return false; - } - - @Override - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { - @Override - public MPanel get() { - - MFeatureEdit featureEdit = new MFeatureEdit(FeaturePathfindStrategy.this, rootConfigPanel); - PathfindStrategy alignment = getPathfindStrat(); - MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.stream(PathfindStrategy.values()).map(Enum::name).collect(Collectors.toList()), alignment.name()) { - @Override - public Dimension getPreferredSize() { - return new Dimension(150, 20); - } - }; - mStringSelectionButton.setOnUpdate(() -> { - FeaturePathfindStrategy.this.getParameter("strategy").setValue(mStringSelectionButton.getSelected()); - FeaturePathfindStrategy.this.getParameter("strategy").setDescription(getPathfindStrat().getDescription()); - featureEdit.removeParameterEdit(null); - }); - featureEdit.addParameterEdit("strategy", new MParameterEdit(FeaturePathfindStrategy.this, FeaturePathfindStrategy.this.getParameter("strategy"), rootConfigPanel, mStringSelectionButton, (a) -> false)); - - for (FeatureParameter parameter: getParameters()) { - if (parameter.getKey().equals("strategy")) continue; - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeaturePathfindStrategy.this, parameter, rootConfigPanel)); - } - return featureEdit; - } - }); - return "base." + getKey() ; - } - - @Getter @RequiredArgsConstructor - public enum PathfindStrategy { - THETA_STAR("The default pathfinding algorithm. It will generate sub-optimal path quickly."), - A_STAR_DIAGONAL("New pathfinding algorithm. It will generate path that looks like the one JPS generates"), - A_STAR_FINE_GRID("New pathfinding algorithm. It will generate path that kind of looks like stair"), - JPS_LEGACY("The improved pathfinding algorithm. Not suggested for usage. It will have problems on diagonal movements, thus giving wrong routes"), - A_STAR_LEGACY("The first pathfinding algorithm. It may have problem on navigating through stairs. This is the one used by Minecraft for mob pathfind."); - - private final String description; - } - - @Override - public void loadConfig(JsonObject jsonObject) { - super.loadConfig(jsonObject); - FeaturePathfindStrategy.PathfindStrategy alignment; - try { - alignment = PathfindStrategy.valueOf(FeaturePathfindStrategy.this.getParameter("strategy").getValue()); - } catch (Exception e) {alignment = PathfindStrategy.THETA_STAR;} - FeaturePathfindStrategy.this.getParameter("strategy").setValue(alignment.name()); - FeaturePathfindStrategy.this.getParameter("strategy").setDescription(alignment.getDescription()); - } - - public PathfindStrategy getPathfindStrat() { - return PathfindStrategy.valueOf(FeaturePathfindStrategy.this.getParameter("strategy").getValue()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindToAll.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindToAll.java deleted file mode 100644 index 886eefef..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindToAll.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeaturePathfindToAll extends SimpleFeature { - public FeaturePathfindToAll(){ - super("Dungeon Secrets.Pathfind To All", "Start pathfind to all secrets upon entering a room", "Auto browse to all secrets in the room", "secret.secretpathfind.allbrowse", false); - this.parameters.put("bat", new FeatureParameter("bat", "Trigger pathfind to Bat", "This feature will trigger pathfind to all bats in this room when entering a room", true, "boolean")); - this.parameters.put("chest", new FeatureParameter("chest", "Trigger pathfind to Chest", "This feature will trigger pathfind to all chests in this room when entering a room", true, "boolean")); - this.parameters.put("essence", new FeatureParameter("essence", "Trigger pathfind to Essence", "This feature will trigger pathfind to all essences in this room when entering a room", true, "boolean")); - this.parameters.put("itemdrop", new FeatureParameter("itemdrop", "Trigger pathfind to Itemdrop", "This feature will trigger pathfind to all itemdrops in this room when entering a room", true, "boolean")); - } - - public boolean isBat() { - return this.getParameter("bat").getValue(); - } - public boolean isChest() { - return this.getParameter("chest").getValue(); - } - public boolean isEssence() { - return this.getParameter("essence").getValue(); - } - public boolean isItemdrop() { - return this.getParameter("itemdrop").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java deleted file mode 100644 index 0c3ae9e6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.listener.TickListener; -import kr.syeyoung.dungeonsguide.features.text.*; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MPassiveLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.*; -import java.util.List; -import java.util.function.Predicate; - -public class FeatureSoulRoomWarning extends TextHUDFeature implements TickListener { - - public FeatureSoulRoomWarning() { - super("Dungeon.Dungeon Information","Secret Soul Alert", "Alert if there is an fairy soul in the room", "secret.fairysoulwarn", true, getFontRenderer().getStringWidth("There is a fairy soul in this room!"), getFontRenderer().FONT_HEIGHT); - getStyles().add(new TextStyle("warning", new AColor(0xFF, 0x69,0x17,255), new AColor(0, 0,0,0), false)); - - this.parameters.put("roomuids", new FeatureParameter("roomuids", "Disabled room Names", "Disable for these rooms", new ArrayList<>(), "stringlist")); - } - - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - @Override - public boolean isHUDViewable() { - return warning > System.currentTimeMillis(); - } - - @Override - public List getUsedTextStyle() { - return Collections.singletonList("warning"); - } - - private UUID lastRoomUID = UUID.randomUUID(); - private long warning = 0; - - private static final List text = new ArrayList(); - static { - text.add(new StyledText("There is a fairy soul in this room!", "warning")); - } - - @Override - public List getText() { - return text; - } - - - @Override - public void onTick() { - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - if (thePlayer == null) return; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) return; - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - - if (!dungeonRoom.getDungeonRoomInfo().getUuid().equals(lastRoomUID)) { - for (DungeonMechanic value : dungeonRoom.getMechanics().values()) { - if (value instanceof DungeonFairySoul) - warning = System.currentTimeMillis() + 2500; - } - lastRoomUID = dungeonRoom.getDungeonRoomInfo().getUuid(); - } - } - - @Override - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { - @Override - public MPanel get() { - - MFeatureEdit featureEdit = new MFeatureEdit(FeatureSoulRoomWarning.this, rootConfigPanel); - featureEdit.addParameterEdit("textStyleNEW", new PanelTextParameterConfig(FeatureSoulRoomWarning.this)); - - StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(FeatureSoulRoomWarning.this.getParameter("alignment").getValue()); - MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name()); - mStringSelectionButton.setOnUpdate(() -> { - FeatureSoulRoomWarning.this.getParameter("alignment").setValue(mStringSelectionButton.getSelected()); - }); - featureEdit.addParameterEdit("alignment", new MParameterEdit(FeatureSoulRoomWarning.this, FeatureSoulRoomWarning.this.getParameter("alignment"), rootConfigPanel, mStringSelectionButton, (a) -> false)); - - for (FeatureParameter parameter: getParameters()) { - if (parameter.getKey().equals("textStylesNEW")) continue; - if (parameter.getKey().equals("alignment")) continue; - if (parameter.getKey().equals("roomuids")) continue; - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureSoulRoomWarning.this, parameter, rootConfigPanel)); - } - featureEdit.addParameterEdit("roomuids", new RoomSelectionPanel(FeatureSoulRoomWarning.this.>getParameter("roomuids"), (a) -> { - for (DungeonMechanic value : a.getMechanics().values()) { - if (value instanceof DungeonFairySoul) return true; - } - return false; - }) ); - return featureEdit; - } - }); - return "base." + getKey() ; - } - - public static class RoomSelectionPanel extends MPanel { - FeatureParameter> uids; - private List passiveLabelAndElements = new ArrayList<>(); - private List toggleButtons = new ArrayList<>(); - private MButton addAll, removeAll; - public RoomSelectionPanel(FeatureParameter> roomuids, Predicate selectableRooms) { - this.uids = roomuids; - for (DungeonRoomInfo dungeonRoomInfo : DungeonRoomInfoRegistry.getRegistered()) { - if (!selectableRooms.test(dungeonRoomInfo)) continue; - MToggleButton mToggleButton = new MToggleButton(); - mToggleButton.setEnabled(!roomuids.getValue().contains(dungeonRoomInfo.getUuid().toString())); - mToggleButton.setOnToggle(() -> { - if (mToggleButton.isEnabled()) - roomuids.getValue().remove(dungeonRoomInfo.getUuid().toString()); - else - roomuids.getValue().add(dungeonRoomInfo.getUuid().toString()); - }); - toggleButtons.add(mToggleButton); - MPassiveLabelAndElement passiveLabelAndElement = new MPassiveLabelAndElement(dungeonRoomInfo.getName(), mToggleButton); - passiveLabelAndElement.setDivideRatio(0.7); - passiveLabelAndElements.add(passiveLabelAndElement); - } - for (MPassiveLabelAndElement passiveLabelAndElement : passiveLabelAndElements) { - add(passiveLabelAndElement); - } - { - addAll = new MButton(); addAll.setText("Enable All"); - addAll.setOnActionPerformed(() -> { - roomuids.getValue().clear(); - for (MToggleButton toggleButton : toggleButtons) { - toggleButton.setEnabled(true); - } - }); - removeAll = new MButton(); removeAll.setText("Disable All"); - removeAll.setOnActionPerformed(() -> { - for (MToggleButton toggleButton : toggleButtons) { - toggleButton.setEnabled(false); - toggleButton.getOnToggle().run(); - } - }); - add(addAll); add(removeAll); - } - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(-1, (int) (20 * Math.ceil(passiveLabelAndElements.size() / 3) + 27)); - } - - @Override - public void onBoundsUpdate() { - int xI = 0; - int y = 22; - int w3 = (getBounds().width-20) / 3; - for (MPassiveLabelAndElement passiveLabelAndElement : passiveLabelAndElements) { - passiveLabelAndElement.setBounds(new Rectangle(5 + xI * (w3+5), y, w3, 20)); - xI ++; - if (xI == 3) { - xI = 0; - y += 20; - } - } - - addAll.setBounds(new Rectangle(getBounds().width-150, 2, 70, 14)); - removeAll.setBounds(new Rectangle(getBounds().width-75, 2, 70, 14)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Gui.drawRect(0,0,getBounds().width, getBounds().height,RenderUtils.blendAlpha(0x141414, 0.12f)); - Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); - Gui.drawRect(1,1,getBounds().width-1, 18, RenderUtils.blendAlpha(0x141414, 0.12f)); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.pushMatrix(); - GlStateManager.translate(5,5,0); - GlStateManager.scale(1.0,1.0,0); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Enable for these rooms", 0,0, 0xFFFFFFFF); - GlStateManager.popMatrix(); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureTogglePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureTogglePathfind.java deleted file mode 100644 index aa128d92..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureTogglePathfind.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.features.listener.KeybindPressedListener; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MKeyEditButton; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ChatComponentText; -import org.lwjgl.input.Keyboard; - -public class FeatureTogglePathfind extends SimpleFeature implements KeybindPressedListener { - public FeatureTogglePathfind() { - super("Dungeon Secrets.Keybinds", "Toggle Pathfind Lines", "A key for toggling pathfound line visibility.\nPress settings to edit the key", "secret.togglePathfind"); - this.parameters.put("key", new FeatureParameter("key", "Key", "Press to toggle pathfind lines", Keyboard.KEY_NONE, "keybind")); - } - public boolean togglePathfindStatus = false; - - @Override - public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { - if (keyBindPressedEvent.getKey() == this.getParameter("key").getValue() && isEnabled()) { - togglePathfindStatus = !togglePathfindStatus; - try { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfToggled Pathfind Line visibility to ยงe"+(togglePathfindStatus ? "on":"off"))); - } catch (Exception ignored) {} - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/PathfindLineProperties.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/PathfindLineProperties.java deleted file mode 100644 index c5f388db..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/PathfindLineProperties.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret; - -import com.google.common.base.Supplier; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; - -import java.util.LinkedHashMap; - -public class PathfindLineProperties extends SimpleFeature { - private PathfindLineProperties parent; - public PathfindLineProperties(String category, String name, String description, String key, boolean useParent, PathfindLineProperties parent) { - super(category, name, description, key); - this.parent = parent; - this.parameters = new LinkedHashMap<>(); - if (parent != null) - this.parameters.put("useGlobal", new FeatureParameter("useGlobal", "Use Global Settings instead of this", "Completely ignore these settings, then use the parent one:: '"+parent.getName()+"'", useParent, "boolean")); - this.parameters.put("pathfind", new FeatureParameter("pathfind", "Enable Pathfinding", "Enable pathfind for secrets", useParent, "boolean")); - this.parameters.put("lineColor", new FeatureParameter("lineColor", "Line Color", "Color of the pathfind line", new AColor(0xFFFF0000, true), "acolor")); - this.parameters.put("lineWidth", new FeatureParameter("lineWidth", "Line Thickness", "Thickness of the pathfind line",1.0f, "float")); - this.parameters.put("linerefreshrate", new FeatureParameter("linerefreshrate", "Line Refreshrate", "Ticks to wait per line refresh. Specify it to -1 to don't refresh line at all", 10, "integer")); - this.parameters.put("beacon", new FeatureParameter("beacon", "Enable Beacons", "Enable beacons for pathfind line targets", true, "boolean")); - this.parameters.put("beamColor", new FeatureParameter("beamColor", "Beam Color", "Color of the beacon beam", new AColor(0x77FF0000, true), "acolor")); - this.parameters.put("beamTargetColor", new FeatureParameter("beamTargetColor", "Target Color", "Color of the target", new AColor(0x33FF0000, true), "acolor")); - } - - - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { - @Override - public MPanel get() { - MFeatureEdit featureEdit = new MFeatureEdit(PathfindLineProperties.this, rootConfigPanel); - for (FeatureParameter parameter: getParameters()) { - if (parameter.getKey().startsWith("line")) - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> isGlobal() || !isPathfind())); - else if (parameter.getKey().startsWith("beam")) - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> isGlobal() || !isBeacon())); - else if (!parameter.getKey().equals("useGlobal")) - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> isGlobal())); - else - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> false)); - } - return featureEdit; - } - }); - return "base." + getKey() ; - } - - @Override - public boolean isDisyllable() { - return false; - } - - public boolean isGlobal() { - if (parent == null) return false; - return this.getParameter("useGlobal").getValue(); - } - - public boolean isPathfind() { - return isGlobal() ? parent.isPathfind() : this.getParameter("pathfind").getValue(); - } - public AColor getLineColor() { - return isGlobal() ? parent.getLineColor() : this.getParameter("lineColor").getValue(); - } - public float getLineWidth() { - return isGlobal() ? parent.getLineWidth() : this.getParameter("lineWidth").getValue(); - } - public int getRefreshRate() { - return isGlobal() ? parent.getRefreshRate() : this.getParameter("linerefreshrate").getValue(); - } - public boolean isBeacon() { - return isGlobal() ? parent.isBeacon() : this.getParameter("beacon").getValue(); - } - public AColor getBeamColor() { - return isGlobal() ? parent.getBeamColor() : this.getParameter("beamColor").getValue(); - } - public AColor getTargetColor() { - return isGlobal() ? parent.getTargetColor() : this.getParameter("beamTargetColor").getValue(); - } - public ActionRoute.ActionRouteProperties getRouteProperties() { - ActionRoute.ActionRouteProperties actionRouteProperties = new ActionRoute.ActionRouteProperties(); - actionRouteProperties.setPathfind(isPathfind()); - actionRouteProperties.setLineColor(getLineColor()); - actionRouteProperties.setLineWidth(getLineWidth()); - actionRouteProperties.setLineRefreshRate(getRefreshRate()); - actionRouteProperties.setBeacon(isBeacon()); - actionRouteProperties.setBeaconBeamColor(getBeamColor()); - actionRouteProperties.setBeaconColor(getTargetColor()); - return actionRouteProperties; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java deleted file mode 100644 index 6a00b72b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser; - -import com.google.common.collect.Lists; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser.MGuiMechanicBrowser; -import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener; -import kr.syeyoung.dungeonsguide.features.listener.GuiPreRenderListener; -import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; -import kr.syeyoung.dungeonsguide.features.text.StyledTextRenderer; -import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MPassiveLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.utils.GlStateUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.*; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.util.MathHelper; -import net.minecraftforge.client.event.GuiScreenEvent; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.io.IOException; -import java.util.*; -import java.util.List; - -public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderListener, GuiClickListener, WorldRenderListener { - public FeatureMechanicBrowse() { - super("Dungeon Secrets.Secret Browser","Secret Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300); - parameters.put("scale", new FeatureParameter("scale", "Scale", "Scale", 1.0f, "float")); - mGuiMechanicBrowser = new MGuiMechanicBrowser(this); - mGuiMechanicBrowser.setWorldAndResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); - lastWidth = Minecraft.getMinecraft().displayWidth; lastHeight = Minecraft.getMinecraft().displayHeight; - } - - public double getScale() { - return this.getParameter("scale").getValue(); - } - - private MGuiMechanicBrowser mGuiMechanicBrowser; - - - @Override - public void drawDemo(float partialTicks) { - super.drawDemo(partialTicks); - double scale = FeatureMechanicBrowse.this.getParameter("scale").getValue(); - GlStateManager.scale(scale, scale, 1.0); - - Dimension bigDim = getFeatureRect().getRectangleNoScale().getSize(); - Dimension effectiveDim = new Dimension((int) (bigDim.width / scale),(int)( bigDim.height / scale)); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - Gui.drawRect(0, 0, effectiveDim.width, fr.FONT_HEIGHT + 4, 0xFF444444); - Gui.drawRect(1, 1, effectiveDim.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); - fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); - fr.drawString("Open Chat to Select Secrets", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA); - } - - private int lastWidth, lastHeight; - - @Override - public void drawScreen(float partialTicks) { - if (!isEnabled()) return; - int i = Mouse.getEventX(); - int j = Minecraft.getMinecraft().displayHeight - Mouse.getEventY(); - if (Minecraft.getMinecraft().displayWidth != lastWidth || Minecraft.getMinecraft().displayHeight != lastHeight) mGuiMechanicBrowser.initGui(); - lastWidth = Minecraft.getMinecraft().displayWidth; lastHeight = Minecraft.getMinecraft().displayHeight; - mGuiMechanicBrowser.drawScreen(i,j,partialTicks); - } - - @Override - public void setFeatureRect(GUIRectangle featureRect) { - super.setFeatureRect(featureRect); - mGuiMechanicBrowser.initGui(); - } - - @Override - public void drawHUD(float partialTicks) { } - - @Override - public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { - if (!isEnabled()) return; - try { - mGuiMechanicBrowser.handleMouseInput(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - - @Override - public void onGuiPreRender(GuiScreenEvent.DrawScreenEvent.Pre rendered) { - if (!isEnabled()) return; - int i = Mouse.getEventX(); - int j = Minecraft.getMinecraft().displayHeight - Mouse.getEventY(); - mGuiMechanicBrowser.drawScreen(i, j, rendered.renderPartialTicks); - } - - @Override - public void drawWorld(float partialTicks) { - if (!isEnabled()) return; - SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - if (!skyblockStatus.isOnDungeon()) return; - if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; - DungeonContext context = skyblockStatus.getContext(); - - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom == null) return; - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - String id = mGuiMechanicBrowser.getPanelMechanicBrowser().getSelectedID(); - if (id != null) { - Optional.ofNullable(dungeonRoom.getMechanics().get(mGuiMechanicBrowser.getPanelMechanicBrowser().getSelectedID())) - .ifPresent(a -> { - a.highlight(new Color(0,255,255,50), id +" ("+( - dungeonRoom.getMechanics().get(id).getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double((dungeonRoom.getMechanics().get(id)).getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", dungeonRoom, partialTicks); - }); - } - } - @Override - public List getTooltipForEditor(GuiGuiLocationConfig guiGuiLocationConfig) { - List mPanels = super.getTooltipForEditor(guiGuiLocationConfig); - - mPanels.add(new MPassiveLabelAndElement("Scale", new MFloatSelectionButton(FeatureMechanicBrowse.this.getParameter("scale").getValue()) {{ - setOnUpdate(() ->{ - FeatureMechanicBrowse.this.getParameter("scale").setValue(this.getData()); - mGuiMechanicBrowser.initGui(); - }); } - })); - - return mPanels; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java deleted file mode 100644 index 27d5e583..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser; - -import kr.syeyoung.dungeonsguide.gui.MGui; -import lombok.Getter; - -public class MGuiMechanicBrowser extends MGui { - private FeatureMechanicBrowse featureMechanicBrowse; - @Getter - private PanelMechanicBrowser panelMechanicBrowser; - public MGuiMechanicBrowser(FeatureMechanicBrowse mechanicBrowse) { - this.featureMechanicBrowse = mechanicBrowse; - panelMechanicBrowser = new PanelMechanicBrowser(mechanicBrowse); - getMainPanel().add(panelMechanicBrowser); - } - - @Override - public void initGui() { - super.initGui(); - panelMechanicBrowser.setBounds(featureMechanicBrowse.getFeatureRect().getRectangle()); - panelMechanicBrowser.setScale(featureMechanicBrowse.getScale()); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawScreen(mouseX, mouseY, partialTicks); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java deleted file mode 100644 index ca803bff..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.GlStateUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.AllArgsConstructor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Supplier; - -@AllArgsConstructor -public class MechanicBrowserElement extends MPanel { - private Supplier name; - private boolean isCategory = false; - private BiConsumer onClick; - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (isCategory || isFocused) - Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF444444); - else if (lastAbsClip.contains(absMousex, absMousey)) - Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF555555); - Minecraft.getMinecraft().fontRendererObj.drawString((String)name.get(), 4, 1, 0xFFEEEEEE); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(Minecraft.getMinecraft().fontRendererObj.getStringWidth(name.get()) + 8, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY) && onClick != null) - onClick.accept(this, new Point(lastParentPoint.x + bounds.x, lastParentPoint.y + bounds.y)); - } - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (lastAbsClip.contains(absMouseX, absMouseY) && onClick != null) - setCursor(EnumCursor.POINTING_HAND); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java deleted file mode 100644 index e2a0d028..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser; - -import kr.syeyoung.dungeonsguide.gui.elements.MList; -import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; -import lombok.Getter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -public class MechanicBrowserTooltip extends MTooltip { - @Getter - private MList mList; - public MechanicBrowserTooltip() { - mList = new MList(); - mList.setGap(0); - add(mList); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Dimension effectiveDim = getEffectiveDimension(); - Gui.drawRect(0, 0, effectiveDim.width, effectiveDim.height, 0xFF444444); - Gui.drawRect(1, 1, effectiveDim.width - 1, effectiveDim.height - 1, 0xFF262626); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - mList.setBounds(new Rectangle(1,1, getEffectiveDimension().width-2, getEffectiveDimension().height-2)); - mList.realignChildren(); - } - - @Override - public void setScale(double scale) { - super.setScale(scale); - mList.setBounds(new Rectangle(1,1, getEffectiveDimension().width-2, getEffectiveDimension().height-2)); - mList.realignChildren(); - } - - @Override - public Dimension getPreferredSize() { - Dimension dim = mList.getPreferredSize(); - return new Dimension((int) ((dim.width + 2) * getScale()), (int) ((dim.height + 2) * getScale())); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (!lastAbsClip.contains(absMouseX, absMouseY)) close(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java deleted file mode 100644 index 25b23e71..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MList; -import kr.syeyoung.dungeonsguide.gui.elements.MPanelScaledGUI; -import kr.syeyoung.dungeonsguide.gui.elements.MScrollablePanel; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiChat; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.MathHelper; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class PanelMechanicBrowser extends MPanelScaledGUI { - private FeatureMechanicBrowse feature; - private MScrollablePanel scrollablePanel; - private MList mList; - private MechanicBrowserTooltip mechanicBrowserTooltip; - - public PanelMechanicBrowser(FeatureMechanicBrowse mechanicBrowse) { - this.feature = mechanicBrowse; - this.scrollablePanel = new MScrollablePanel(1); - add(this.scrollablePanel); - scrollablePanel.getScrollBarY().setWidth(0); - mList = new MList() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0,0,parentWidth,parentHeight)); - Dimension prefSize = getPreferredSize(); - int hei = prefSize.height; - setBounds(new Rectangle(0,0,parentWidth,hei)); - realignChildren(); - } - }; - mList.setDrawLine(false); mList.setGap(0); - scrollablePanel.add(mList); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - toggleTooltip(openGUI()); - - Optional dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext()) - .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) - .map(a -> DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getRoomMapper().get(a)); - - DungeonRoom dungeonRoom = dungeonRoomOpt.orElse(null); - renderTick(dungeonRoom); - if (dungeonRoom == null) return; - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - - GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - Dimension effectiveDim = getEffectiveDimension(); - - Gui.drawRect(0, 0, effectiveDim.width, fr.FONT_HEIGHT + 4, 0xFF444444); - Gui.drawRect(1, 1, effectiveDim.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); - if (grp.getPath("MECH-BROWSER") == null) - fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); - else { - ActionRoute route = grp.getPath("MECH-BROWSER"); - fr.drawString(route.getMechanic()+" -> "+route.getState(), fr.getStringWidth("Selected: ") + 2,2, 0xFFFFFF00); - } - fr.drawString("Open Chat to Select Secrets", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA); - - if (!openGUI()) return; - - Gui.drawRect(0, fr.FONT_HEIGHT + 4, effectiveDim.width, effectiveDim.height, 0xFF444444); - Gui.drawRect(1, fr.FONT_HEIGHT + 5, effectiveDim.width - 1,effectiveDim.height - 1, 0xFF262626); - } - - private UUID lastRoomUID = null; - public void renderTick(DungeonRoom dungeonRoom) { - if (dungeonRoom == null && lastRoomUID != null) { - lastRoomUID = null; - for (MPanel childComponent : mList.getChildComponents()) { - mList.remove(childComponent); - } - if (mechanicBrowserTooltip != null) { - mechanicBrowserTooltip.close(); - mechanicBrowserTooltip = null; - } - selectedID = null; - } else if (dungeonRoom != null && lastRoomUID != dungeonRoom.getDungeonRoomInfo().getUuid()) { - lastRoomUID = dungeonRoom.getDungeonRoomInfo().getUuid(); - // SETUP THINGS. - for (MPanel childComponent : mList.getChildComponents()) { - mList.remove(childComponent); - } - if (mechanicBrowserTooltip != null) { - mechanicBrowserTooltip.close(); - mechanicBrowserTooltip = null; - } - selectedID = null; - mList.add(new MechanicBrowserElement(() -> "ยงbCancel Current", false, (pt, me) -> cancel(pt))); - - boolean found = false; - for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonFairySoul) { - if (!found) { - mList.add(new MechanicBrowserElement(() -> "Fairy Soul", true, null)); - found = true; - } - mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ - (value.getValue().getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); - } - } - found = false; - for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonSecret) { - if (!found) { - mList.add(new MechanicBrowserElement(() -> "Secrets", true, null)); - found = true; - } - mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ - (value.getValue().getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); - } - } - found = false; - for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonTomb) { - if (!found) { - mList.add(new MechanicBrowserElement(() -> "Crypts", true, null)); - found = true; - } - mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ - (value.getValue().getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); - } - } - found = false; - for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonNPC) { - if (!found) { - mList.add(new MechanicBrowserElement(() -> "NPC", true, null)); - found = true; - } - mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ - (value.getValue().getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); - } - } - found = false; - for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonJournal) { - if (!found) { - mList.add(new MechanicBrowserElement(() -> "Journals", true, null)); - found = true; - } - mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ - (value.getValue().getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); - } - } - found = false; - for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonRoomDoor){ - if (!found) { - mList.add(new MechanicBrowserElement(() -> "Gates", true, null)); - found = true; - } - mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ - (value.getValue().getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); - } - } - found = false; - for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonDoor || value.getValue() instanceof DungeonBreakableWall || value.getValue() instanceof DungeonLever - || value.getValue() instanceof DungeonOnewayDoor || value.getValue() instanceof DungeonOnewayLever || value.getValue() instanceof DungeonPressurePlate) { - if (!found) { - mList.add(new MechanicBrowserElement(() -> "ETC", true, null)); - found = true; - } - mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ - (value.getValue().getRepresentingPoint(dungeonRoom) != null ? - String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") - +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); - } - } - - scrollablePanel.evalulateContentArea(); - - } - } - - private int latestTooltipDY; - @Getter - private String selectedID = null; - public void onElementClick(String id, DungeonMechanic dungeonMechanic, Point pt, MechanicBrowserElement mechanicBrowserElement) { - Optional dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext()) - .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) - .map(a -> DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getRoomMapper().get(a)); - selectedID = id; - - DungeonRoom dungeonRoom = dungeonRoomOpt.orElse(null); - if (dungeonRoom == null) return; - DungeonMechanic dungeonMechanic1 = dungeonRoom.getMechanics().get(id); - if (dungeonMechanic1 != dungeonMechanic) return; - Set states = dungeonMechanic1.getPossibleStates(dungeonRoom); - - - if (mechanicBrowserTooltip != null) { - mechanicBrowserTooltip.close(); - } - - latestTooltipDY = (int) (pt.y * getScale() - bounds.y - 1); - - mechanicBrowserTooltip = new MechanicBrowserTooltip(); - for (String state : states) { - mechanicBrowserTooltip.getMList().add(new MechanicBrowserElement(() -> state, false, (m2, pt2) -> { - if (dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor) - ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind("MECH-BROWSER", id, state, FeatureRegistry.SECRET_LINE_PROPERTIES_SECRET_BROWSER.getRouteProperties()); -// mechanicBrowserTooltip.close(); -// mechanicBrowserTooltip = null; - })); - } - mechanicBrowserTooltip.setScale(getScale()); - Dimension prefSize = mechanicBrowserTooltip.getPreferredSize(); - mechanicBrowserTooltip.setBounds(new Rectangle(bounds.x + - (bounds.x > Minecraft.getMinecraft().displayWidth/2 ? -prefSize.width : bounds.width), latestTooltipDY + bounds.y, prefSize.width, prefSize.height)); - mechanicBrowserTooltip.open(this); - } - - public void cancel(MechanicBrowserElement mechanicBrowserElement) { - Optional dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext()) - .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) - .map(a -> DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getRoomMapper().get(a)); - mechanicBrowserElement.setFocused(false); - if (!dungeonRoomOpt.isPresent()) return; - DungeonRoom dungeonRoom = dungeonRoomOpt.get(); - if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; - ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).cancel("MECH-BROWSER"); - } - - public void toggleTooltip(boolean open) { - if (mechanicBrowserTooltip != null) { - if (open) { - mechanicBrowserTooltip.open(this); - } else { - mechanicBrowserTooltip.close(); - } - } - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - Dimension dimension = getEffectiveDimension(); - int y = Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT + 4; - scrollablePanel.setBounds(new Rectangle(1,y + 1, dimension.width - 2, dimension.height - y - 2)); - scrollablePanel.evalulateContentArea(); - if (mechanicBrowserTooltip != null) { - Dimension prefSize = mechanicBrowserTooltip.getPreferredSize(); - mechanicBrowserTooltip.setScale(getScale()); - mechanicBrowserTooltip.setBounds(new Rectangle(bounds.x + (bounds.x > Minecraft.getMinecraft().displayWidth/2 ? -prefSize.width: bounds.width), latestTooltipDY + bounds.y, prefSize.width, prefSize.height)); - } - } - - public boolean openGUI() { - return Minecraft.getMinecraft().currentScreen != null - && Minecraft.getMinecraft().currentScreen instanceof GuiChat && lastRoomUID != null; - } - - @Override - public List getChildComponents() { - return openGUI() ? super.getChildComponents() : Collections.emptyList(); - } - - @Override - public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { - selectedID = null; - if (mechanicBrowserTooltip != null) { - mechanicBrowserTooltip.close(); - mechanicBrowserTooltip = null; - } - - return super.mouseClicked0(absMouseX, absMouseY, relMouseX0, relMouseY0, mouseButton); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBlaze.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBlaze.java deleted file mode 100644 index 1e698414..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBlaze.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeatureSolverBlaze extends SimpleFeature { - public FeatureSolverBlaze() { - super("Solver.Floor 2+", "Blaze", "Highlights the blaze that needs to be killed in an blaze room", "solver.blaze"); - parameters.put("normBlazeColor", new FeatureParameter("blazecolor", "Normal Blaze Color", "Normal Blaze Color", new AColor(255,255,255,255), "acolor")); - parameters.put("nextBlazeColor", new FeatureParameter("blazecolor", "Next Blaze Color", "Next Blaze Color", new AColor(0,255,0,255), "acolor")); - parameters.put("nextUpBlazeColor", new FeatureParameter("blazecolor", "Next Up Blaze Color", "Color of blaze after next blaze", new AColor(255,255,0,255), "acolor")); - parameters.put("blazeborder", new FeatureParameter("blazeborder", "Blaze Border Color", "Blaze border color", new AColor(255,255,255,0), "acolor")); - } - - public AColor getBlazeColor() { - return this.getParameter("normBlazeColor").getValue(); - } - public AColor getNextBlazeColor() { - return this.getParameter("nextBlazeColor").getValue(); - } - public AColor getNextUpBlazeColor() { - return this.getParameter("nextUpBlazeColor").getValue(); - } - public AColor getBorder() { - return this.getParameter("blazeborder").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBombdefuse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBombdefuse.java deleted file mode 100644 index e9bf623b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBombdefuse.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; -import org.lwjgl.input.Keyboard; - -public class FeatureSolverBombdefuse extends SimpleFeature { - public FeatureSolverBombdefuse() { - super("Solver.Floor 7+", "Bomb Defuse", "Communicates with others dg using key 'F' for solutions and displays it", "solver.bombdefuse"); - parameters.put("key", new FeatureParameter("key", "Key","Press to send solution in chat", Keyboard.KEY_NONE, "keybind")); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBox.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBox.java deleted file mode 100644 index c4dcebf6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverBox.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -import java.util.LinkedHashMap; - -public class FeatureSolverBox extends SimpleFeature { - public FeatureSolverBox() { - super("Solver.Floor 3+", "Box (Advanced)", "Calculates solution for box puzzle room, and displays it to user", "solver.box"); - this.parameters = new LinkedHashMap<>(); - this.parameters.put("disableText", new FeatureParameter("disableText", "Box Puzzle Solver Disable text", "Disable 'Type recalc to recalculate solution' showing up on top left.\nYou can still type recalc to recalc solution after disabling this feature", false, "boolean")); - this.parameters.put("lineColor", new FeatureParameter("lineColor", "Line Color", "Color of the solution line", new AColor(0xFF00FF00, true), "acolor")); - this.parameters.put("lineWidth", new FeatureParameter("lineWidth", "Line Thickness", "Thickness of the solution line",1.0f, "float")); - - this.parameters.put("targetColor", new FeatureParameter("targetColor", "Target Color", "Color of the target button", new AColor(0x5500FFFF, true), "acolor")); - this.parameters.put("textColor1", new FeatureParameter("textColor1", "Text Color", "Color of the text (next step)", new AColor(0xFF00FF00, true), "acolor")); - this.parameters.put("textColor2", new FeatureParameter("textColor2", "Text Color", "Color of the text (others)", new AColor(0xFF000000, true), "acolor")); - } - public AColor getLineColor() { - return this.getParameter("lineColor").getValue(); - } - public float getLineWidth() { - return this.getParameter("lineWidth").getValue(); - } - public boolean disableText() { - return this.getParameter("disableText").getValue(); - } - public AColor getTargetColor() { - return this.getParameter("targetColor").getValue(); - } - public AColor getTextColor() { - return this.getParameter("textColor1").getValue(); - } - public AColor getTextColor2() { - return this.getParameter("textColor2").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverIcefill.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverIcefill.java deleted file mode 100644 index 681e6b12..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverIcefill.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -import java.util.LinkedHashMap; - -public class FeatureSolverIcefill extends SimpleFeature { - public FeatureSolverIcefill() { - super("Solver.Floor 3+", "Icepath (Advanced)", "Calculates solution for icepath puzzle and displays it to user", "solver.icepath"); - this.parameters = new LinkedHashMap<>(); - this.parameters.put("lineColor", new FeatureParameter("lineColor", "Line Color", "Color of the solution line", new AColor(0xFF00FF00, true), "acolor")); - this.parameters.put("lineWidth", new FeatureParameter("lineWidth", "Line Thickness", "Thickness of the solution line",1.0f, "float")); - } - public AColor getLineColor() { - return this.getParameter("lineColor").getValue(); - } - public float getLineWidth() { - return this.getParameter("lineWidth").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverKahoot.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverKahoot.java deleted file mode 100644 index 6055c12b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverKahoot.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeatureSolverKahoot extends SimpleFeature { - public FeatureSolverKahoot() { - super("Solver.Floor 4+", "Quiz", "Highlights the correct solution for trivia puzzle", "solver.trivia"); - - this.parameters.put("targetColor", new FeatureParameter("targetColor", "Target Color", "Color of the solution box", new AColor(0,255,0,50), "acolor")); - } - - public AColor getTargetColor() { - return this.getParameter("targetColor").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverRiddle.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverRiddle.java deleted file mode 100644 index 23bc5a0c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverRiddle.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeatureSolverRiddle extends SimpleFeature { - public FeatureSolverRiddle() { - super("Solver.Any Floor", "Riddle", "Highlights the correct box after clicking on all 3 weirdos", "solver.riddle"); - - this.parameters.put("targetColor", new FeatureParameter("targetColor", "Target Color", "Color of the solution box", new AColor(0,255,0,50), "acolor")); - } - - public AColor getTargetColor() { - return this.getParameter("targetColor").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverSilverfish.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverSilverfish.java deleted file mode 100644 index 31a4d0e6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverSilverfish.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -import java.util.LinkedHashMap; - -public class FeatureSolverSilverfish extends SimpleFeature { - public FeatureSolverSilverfish() { - super("Solver.Floor 3+", "Silverfish (Advanced)", "Actively calculates solution for silverfish puzzle and displays it to user", "solver.silverfish"); - this.parameters = new LinkedHashMap<>(); - this.parameters.put("lineColor", new FeatureParameter("lineColor", "Line Color", "Color of the solution line", new AColor(0xFF00FF00, true), "acolor")); - this.parameters.put("lineWidth", new FeatureParameter("lineWidth", "Line Thickness", "Thickness of the solution line",1.0f, "float")); - } - public AColor getLineColor() { - return this.getParameter("lineColor").getValue(); - } - public float getLineWidth() { - return this.getParameter("lineWidth").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverTeleport.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverTeleport.java deleted file mode 100644 index c7e42516..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverTeleport.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeatureSolverTeleport extends SimpleFeature { - public FeatureSolverTeleport() { - super("Solver.Any Floor", "Teleport", "Shows teleport pads you've visited in a teleport maze room", "solver.teleport"); - - this.parameters.put("targetColor", new FeatureParameter("targetColor", "Solution Color", "Color of the solution teleport pad", new AColor(0,255,0,100), "acolor")); - this.parameters.put("targetColor2", new FeatureParameter("targetColor2", "Not-Solution Color", "Color of the solution teleport pads you've been to", new AColor(255,0,0,100), "acolor")); - } - - public AColor getTargetColor() { - return this.getParameter("targetColor").getValue(); - } - public AColor getTargetColor2() { - return this.getParameter("targetColor2").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverTictactoe.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverTictactoe.java deleted file mode 100644 index 68ca4cb5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/solvers/FeatureSolverTictactoe.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.impl.solvers; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.SimpleFeature; - -public class FeatureSolverTictactoe extends SimpleFeature { - public FeatureSolverTictactoe() { - super("Solver.Any Floor", "Tictactoe", "Shows the best move that could be taken by player in the tictactoe room", "solver.tictactoe"); - - this.parameters.put("targetColor", new FeatureParameter("targetColor", "Target Color", "Color of the solution box during your turn", new AColor(0,255,255,50), "acolor")); - this.parameters.put("targetColor2", new FeatureParameter("targetColor", "Target Color", "Color of the solution box during enemy turn", new AColor(255,201,0,50), "acolor")); - } - - public AColor getTargetColor() { - return this.getParameter("targetColor").getValue(); - } - public AColor getTargetColor2() { - return this.getParameter("targetColor2").getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/BossroomEnterListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/BossroomEnterListener.java deleted file mode 100644 index aa0b6686..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/BossroomEnterListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface BossroomEnterListener { - void onBossroomEnter(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ChatListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ChatListener.java deleted file mode 100644 index 4bd7e9ef..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ChatListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -public interface ChatListener { - void onChat(ClientChatReceivedEvent clientChatReceivedEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ChatListenerGlobal.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ChatListenerGlobal.java deleted file mode 100644 index 631f4cda..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ChatListenerGlobal.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.ClientChatReceivedEvent; - -public interface ChatListenerGlobal { - void onChat(ClientChatReceivedEvent clientChatReceivedEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DiscordUserJoinRequestListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DiscordUserJoinRequestListener.java deleted file mode 100644 index d48331d5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DiscordUserJoinRequestListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import kr.syeyoung.dungeonsguide.events.DiscordUserJoinRequestEvent; -import kr.syeyoung.dungeonsguide.events.DiscordUserUpdateEvent; - -public interface DiscordUserJoinRequestListener { - void onDiscordUserJoinRequest(DiscordUserJoinRequestEvent event); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DiscordUserUpdateListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DiscordUserUpdateListener.java deleted file mode 100644 index d376a21d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DiscordUserUpdateListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import kr.syeyoung.dungeonsguide.events.DiscordUserUpdateEvent; - -public interface DiscordUserUpdateListener { - void onDiscordUserUpdate(DiscordUserUpdateEvent event); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonContextInitializationListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonContextInitializationListener.java deleted file mode 100644 index 6256b190..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonContextInitializationListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface DungeonContextInitializationListener { - void onDungeonInitialize(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonEndListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonEndListener.java deleted file mode 100644 index 4b77f584..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonEndListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface DungeonEndListener { - void onDungeonEnd(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonQuitListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonQuitListener.java deleted file mode 100644 index a576ac53..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonQuitListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface DungeonQuitListener { - void onDungeonQuit(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonStartListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonStartListener.java deleted file mode 100644 index 7edcff0d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/DungeonStartListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface DungeonStartListener { - void onDungeonStart(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/EntityLivingRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/EntityLivingRenderListener.java deleted file mode 100644 index 44207678..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/EntityLivingRenderListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.RenderLivingEvent; -import net.minecraftforge.client.event.RenderPlayerEvent; - -public interface EntityLivingRenderListener { - void onEntityRenderPre(RenderLivingEvent.Pre renderPlayerEvent); - void onEntityRenderPost(RenderLivingEvent.Post renderPlayerEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiBackgroundRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiBackgroundRenderListener.java deleted file mode 100644 index b46f9353..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiBackgroundRenderListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.GuiScreenEvent; - -public interface GuiBackgroundRenderListener { - void onGuiBGRender(GuiScreenEvent.BackgroundDrawnEvent rendered); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiClickListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiClickListener.java deleted file mode 100644 index 048c9683..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiClickListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.GuiScreenEvent; - -public interface GuiClickListener { - void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiOpenListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiOpenListener.java deleted file mode 100644 index 0ce74ae9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiOpenListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.GuiOpenEvent; - -public interface GuiOpenListener { - void onGuiOpen(GuiOpenEvent event); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPostRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPostRenderListener.java deleted file mode 100644 index 6ea30768..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPostRenderListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.client.event.RenderGameOverlayEvent; - -public interface GuiPostRenderListener { - void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPreRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPreRenderListener.java deleted file mode 100644 index e902f41d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPreRenderListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.GuiScreenEvent; - -public interface GuiPreRenderListener { - void onGuiPreRender(GuiScreenEvent.DrawScreenEvent.Pre rendered); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiUpdateListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiUpdateListener.java deleted file mode 100644 index a52baac7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiUpdateListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; -import net.minecraftforge.client.event.GuiScreenEvent; - -public interface GuiUpdateListener { - void onGuiUpdate(WindowUpdateEvent windowUpdateEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/InteractListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/InteractListener.java deleted file mode 100644 index 717f2c72..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/InteractListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -public interface InteractListener { - void onInteract(PlayerInteractEvent event); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeyInputListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeyInputListener.java deleted file mode 100644 index ae940936..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeyInputListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.fml.common.gameevent.InputEvent; - -public interface KeyInputListener { - void onKeyInput(GuiScreenEvent.KeyboardInputEvent keyboardInputEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeybindPressedListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeybindPressedListener.java deleted file mode 100644 index 3d67e326..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/KeybindPressedListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; - -public interface KeybindPressedListener { - void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/PlayerRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/PlayerRenderListener.java deleted file mode 100644 index 73a27171..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/PlayerRenderListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.RenderPlayerEvent; - -public interface PlayerRenderListener { - void onEntityRenderPre(RenderPlayerEvent.Pre renderPlayerEvent ); - void onEntityRenderPost(RenderPlayerEvent.Post renderPlayerEvent ); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ScreenRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ScreenRenderListener.java deleted file mode 100644 index d801e7ea..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/ScreenRenderListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface ScreenRenderListener { - void drawScreen(float partialTicks); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SkyblockJoinListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SkyblockJoinListener.java deleted file mode 100644 index bd27a83b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SkyblockJoinListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface SkyblockJoinListener { - void onSkyblockJoin(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SkyblockLeaveListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SkyblockLeaveListener.java deleted file mode 100644 index efa80789..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SkyblockLeaveListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface SkyblockLeaveListener { - void onSkyblockQuit(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SoundListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SoundListener.java deleted file mode 100644 index 8bdbf532..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/SoundListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.sound.PlaySoundEvent; - -public interface SoundListener { - void onSound(PlaySoundEvent playSoundEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/StompConnectedListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/StompConnectedListener.java deleted file mode 100644 index 0f5bad0e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/StompConnectedListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; - -public interface StompConnectedListener { - void onStompConnected(StompConnectedEvent event); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TextureStichListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TextureStichListener.java deleted file mode 100644 index 77600d1e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TextureStichListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.client.event.TextureStitchEvent; - -public interface TextureStichListener { - void onTextureStitch(TextureStitchEvent event); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TickListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TickListener.java deleted file mode 100644 index 2fea2f09..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TickListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface TickListener { - void onTick(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TitleListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TitleListener.java deleted file mode 100644 index 806cd50b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TitleListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraft.network.play.server.S45PacketTitle; - -public interface TitleListener { - void onTitle(S45PacketTitle renderPlayerEvent); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java deleted file mode 100644 index f1363dc2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -import net.minecraftforge.event.entity.player.ItemTooltipEvent; - -public interface TooltipListener { - void onTooltip(ItemTooltipEvent event); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/WorldRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/WorldRenderListener.java deleted file mode 100644 index c4b68c52..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/WorldRenderListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.listener; - -public interface WorldRenderListener { - void drawWorld(float partialTicks); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java deleted file mode 100644 index beeff007..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.text; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MEditableAColor; -import kr.syeyoung.dungeonsguide.gui.elements.MPanelScaledGUI; -import kr.syeyoung.dungeonsguide.gui.elements.MScrollablePanel; -import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class PanelTextParameterConfig extends MPanel { - - private final StyledTextProvider feature; - - private final MEditableAColor currentColor; - private final MEditableAColor backgroundColor; - private final MToggleButton shadow; - - private MScrollablePanel mScrollablePanel; - private MPanelScaledGUI rendering; - - @Override - public void onBoundsUpdate() { - } - @Override - public Dimension getPreferredSize() { - return new Dimension(400, getPanelBound().height + 20); - } - - public PanelTextParameterConfig(final StyledTextProvider feature) { - this.feature = feature; - setBackgroundColor(new Color(38, 38, 38, 255)); - - currentColor = new MEditableAColor(); - currentColor.setColor(new AColor(0xff555555, true)); - currentColor.setEnableEdit(false); - currentColor.setSize(new Dimension(15, 10)); - currentColor.setOnUpdate(new Runnable() { - @Override - public void run() { - for (String se:selected) - feature.getStylesMap().get(se).setColor(currentColor.getColor()); - } - }); - add(currentColor); - backgroundColor = new MEditableAColor(); - backgroundColor.setColor(new AColor(0xff555555, true)); - backgroundColor.setEnableEdit(false); - backgroundColor.setSize(new Dimension(15, 10)); - backgroundColor.setOnUpdate(new Runnable() { - @Override - public void run() { - for (String se:selected) - feature.getStylesMap().get(se).setBackground(backgroundColor.getColor()); - } - }); - add(backgroundColor); - shadow = new MToggleButton(); - shadow.setSize(new Dimension(20, 10)); - shadow.setOnToggle(new Runnable() { - @Override - public void run() { - for (String se:selected) - feature.getStylesMap().get(se).setShadow(shadow.isEnabled()); - } - }); - add(shadow); - - mScrollablePanel = new MScrollablePanel(3); - mScrollablePanel.setHideScrollBarWhenNotNecessary(true); - add(mScrollablePanel); - - mScrollablePanel.add(rendering = new MPanelScaledGUI() { - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); - - List texts = feature.getDummyText(); - Map styles = feature.getStylesMap(); - List calc = StyledTextRenderer.drawTextWithStylesAssociated(texts, 0,0, getEffectiveDimension().width, styles, StyledTextRenderer.Alignment.LEFT); - boolean bool =scissor.contains(absMousex, absMousey); - for (StyledTextRenderer.StyleTextAssociated calc3: calc) { - if (selected.contains(calc3.getStyledText().getGroup())) { - Gui.drawRect(calc3.getRectangle().x, calc3.getRectangle().y, calc3.getRectangle().x + calc3.getRectangle().width, calc3.getRectangle().y + calc3.getRectangle().height, 0x4244A800); - } else if (bool && calc3.getRectangle().contains(relMousex0, relMousey0)) { - for (StyledTextRenderer.StyleTextAssociated calc2 : calc) { - if (calc2.getStyledText().getGroup().equals(calc3.getStyledText().getGroup())) - Gui.drawRect(calc2.getRectangle().x, calc2.getRectangle().y, calc2.getRectangle().x + calc2.getRectangle().width, calc2.getRectangle().y + calc2.getRectangle().height, 0x55777777); - } - } - } - } - - - private int lastX; - private int lastY; - private boolean dragStart = false; - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - List texts = feature.getDummyText(); - Map styles = feature.getStylesMap(); - boolean existed = selected.isEmpty(); - boolean found = false; - List calc = StyledTextRenderer.calculate(texts, 0,0, styles); - for (StyledTextRenderer.StyleTextAssociated calc3: calc) { - if (calc3.getRectangle().contains(relMouseX, relMouseY)) { - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - if (!selected.contains(calc3.getStyledText().getGroup())) - selected.add(calc3.getStyledText().getGroup()); - else - selected.remove(calc3.getStyledText().getGroup()); - } else { - selected.clear(); - selected.add(calc3.getStyledText().getGroup()); - } - found = true; - } - } - - if (!found && !(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) && parent.getLastAbsClip().contains(absMouseX * getScale(), absMouseY* getScale())) { - selected.clear(); - dragStart = true; - lastX = absMouseX; - lastY = absMouseY; - } - currentColor.setEnableEdit(selected.size() != 0); - PanelTextParameterConfig.this.backgroundColor.setEnableEdit(selected.size() != 0); - if (existed != selected.isEmpty()) { - if (selected.size() != 0) { - currentColor.setColor(styles.get(selected.iterator().next()).getColor()); - PanelTextParameterConfig.this.backgroundColor.setColor(styles.get(selected.iterator().next()).getBackground()); - shadow.setEnabled(styles.get(selected.iterator().next()).isShadow()); - } else { - currentColor.setColor(new AColor(0xff555555, true)); - PanelTextParameterConfig.this.backgroundColor.setColor(new AColor(0xff555555, true)); - shadow.setEnabled(false); - } - } - - if (selected.size() == 1) { - currentColor.setColor(styles.get(selected.iterator().next()).getColor()); - PanelTextParameterConfig.this.backgroundColor.setColor(styles.get(selected.iterator().next()).getBackground()); - shadow.setEnabled(styles.get(selected.iterator().next()).isShadow()); - } - } - - @Override - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - dragStart = false; - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - if (dragStart) { - int dx= absMouseX - lastX; - int dy= absMouseY - lastY; - int actualOFFX = (int) (dx / getScale()); - int actualOFFY = (int) (dy / getScale()); - lastX =(int) (actualOFFX * getScale())+lastX; - lastY =(int) (actualOFFY * getScale())+lastY; - mScrollablePanel.getScrollBarX().addToCurrent(-actualOFFX); - mScrollablePanel.getScrollBarY().addToCurrent(-actualOFFY); - } - } - - @Override - public Dimension getPreferredSize() { - List calc = StyledTextRenderer.calculate(feature.getDummyText(), 0,0, feature.getStylesMap()); - int w = 0, h = 0; - for (StyledTextRenderer.StyleTextAssociated styleTextAssociated : calc) { - int endX = styleTextAssociated.getRectangle().x + styleTextAssociated.getRectangle().width; - int endY = styleTextAssociated.getRectangle().y + styleTextAssociated.getRectangle().height; - if (endX > w) w = endX; - if (endY > h) h = endY; - } - return new Dimension((int) (w * getScale()),(int) (h * getScale())); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(new Point(0,0), getPreferredSize())); - } - - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if ( parent.getLastAbsClip().contains(absMouseX * getScale(), absMouseY* getScale())) { - double scale = rendering.getScale(); - if (scrollAmount > 0) { - scale += 0.1; - } else if (scrollAmount < 0) { - scale -= 0.1; - } - if (scale < 0.1) scale = 0.1f; - if (scale > 5) scale = 5.0f; - rendering.setScale(scale); - mScrollablePanel.setBounds(new Rectangle(new Point(5,5),getPanelBound())); - } - } - }); - - - } - - private final Set selected = new HashSet(); - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - - GlStateManager.pushMatrix(); - - Dimension dim = getPanelBound(); - int width = dim.width, height = dim.height; - Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f)); - Gui.drawRect(4,4,width+6, height+6, 0xFF222222); - Gui.drawRect(5,5,width+5, height+5, RenderUtils.blendAlpha(0x141414, 0.15f)); - - - GlStateManager.translate(5, height + 7, 0); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Press Shift to multi-select", 0, 0, 0xFFBFBFBF); - GlStateManager.popMatrix(); - - GlStateManager.pushMatrix(); - GlStateManager.translate(width + 15, 5, 0); - GlStateManager.pushMatrix(); - fr.drawString("Selected Groups: "+selected, 0, 0, 0xFFBFBFBF); - GlStateManager.popMatrix(); - fr.drawString("Text Color: ", 0, 10, 0xFFFFFFFF); - fr.drawString("Background Color: ", 0, 20, 0xFFFFFFFF); - fr.drawString("Shadow: ", 0, 39, 0xFFFFFFFF); - - GlStateManager.popMatrix(); - } - - private Dimension getPanelBound(){ -// return new Dimension((getBounds().width-25)/2, 100); - return new Dimension(150,100); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - - Dimension dim = getPanelBound(); - currentColor.setBounds(new Rectangle(75+dim.width , 14, 15, 10)); - backgroundColor.setBounds(new Rectangle(110+dim.width , 24, 15, 10)); - shadow.setBounds(new Rectangle(75+dim.width , 43, 30, 10)); - mScrollablePanel.setBounds(new Rectangle(5,5,dim.width,dim.height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java deleted file mode 100644 index 10f9b06d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledText.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.text; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class StyledText { - private String text; - private String group; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java deleted file mode 100644 index f3eba3a9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.text; - -import java.util.List; -import java.util.Map; - -public interface StyledTextProvider { - List getDummyText(); - List getText(); - - List getStyles(); - Map getStylesMap(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java deleted file mode 100644 index 9ebc138b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.text; - -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraftforge.fml.relauncher.ReflectionHelper; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class StyledTextRenderer { - - public static enum Alignment { - LEFT, CENTER, RIGHT - } - - private static final Method renderChar = ReflectionHelper.findMethod(FontRenderer.class, null, new String[] {"renderChar", "func_181559_a"}, char.class, boolean.class); - private static final Method doDraw = ReflectionHelper.findMethod(FontRenderer.class, null, new String[] {"doDraw"}, float.class); - private static final Field posX = ReflectionHelper.findField(FontRenderer.class, "posX", "field_78295_j"); - private static final Field posY = ReflectionHelper.findField(FontRenderer.class, "posY", "field_78296_k"); - - - public static List drawTextWithStylesAssociated(List texts, int x, int y,int width, Map styleMap, Alignment alignment) { - String[] totalLines = (texts.stream().map( a-> a.getText()).collect(Collectors.joining())+" ").split("\n"); - - - GlStateManager.enableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - - int currentLine = 0; - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine])); - int currY = y; - int maxHeightForLine = 0; - List associateds = new ArrayList(); - for (StyledText st : texts) { - TextStyle ts = styleMap.get(st.getGroup()); - String[] lines = st.getText().split("\n"); - for (int i = 0; i < lines.length; i++) { - String str = lines[i]; - Dimension d = null; - try { - d = drawFragmentText(fr, str, ts, currX, currY, false); - } catch (InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); - } - associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height))); - currX += d.width; - if (maxHeightForLine < d.height) - maxHeightForLine = d.height; - - if (i+1 != lines.length) { - currY += maxHeightForLine ; - currentLine++; - currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine])); - maxHeightForLine = 0; - } - } - if (st.getText().endsWith("\n")) { - currY += maxHeightForLine; - currentLine++; - currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine])); - maxHeightForLine = 0; - } - } - return associateds; - } - - public static List calculate(List texts, int x, int y, Map styleMap) { - int currX = x; - int currY = y; - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int maxHeightForLine = 0; - List associateds = new ArrayList(); - for (StyledText st : texts) { - TextStyle ts = styleMap.get(st.getGroup()); - String[] lines = st.getText().split("\n"); - for (int i = 0; i < lines.length; i++) { - String str = lines[i]; - Dimension d = null; - try { - d = drawFragmentText(fr, str, ts, currX, currY, true); - } catch (InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); - } - associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height))); - currX += d.width; - if (maxHeightForLine < d.height) - maxHeightForLine = d.height; - - if (i+1 != lines.length) { - currY += maxHeightForLine; - currX = x; - maxHeightForLine = 0; - } - } - if (st.getText().endsWith("\n")) { - currY += maxHeightForLine; - currX = x; - maxHeightForLine = 0; - } - } - return associateds; - } - - @Data - @AllArgsConstructor - public static class StyleTextAssociated { - private StyledText styledText; - private Rectangle rectangle; - } - - private static Dimension drawFragmentText(FontRenderer fr, String content, TextStyle style, int x, int y, boolean stopDraw) throws InvocationTargetException, IllegalAccessException { - if (stopDraw) - return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT); - - int bgColor = RenderUtils.getColorAt(x,y, style.getBackground()); - if ((bgColor & 0xFF000000) != 0) - Gui.drawRect(x,y, x+fr.getStringWidth(content), y + fr.FONT_HEIGHT, bgColor); - - - posX.set(fr, x+1); - posY.set(fr, y+1); - - if (style.isShadow()) { - char[] charArr = content.toCharArray(); - float width = 0; - for (int i = 0; i < charArr.length; i++) { - int color = RenderUtils.getColorAt(x + width, y, style.getColor()); - color = (color & 16579836) >> 2 | color & -16777216; - - width +=renderChar(fr, charArr[i], color,true, false, false, false); - } - } - posX.set(fr, x); - posY.set(fr, y); - { - char[] charArr = content.toCharArray(); - float width = 0; - for (int i = 0; i < charArr.length; i++) { - int color = RenderUtils.getColorAt(x + width, y, style.getColor()); - - width +=renderChar(fr, charArr[i], color, false, false, false, false); - } - return new Dimension((int) width, fr.FONT_HEIGHT); - } - } - - private static float renderChar(FontRenderer fr, char character, int color, boolean shadow, boolean randomStyle, boolean boldStyle, boolean italicStyle) throws InvocationTargetException, IllegalAccessException { - RenderUtils.GL_SETCOLOR(color); - int j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(character); - - if (randomStyle && j != -1) - { - int k = fr.getCharWidth(character); - char c1; - - while (true) - { - j = fr.fontRandom.nextInt("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".length()); - c1 = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".charAt(j); - - if (k == fr.getCharWidth(c1)) - { - break; - } - } - - character = c1; - } - - float f1 = j == -1 || fr.getUnicodeFlag() ? 0.5f : 1f; - boolean flag = (character == 0 || j == -1 || fr.getUnicodeFlag()) && shadow; - - if (flag) - { - posX.set(fr,(float) posX.get(fr) - f1); - posY.set(fr,(float) posY.get(fr) - f1); - } - - float f = (float) renderChar.invoke(fr, character, italicStyle); - - if (flag) - { - posX.set(fr,(float) posX.get(fr) + f1); - posY.set(fr,(float) posY.get(fr) + f1); - } - - if (boldStyle) - { - posX.set(fr,(float) posX.get(fr) + f1); - - if (flag) - { - posX.set(fr,(float) posX.get(fr) - f1); - posY.set(fr,(float) posY.get(fr) - f1); - } - - renderChar.invoke(fr, character, italicStyle); - posX.set(fr,(float) posX.get(fr) - f1); - - if (flag) - { - posX.set(fr,(float) posX.get(fr) + f1); - posY.set(fr,(float) posY.get(fr) + f1); - } - - ++f; - } - doDraw.invoke(fr, f); - - return f; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java deleted file mode 100644 index b0cda000..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.text; - -import com.google.common.base.Supplier; -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; -import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; -import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; -import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.features.FeatureParameter; -import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MPassiveLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; - -import java.util.*; -import java.util.List; - -public abstract class TextHUDFeature extends GuiFeature implements StyledTextProvider { - protected TextHUDFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { - super(category, name, description, key, keepRatio, width, height); - this.parameters.put("textStylesNEW", new FeatureParameter>("textStylesNEW", "", "", new ArrayList(), "list_textStyle")); - this.parameters.put("alignment", new FeatureParameter("alignment", "Alignment", "Alignment", "LEFT", "string")); - this.parameters.put("scale", new FeatureParameter("scale", "Scale", "Scale", 1.0f, "float")); - } - - @Override - public void drawHUD(float partialTicks) { - if (isHUDViewable()) { - List asd = getText(); - - double scale = 1; - if (doesScaleWithHeight()) { - FontRenderer fr = getFontRenderer(); - scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); - } else { - scale = this.getParameter("scale").getValue(); - } - GlStateManager.scale(scale, scale, 0); - StyledTextRenderer.drawTextWithStylesAssociated(asd, 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(), - StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.getParameter("alignment").getValue())); - } - } - - public boolean doesScaleWithHeight() { - return true; - } - - @Override - public void drawDemo(float partialTicks) { - List asd = getDummyText(); - double scale = 1; - if (doesScaleWithHeight()) { - FontRenderer fr = getFontRenderer(); - scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); - } else { - scale = this.getParameter("scale").getValue(); - } - GlStateManager.scale(scale, scale, 0); - - StyledTextRenderer.drawTextWithStylesAssociated(asd, 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(), - StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.getParameter("alignment").getValue())); - } - - public int countLines(List texts) { - StringBuilder things = new StringBuilder(); - for (StyledText text : texts) { - things.append(text.getText()); - } - String things2 = things.toString().trim(); - int lines = 1; - for (char c : things2.toCharArray()) { - if (c == '\n') lines++; - } - return lines; - } - - public abstract boolean isHUDViewable(); - - public abstract List getUsedTextStyle(); - public List getDummyText() { - return getText(); - } - public abstract List getText(); - - public List getStyles() { - return this.>getParameter("textStylesNEW").getValue(); - } - private Map stylesMap; - public Map getStylesMap() { - if (stylesMap == null) { - List styles = getStyles(); - Map res = new HashMap(); - for (TextStyle ts : styles) { - res.put(ts.getGroupName(), ts); - } - for (String str : getUsedTextStyle()) { - if (!res.containsKey(str)) - res.put(str, new TextStyle(str, new AColor(0xffffffff, true), new AColor(0x00777777, true), false)); - } - stylesMap = res; - } - return stylesMap; - } - - - @Override - public String getEditRoute(RootConfigPanel rootConfigPanel) { - ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { - @Override - public MPanel get() { - - MFeatureEdit featureEdit = new MFeatureEdit(TextHUDFeature.this, rootConfigPanel); - featureEdit.addParameterEdit("textStyleNEW", new PanelTextParameterConfig(TextHUDFeature.this)); - - StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.getParameter("alignment").getValue()); - MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name()); - mStringSelectionButton.setOnUpdate(() -> { - TextHUDFeature.this.getParameter("alignment").setValue(mStringSelectionButton.getSelected()); - }); - featureEdit.addParameterEdit("alignment", new MParameterEdit(TextHUDFeature.this, TextHUDFeature.this.getParameter("alignment"), rootConfigPanel, mStringSelectionButton, (a) -> false)); - - for (FeatureParameter parameter: getParameters()) { - if (parameter.getKey().equals("textStylesNEW")) continue; - if (parameter.getKey().equals("alignment")) continue; - featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(TextHUDFeature.this, parameter, rootConfigPanel)); - } - return featureEdit; - } - }); - return "base." + getKey() ; - } - - @Override - public List getTooltipForEditor(GuiGuiLocationConfig guiGuiLocationConfig) { - List mPanels = super.getTooltipForEditor(guiGuiLocationConfig); - StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(this.getParameter("alignment").getValue()); - MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name()); - mStringSelectionButton.setOnUpdate(() -> { - TextHUDFeature.this.getParameter("alignment").setValue(mStringSelectionButton.getSelected()); - }); - - mPanels.add(new MPassiveLabelAndElement("Alignment", mStringSelectionButton)); - if (!doesScaleWithHeight()) { - mPanels.add(new MPassiveLabelAndElement("Scale", new MFloatSelectionButton(TextHUDFeature.this.getParameter("scale").getValue()) {{ - setOnUpdate(() ->{ - TextHUDFeature.this.getParameter("scale").setValue(this.getData()); - }); } - })); - } - - return mPanels; - } - - @Override - public void onParameterReset() { - stylesMap = null; - } - - @Override - public void loadConfig(JsonObject jsonObject) { - super.loadConfig(jsonObject); - StyledTextRenderer.Alignment alignment; - try { - alignment = StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.getParameter("alignment").getValue()); - } catch (Exception e) {alignment = StyledTextRenderer.Alignment.LEFT;} - TextHUDFeature.this.getParameter("alignment").setValue(alignment.name()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java deleted file mode 100644 index 7af96457..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextStyle.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.features.text; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.awt.*; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class TextStyle { - private String groupName; - private AColor color; - private AColor background; - private boolean shadow = false; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/GameSDK.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/GameSDK.java deleted file mode 100644 index 39885ab9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/GameSDK.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk; - -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.Platform; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.PointerByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.GameSDKTypeMapper; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.*; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.*; -import kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct.IDiscordActivityEvents; -import kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct.IDiscordActivityManager; -import kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct.IDiscordCore; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.*; -import lombok.Getter; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.Collections; - -public class GameSDK { - @Getter - private static NativeGameSDK nativeGameSDK; - - static { - try { - if (System.getProperty("dg.safe") == null) extractLibrary(); - } catch (IOException e) { - e.printStackTrace(); - } - } - public static void extractLibrary() throws IOException { - String libName = System.mapLibraryName("discord_game_sdk"); - String dir = ""; - switch(Platform.getOSType()) { - case Platform.MAC: - dir = "darwin"; - break; - case Platform.LINUX: - dir = "linux"; - break; - case Platform.WINDOWS: - if (Platform.is64Bit()) dir = "win-x64"; - else dir = "win-x86"; - break; - default: - throw new IllegalStateException("Unsupported OS Type"); - } - - String resourceLoc = "/gamesdk/"+dir+"/"+libName; - File targetExtractionPath = new File("native/"+libName); - targetExtractionPath.getParentFile().mkdirs(); - try (InputStream is = GameSDK.class.getResourceAsStream(resourceLoc)) { - Files.copy(is, targetExtractionPath.toPath(), StandardCopyOption.REPLACE_EXISTING); - targetExtractionPath.deleteOnExit(); - } - - nativeGameSDK = (NativeGameSDK) Native.loadLibrary(targetExtractionPath.getAbsolutePath(), NativeGameSDK.class, - Collections.singletonMap(Library.OPTION_TYPE_MAPPER, GameSDKTypeMapper.INSTANCE)); - } - - public static void writeString(byte[] bts, String str) { - System.arraycopy(str.getBytes(), 0, bts, 0, str.getBytes().length); - bts[str.getBytes().length] = 0; - } - public static String readString(byte[] bts) { - int i; - for (i = 0; i < bts.length && bts[i] != 0; i++); - byte[] asdasd = new byte[i]; - System.arraycopy(bts, 0, asdasd, 0, i); - return new String(asdasd); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/GameSDKTypeMapper.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/GameSDKTypeMapper.java deleted file mode 100644 index 1d8a4ef8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/GameSDKTypeMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna; - -import com.sun.jna.DefaultTypeMapper; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.*; - -public class GameSDKTypeMapper extends DefaultTypeMapper { - public static final GameSDKTypeMapper INSTANCE = new GameSDKTypeMapper(); - private GameSDKTypeMapper() { - addTypeConverter(EDiscordResult.class, new EDiscordResult.EDiscordResultTypeConverter()); - addTypeConverter(EDiscordCreateFlags.class, new EDiscordCreateFlags.EDiscordCreateFlagsTypeConverter()); - addTypeConverter(EDiscordLogLevel.class, new EDiscordLogLevel.EDiscordLogLevelTypeConverter()); - addTypeConverter(EDiscordUserFlag.class, new EDiscordUserFlag.EDiscordUserFlagTypeConverter()); - addTypeConverter(EDiscordPremiumType.class, new EDiscordPremiumType.EDiscordPremiumTypeTypeConverter()); - addTypeConverter(EDiscordImageType.class, new EDiscordImageType.EDiscordImageTypeTypeConverter()); - addTypeConverter(EDiscordActivityType.class, new EDiscordActivityType.EDiscordActivityTypeTypeConverter()); - addTypeConverter(EDiscordActivityActionType.class, new EDiscordActivityActionType.EDiscordActivityActionTypeTypeConverter()); - addTypeConverter(EDiscordActivityJoinRequestReply.class, new EDiscordActivityJoinRequestReply.EDiscordActivityJoinRequestReplyTypeConverter()); - addTypeConverter(EDiscordStatus.class, new EDiscordStatus.EDiscordStatusTypeConverter()); - addTypeConverter(EDiscordRelationshipType.class, new EDiscordRelationshipType.EDiscordRelationshipTypeTypeConverter()); - addTypeConverter(EDiscordLobbyType.class, new EDiscordLobbyType.EDiscordLobbyTypeTypeConverter()); - addTypeConverter(EDiscordLobbySearchComparison.class, new EDiscordLobbySearchComparison.EDiscordLobbySearchComparisonTypeConverter()); - addTypeConverter(EDiscordLobbySearchCast.class, new EDiscordLobbySearchCast.EDiscordLobbySearchCastTypeConverter()); - addTypeConverter(EDiscordLobbySearchDistance.class, new EDiscordLobbySearchDistance.EDiscordLobbySearchDistanceTypeConverter()); - addTypeConverter(EDiscordEntitlementType.class, new EDiscordEntitlementType.EDiscordEntitlementTypeTypeConverter()); - addTypeConverter(EDiscordSkuType.class, new EDiscordSkuType.EDiscordSkuTypeTypeConverter()); - addTypeConverter(EDiscordInputModeType.class, new EDiscordInputModeType.EDiscordInputModeTypeTypeConverter()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/NativeGameSDK.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/NativeGameSDK.java deleted file mode 100644 index 59fc0339..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/NativeGameSDK.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna; - -import com.sun.jna.Callback; -import com.sun.jna.Library; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.PointerByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordCreateParams; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordVersion; - -public interface NativeGameSDK extends Library { - - public static final int DISCORD_VERSION = 2; - public static final int DISCORD_APPLICATION_MANAGER_VERSION = 1; - public static final int DISCORD_USER_MANAGER_VERSION = 1; - public static final int DISCORD_IMAGE_MANAGER_VERSION = 1; - public static final int DISCORD_ACTIVITY_MANAGER_VERSION = 1; - public static final int DISCORD_RELATIONSHIP_MANAGER_VERSION = 1; - public static final int DISCORD_LOBBY_MANAGER_VERSION = 1; - public static final int DISCORD_NETWORK_MANAGER_VERSION = 1; - public static final int DISCORD_OVERLAY_MANAGER_VERSION = 1; - public static final int DISCORD_STORAGE_MANAGER_VERSION = 1; - public static final int DISCORD_STORE_MANAGER_VERSION = 1; - public static final int DISCORD_VOICE_MANAGER_VERSION = 1; - public static final int DISCORD_ACHIEVEMENT_MANAGER_VERSION = 1; - - EDiscordResult DiscordCreate(DiscordVersion version, DiscordCreateParams params, PointerByReference result); // result is double pointer of IDiscordCore - - interface DiscordCallback extends Callback { - void callback(Pointer callbackData, EDiscordResult result); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivity.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivity.java deleted file mode 100644 index d257b414..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivity.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.Int64; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - - -public class DiscordActivity extends DiscordStruct { - public EDiscordActivityType activityType = EDiscordActivityType.DiscordActivityType_Playing; - public Int64 applicationId = new Int64(); - public byte[] name = new byte[128]; - public byte[] state = new byte[128]; - public byte[] details = new byte[128]; - public DiscordActivityTimestamps timestamps; - public DiscordActivityAssets assets; - public DiscordActivityParty party; - public DiscordActivitySecrets secrets; - public boolean instance; - public DiscordActivity() {super();} public DiscordActivity(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordActivity implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordActivity implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("activityType", "applicationId", "name", "state", "details", "timestamps", "assets", "party", "secrets", "instance"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityAssets.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityAssets.java deleted file mode 100644 index 03b64f46..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityAssets.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; - -import java.util.Arrays; -import java.util.List; - - -public class DiscordActivityAssets extends DiscordStruct{ - public byte[] large_image = new byte[128]; - public byte[] large_text = new byte[128]; - public byte[] small_image = new byte[128]; - public byte[] small_text = new byte[128]; - public DiscordActivityAssets() {super();}public DiscordActivityAssets(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordActivityAssets implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordActivityAssets implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("large_image", "large_text", "small_image", "small_text"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityParty.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityParty.java deleted file mode 100644 index b9a20db3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityParty.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; - -import java.util.Arrays; -import java.util.List; - - -public class DiscordActivityParty extends DiscordStruct { - public byte[] id = new byte[128]; - public DiscordPartySize discordActivityParty; - public DiscordActivityParty() {super();} public DiscordActivityParty(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordActivityParty implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordActivityParty implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("id", "discordActivityParty"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivitySecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivitySecrets.java deleted file mode 100644 index 2975f97f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivitySecrets.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; - -import java.util.Arrays; -import java.util.List; - - -public class DiscordActivitySecrets extends DiscordStruct { - public byte[] match = new byte[128]; - public byte[] join = new byte[128]; - public byte[] spectate = new byte[128]; - public DiscordActivitySecrets() {super();} public DiscordActivitySecrets(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordActivitySecrets implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordActivitySecrets implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("match", "join", "spectate"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityTimestamps.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityTimestamps.java deleted file mode 100644 index 4765ffb9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordActivityTimestamps.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordTimestamp; - -import java.util.Arrays; -import java.util.List; - -public class DiscordActivityTimestamps extends DiscordStruct { - public DiscordTimestamp start = new DiscordTimestamp(); - public DiscordTimestamp end = new DiscordTimestamp(); - public DiscordActivityTimestamps() {super();} public DiscordActivityTimestamps(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordActivityTimestamps implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordActivityTimestamps implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("start", "end"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordCreateParams.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordCreateParams.java deleted file mode 100644 index 10f1ba3d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordCreateParams.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct.*; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordClientID; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordVersion; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt64; - -import java.util.Arrays; -import java.util.List; - -public class DiscordCreateParams extends DiscordStruct { public DiscordCreateParams() {super();} public DiscordCreateParams(Pointer pointer) {super(pointer);} - public DiscordClientID client_id = new DiscordClientID(); - public UInt64 flags = new UInt64(); - public Pointer events; // void* - public Pointer event_data; // void* - public Pointer application_events; - public DiscordVersion application_version = new DiscordVersion(NativeGameSDK.DISCORD_APPLICATION_MANAGER_VERSION); - public IDiscordUserEvents.ByReference user_events; - public DiscordVersion user_version= new DiscordVersion(NativeGameSDK.DISCORD_USER_MANAGER_VERSION); - public Pointer image_events;// void* - public DiscordVersion image_version= new DiscordVersion(NativeGameSDK.DISCORD_IMAGE_MANAGER_VERSION); - public IDiscordActivityEvents.ByReference activity_events; - public DiscordVersion activity_version= new DiscordVersion(NativeGameSDK.DISCORD_ACTIVITY_MANAGER_VERSION); - public IDiscordRelationshipEvents.ByReference relationship_events; - public DiscordVersion relationship_version= new DiscordVersion(NativeGameSDK.DISCORD_RELATIONSHIP_MANAGER_VERSION); - public IDiscordLobbyEvents.ByReference lobby_events; - public DiscordVersion lobby_version= new DiscordVersion(NativeGameSDK.DISCORD_LOBBY_MANAGER_VERSION); - public IDiscordNetworkEvents.ByReference network_events; - public DiscordVersion network_version= new DiscordVersion(NativeGameSDK.DISCORD_NETWORK_MANAGER_VERSION); - public IDiscordOverlayEvents.ByReference overlay_events; - public DiscordVersion overlay_version= new DiscordVersion(NativeGameSDK.DISCORD_OVERLAY_MANAGER_VERSION); - public Pointer storage_events;// void* - public DiscordVersion storage_version= new DiscordVersion(NativeGameSDK.DISCORD_STORAGE_MANAGER_VERSION); - public IDiscordStoreEvents.ByReference store_events; - public DiscordVersion store_version= new DiscordVersion(NativeGameSDK.DISCORD_STORE_MANAGER_VERSION); - public IDiscordVoiceEvents.ByReference voice_events; - public DiscordVersion voice_version= new DiscordVersion(NativeGameSDK.DISCORD_VOICE_MANAGER_VERSION); - public IDiscordAchievementEvents.ByReference achievement_events; - public DiscordVersion achievement_version= new DiscordVersion(NativeGameSDK.DISCORD_ACHIEVEMENT_MANAGER_VERSION); - - public static class ByReference extends DiscordCreateParams implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordCreateParams implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("client_id", "flags", "events", "event_data", "application_events", "application_version", "user_events", - "user_version", "image_events", "image_version", "activity_events", "activity_version", "lobby_events", "lobby_version", - "network_events", "network_version", "overlay_events", "overlay_version", "storage_events", "storage_version", "store_events", - "store_version", "voice_events", "voice_version", "achievement_events", "achievement_version"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordEntitlement.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordEntitlement.java deleted file mode 100644 index 6e0f29ac..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordEntitlement.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordEntitlementType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import java.util.Arrays; -import java.util.List; - -public class DiscordEntitlement extends DiscordStruct { - public DiscordSnowflake id = new DiscordSnowflake(); - public EDiscordEntitlementType type = EDiscordEntitlementType.DiscordEntitlementType_Purchase; - public DiscordSnowflake sku_id = new DiscordSnowflake(); - public DiscordEntitlement() {super();} public DiscordEntitlement(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordEntitlement implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordEntitlement implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("id", "type", "sku_id"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordFileStat.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordFileStat.java deleted file mode 100644 index a7e38b37..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordFileStat.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; - -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt64; - -import java.util.Arrays; -import java.util.List; - -public class DiscordFileStat extends DiscordStruct { - public byte[] filename = new byte[260]; - public UInt64 size = new UInt64(); - public UInt64 last_modified = new UInt64(); - public DiscordFileStat() {super();} public DiscordFileStat(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordFileStat implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordFileStat implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("filename", "size", "last_modified"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordImageDimensions.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordImageDimensions.java deleted file mode 100644 index d3247b07..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordImageDimensions.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; - -import java.util.Arrays; -import java.util.List; - -public class DiscordImageDimensions extends DiscordStruct { - public UInt32 width = new UInt32(); - public UInt32 height = new UInt32(); - public DiscordImageDimensions() {super();} public DiscordImageDimensions(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordImageDimensions implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) { super(pointer);}} - public static class ByValue extends DiscordImageDimensions implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) { super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("width", "height"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordImageHandle.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordImageHandle.java deleted file mode 100644 index 2ca33f46..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordImageHandle.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordImageType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.Int64; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; - -import java.util.Arrays; -import java.util.List; - -public class DiscordImageHandle extends DiscordStruct { - public EDiscordImageType type = EDiscordImageType.DiscordImageType_User; - public Int64 id = new Int64(); - public UInt32 size = new UInt32(); - public DiscordImageHandle() {super();} public DiscordImageHandle(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordImageHandle implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordImageHandle implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("type", "id", "size"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordInputMode.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordInputMode.java deleted file mode 100644 index 8a69f53a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordInputMode.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordInputModeType; - -import java.util.Arrays; -import java.util.List; - - -public class DiscordInputMode extends DiscordStruct { - public EDiscordInputModeType type = EDiscordInputModeType.DiscordInputModeType_PushToTalk; - public byte[] shortcut = new byte[256]; - public DiscordInputMode() {super();} public DiscordInputMode(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordInputMode implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordInputMode implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("type", "shortcut"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordLobby.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordLobby.java deleted file mode 100644 index 18453004..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordLobby.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordLobbyType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; - -import java.util.Arrays; -import java.util.List; - -public class DiscordLobby extends DiscordStruct { - public DiscordSnowflake id = new DiscordSnowflake(); - public EDiscordLobbyType type = EDiscordLobbyType.DiscordLobbyType_Private; - public DiscordSnowflake owner_id = new DiscordSnowflake(); - public byte[] secret = new byte[128]; - public UInt32 capacity = new UInt32(); - public boolean locked; - public DiscordLobby() {super();} public DiscordLobby(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordLobby implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordLobby implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("id", "type", "owner_id", "secret", "capacity", "locked"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordOAuth2Token.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordOAuth2Token.java deleted file mode 100644 index f870f830..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordOAuth2Token.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordTimestamp; - -import java.util.Arrays; -import java.util.List; - - -public class DiscordOAuth2Token extends DiscordStruct { - public byte[] access_token = new byte[128]; - public byte[] scopes = new byte[1024]; - public DiscordTimestamp expires = new DiscordTimestamp(); - public DiscordOAuth2Token() {super();} public DiscordOAuth2Token(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordOAuth2Token implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordOAuth2Token implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("access_token", "scopes", "expires"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordPartySize.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordPartySize.java deleted file mode 100644 index 43c40723..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordPartySize.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.Int32; - -import java.util.Arrays; -import java.util.List; - -public class DiscordPartySize extends DiscordStruct{ - public Int32 current_size = new Int32(); - public Int32 max_size = new Int32(); - public DiscordPartySize() {super();} public DiscordPartySize(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordPartySize implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordPartySize implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("current_size", "max_size"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordPresence.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordPresence.java deleted file mode 100644 index 4e12f175..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordPresence.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordStatus; - -import java.util.Arrays; -import java.util.List; - -public class DiscordPresence extends DiscordStruct { - public EDiscordStatus status = EDiscordStatus.DiscordStatus_Offline; - public DiscordActivity activity; - public DiscordPresence() {super();} public DiscordPresence(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordPresence implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordPresence implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("status", "activity"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordRelationship.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordRelationship.java deleted file mode 100644 index 03cbae4a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordRelationship.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordRelationshipType; - -import java.util.Arrays; -import java.util.List; - -public class DiscordRelationship extends DiscordStruct { - public EDiscordRelationshipType type = EDiscordRelationshipType.DiscordRelationshipType_None; - public DiscordUser user; - public DiscordPresence presence; - public DiscordRelationship() {super();} public DiscordRelationship(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordRelationship implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordRelationship implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("type", "user", "presence"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordSku.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordSku.java deleted file mode 100644 index 2e9aaf1d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordSku.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordSkuType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import java.util.Arrays; -import java.util.List; - - -public class DiscordSku extends DiscordStruct { - public DiscordSnowflake id = new DiscordSnowflake(); - public EDiscordSkuType type = EDiscordSkuType.DiscordSkuType_Application; - public byte[] name = new byte[256]; - public DiscordSkuPrice discordSkuPrice; - public DiscordSku() {super();} public DiscordSku(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordSku implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordSku implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("id", "type", "name", "discordSkuPrice"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordSkuPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordSkuPrice.java deleted file mode 100644 index 6eea0924..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordSkuPrice.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; - -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; - -import java.util.Arrays; -import java.util.List; - -public class DiscordSkuPrice extends DiscordStruct { - public UInt32 amount = new UInt32(); - public byte[] currency = new byte[16]; - public DiscordSkuPrice() {super();} public DiscordSkuPrice(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordSkuPrice implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordSkuPrice implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("amount", "currency"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordStruct.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordStruct.java deleted file mode 100644 index f6a19d82..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordStruct.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Library; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.TypeMapper; -import kr.syeyoung.dungeonsguide.gamesdk.jna.GameSDKTypeMapper; - -import java.util.Collections; -import java.util.Map; - -public abstract class DiscordStruct extends Structure { - public static final Map OPTIONS = Collections.singletonMap(Library.OPTION_TYPE_MAPPER, GameSDKTypeMapper.INSTANCE); - protected DiscordStruct() { - super(GameSDKTypeMapper.INSTANCE); - } - protected DiscordStruct(Pointer p) {super(p); read();} -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordUser.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordUser.java deleted file mode 100644 index b20d18c2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordUser.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import lombok.Getter; -import lombok.Setter; - -import java.util.Arrays; -import java.util.List; - -public class DiscordUser extends DiscordStruct { - public DiscordSnowflake id = new DiscordSnowflake(); - public byte[] username = new byte[256]; - public byte[] discriminator = new byte[8]; - public byte[] avatar = new byte[128]; - public boolean bot; - public DiscordUser() {super();} public DiscordUser(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordUser implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordUser implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("id", "username", "discriminator", "avatar", "bot"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordUserAchievement.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordUserAchievement.java deleted file mode 100644 index c12dcf56..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/datastruct/DiscordUserAchievement.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct; - -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; - -import java.util.Arrays; -import java.util.List; - -public class DiscordUserAchievement extends DiscordStruct { - public DiscordSnowflake user_id = new DiscordSnowflake(); - public DiscordSnowflake achievement_id = new DiscordSnowflake(); - public UInt32 percent_complete = new UInt32(); - public byte[] unlocked_at = new byte[64]; - public DiscordUserAchievement() {super();} public DiscordUserAchievement(Pointer pointer) {super(pointer);} - - public static class ByReference extends DiscordUserAchievement implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends DiscordUserAchievement implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override - protected List getFieldOrder() { - return Arrays.asList("user_id", "achievement_id", "percent_complete", "unlocked_at"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityActionType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityActionType.java deleted file mode 100644 index d46fdfc6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityActionType.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordActivityActionType { - DiscordActivityActionType_Join(1), - DiscordActivityActionType_Spectate(2); - - @Getter - private final int value; - private EDiscordActivityActionType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordActivityActionType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordActivityActionType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordActivityActionTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordActivityActionType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordActivityActionType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityJoinRequestReply.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityJoinRequestReply.java deleted file mode 100644 index a8deda60..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityJoinRequestReply.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordActivityJoinRequestReply { - DiscordActivityJoinRequestReply_No(0), - DiscordActivityJoinRequestReply_Yes(1), - DiscordActivityJoinRequestReply_Ignore(2); - - @Getter - private final int value; - private EDiscordActivityJoinRequestReply(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordActivityJoinRequestReply value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordActivityJoinRequestReply fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordActivityJoinRequestReplyTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordActivityJoinRequestReply.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordActivityJoinRequestReply)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityType.java deleted file mode 100644 index 9328758a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordActivityType.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordActivityType { - DiscordActivityType_Playing(0), - DiscordActivityType_Streaming(1), - DiscordActivityType_Listening(2), - DiscordActivityType_Watching(3); - - @Getter - private final int value; - private EDiscordActivityType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordActivityType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordActivityType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordActivityTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordActivityType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordActivityType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordCreateFlags.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordCreateFlags.java deleted file mode 100644 index 29598b47..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordCreateFlags.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordCreateFlags { - DiscordCreateFlags_Default(0), - DiscordCreateFlags_NoRequireDiscord(1); - - @Getter - private final int value; - private EDiscordCreateFlags(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordCreateFlags value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordCreateFlags fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordCreateFlagsTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordCreateFlags.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordCreateFlags)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordEntitlementType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordEntitlementType.java deleted file mode 100644 index d155fbc6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordEntitlementType.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordEntitlementType { - DiscordEntitlementType_Purchase(1), - DiscordEntitlementType_PremiumSubscription(2), - DiscordEntitlementType_DeveloperGift(3), - DiscordEntitlementType_TestModePurchase(4), - DiscordEntitlementType_FreePurchase(5), - DiscordEntitlementType_UserGift(6), - DiscordEntitlementType_PremiumPurchase(7); - - @Getter - private final int value; - private EDiscordEntitlementType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordEntitlementType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordEntitlementType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordEntitlementTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordEntitlementType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordEntitlementType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordImageType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordImageType.java deleted file mode 100644 index db4258db..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordImageType.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordImageType { - DiscordImageType_User(0); - - @Getter - private final int value; - private EDiscordImageType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordImageType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordImageType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordImageTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordImageType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - - if (value == null) return 0;return ((EDiscordImageType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordInputModeType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordInputModeType.java deleted file mode 100644 index 1cc49b7e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordInputModeType.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordInputModeType { - DiscordInputModeType_VoiceActivity(0), - DiscordInputModeType_PushToTalk(1); - - @Getter - private final int value; - private EDiscordInputModeType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordInputModeType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordInputModeType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordInputModeTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordInputModeType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordInputModeType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchCast.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchCast.java deleted file mode 100644 index 5bd97267..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchCast.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordLobbySearchCast { - DiscordLobbySearchCast_String(1), - DiscordLobbySearchCast_Number(2); - - @Getter - private final int value; - private EDiscordLobbySearchCast(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordLobbySearchCast value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordLobbySearchCast fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordLobbySearchCastTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordLobbySearchCast.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordLobbySearchCast)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchComparison.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchComparison.java deleted file mode 100644 index 5cc8f934..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchComparison.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordLobbySearchComparison { - DiscordLobbySearchComparison_LessThanOrEqual(-2), - DiscordLobbySearchComparison_LessThan(-1), - DiscordLobbySearchComparison_Equal(0), - DiscordLobbySearchComparison_GreaterThan(1), - DiscordLobbySearchComparison_GreaterThanOrEqual(2), - DiscordLobbySearchComparison_NotEqual(3); - - @Getter - private final int value; - private EDiscordLobbySearchComparison(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordLobbySearchComparison value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordLobbySearchComparison fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordLobbySearchComparisonTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordLobbySearchComparison.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordLobbySearchComparison)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchDistance.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchDistance.java deleted file mode 100644 index e8a920ea..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbySearchDistance.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordLobbySearchDistance { - DiscordLobbySearchDistance_Local(0), - DiscordLobbySearchDistance_Default(1), - DiscordLobbySearchDistance_Extended(2), - DiscordLobbySearchDistance_Global(3); - - @Getter - private final int value; - private EDiscordLobbySearchDistance(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordLobbySearchDistance value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordLobbySearchDistance fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordLobbySearchDistanceTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordLobbySearchDistance.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordLobbySearchDistance)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbyType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbyType.java deleted file mode 100644 index d8353d59..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLobbyType.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordLobbyType { - DiscordLobbyType_Private(1), - DiscordLobbyType_Public(2); - - @Getter - private final int value; - private EDiscordLobbyType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordLobbyType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordLobbyType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordLobbyTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordLobbyType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - - if (value == null) return 0;return ((EDiscordLobbyType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLogLevel.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLogLevel.java deleted file mode 100644 index 0fa0f3ab..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordLogLevel.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordLogLevel { - DiscordLogLevel_Error(1), - DiscordLogLevel_Warn(2), - DiscordLogLevel_Info(3), - DiscordLogLevel_Debug(4); - - @Getter - private final int value; - private EDiscordLogLevel(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordLogLevel value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordLogLevel fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordLogLevelTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordLogLevel.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - - if (value == null) return 0;return ((EDiscordLogLevel)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordPremiumType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordPremiumType.java deleted file mode 100644 index 4ca426d5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordPremiumType.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordPremiumType { - DiscordPremiumType_None(0), - DiscordPremiumType_Tier1(1), - DiscordPremiumType_Tier2(2); - - @Getter - private final int value; - private EDiscordPremiumType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordPremiumType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordPremiumType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordPremiumTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordPremiumType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordPremiumType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordRelationshipType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordRelationshipType.java deleted file mode 100644 index b2edb714..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordRelationshipType.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordRelationshipType { - DiscordRelationshipType_None(0), - DiscordRelationshipType_Friend(1), - DiscordRelationshipType_Blocked(2), - DiscordRelationshipType_PendingIncoming(3), - DiscordRelationshipType_PendingOutgoing(4), - DiscordRelationshipType_Implicit(5); - - @Getter - private final int value; - private EDiscordRelationshipType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordRelationshipType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordRelationshipType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordRelationshipTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordRelationshipType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordRelationshipType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordResult.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordResult.java deleted file mode 100644 index cb0541bf..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordResult.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordResult { - DiscordResult_Ok(0), - DiscordResult_ServiceUnavailable(1), - DiscordResult_InvalidVersion(2), - DiscordResult_LockFailed(3), - DiscordResult_InternalError(4), - DiscordResult_InvalidPayload(5), - DiscordResult_InvalidCommand(6), - DiscordResult_InvalidPermissions(7), - DiscordResult_NotFetched(8), - DiscordResult_NotFound(9), - DiscordResult_Conflict(10), - DiscordResult_InvalidSecret(11), - DiscordResult_InvalidJoinSecret(12), - DiscordResult_NoEligibleActivity(13), - DiscordResult_InvalidInvite(14), - DiscordResult_NotAuthenticated(15), - DiscordResult_InvalidAccessToken(16), - DiscordResult_ApplicationMismatch(17), - DiscordResult_InvalidDataUrl(18), - DiscordResult_InvalidBase64(19), - DiscordResult_NotFiltered(20), - DiscordResult_LobbyFull(21), - DiscordResult_InvalidLobbySecret(22), - DiscordResult_InvalidFilename(23), - DiscordResult_InvalidFileSize(24), - DiscordResult_InvalidEntitlement(25), - DiscordResult_NotInstalled(26), - DiscordResult_NotRunning(27), - DiscordResult_InsufficientBuffer(28), - DiscordResult_PurchaseCanceled(29), - DiscordResult_InvalidGuild(30), - DiscordResult_InvalidEvent(31), - DiscordResult_InvalidChannel(32), - DiscordResult_InvalidOrigin(33), - DiscordResult_RateLimited(34), - DiscordResult_OAuth2Error(35), - DiscordResult_SelectChannelTimeout(36), - DiscordResult_GetGuildTimeout(37), - DiscordResult_SelectVoiceForceRequired(38), - DiscordResult_CaptureShortcutAlreadyListening(39), - DiscordResult_UnauthorizedForAchievement(40), - DiscordResult_InvalidGiftCode(41), - DiscordResult_PurchaseError(42), - DiscordResult_TransactionAborted(43); - - @Getter - private final int value; - private EDiscordResult(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordResult value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordResult fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordResultTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordResult.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordResult)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordSkuType.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordSkuType.java deleted file mode 100644 index ba174a17..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordSkuType.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordSkuType { - DiscordSkuType_Application(1), - DiscordSkuType_DLC(2), - DiscordSkuType_Consumable(3), - DiscordSkuType_Bundle(4); - - @Getter - private final int value; - private EDiscordSkuType(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordSkuType value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordSkuType fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordSkuTypeTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordSkuType.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - - if (value == null) return 0;return ((EDiscordSkuType)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordStatus.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordStatus.java deleted file mode 100644 index b788aa62..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordStatus.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordStatus { - DiscordStatus_Offline(0), - DiscordStatus_Online(1), - DiscordStatus_Idle(2), - DiscordStatus_DoNotDisturb(3); - - @Getter - private final int value; - private EDiscordStatus(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordStatus value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordStatus fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordStatusTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordStatus.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - - if (value == null) return 0;return ((EDiscordStatus)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordUserFlag.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordUserFlag.java deleted file mode 100644 index 242e5f1e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/enumuration/EDiscordUserFlag.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration; - -import com.sun.jna.FromNativeContext; -import com.sun.jna.ToNativeContext; -import com.sun.jna.TypeConverter; -import lombok.Getter; - -import java.util.HashMap; -import java.util.Map; - -public enum EDiscordUserFlag { - DiscordUserFlag_Partner(2), - DiscordUserFlag_HypeSquadEvents(4), - DiscordUserFlag_HypeSquadHouse1(64), - DiscordUserFlag_HypeSquadHouse2(128), - DiscordUserFlag_HypeSquadHouse3(256); - - @Getter - private final int value; - private EDiscordUserFlag(int value) { - this.value = value; - } - - private static final Map valueMap = new HashMap<>(); - static { - for (EDiscordUserFlag value : values()) { - valueMap.put(value.value, value); - } - } - - public static EDiscordUserFlag fromValue(int value) { - return valueMap.get(value); - } - - public static class EDiscordUserFlagTypeConverter implements TypeConverter { - @Override - public Object fromNative(Object nativeValue, FromNativeContext context) { - return EDiscordUserFlag.fromValue((Integer)nativeValue); - } - - @Override - public Object toNative(Object value, ToNativeContext context) { - if (value == null) return 0; - return ((EDiscordUserFlag)value).getValue(); - } - - @Override - public Class nativeType() { - return Integer.class; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/GameSDKCallback.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/GameSDKCallback.java deleted file mode 100644 index 6f139163..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/GameSDKCallback.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Library; -import kr.syeyoung.dungeonsguide.gamesdk.jna.GameSDKTypeMapper; - -import java.util.Collections; -import java.util.Map; - -public interface GameSDKCallback extends Callback { - public static final Map OPTIONS = Collections.singletonMap(Library.OPTION_TYPE_MAPPER, GameSDKTypeMapper.INSTANCE); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordAchievementEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordAchievementEvents.java deleted file mode 100644 index e7cf3b38..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordAchievementEvents.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordUserAchievement; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordAchievementEvents extends DiscordStruct { public IDiscordAchievementEvents() {super();} public IDiscordAchievementEvents(Pointer pointer) {super(pointer);} - public interface OnUserAchievementUpdateCallback extends GameSDKCallback { void onUserAchievementUpdate(Pointer eventData, DiscordUserAchievement userAchievement); } - public OnUserAchievementUpdateCallback OnUserAchievementUpdate; - - - - public static class ByReference extends IDiscordAchievementEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordAchievementEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("OnUserAchievementUpdate"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordAchievementManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordAchievementManager.java deleted file mode 100644 index f83c0195..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordAchievementManager.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.Int32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt8; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordUserAchievement; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordAchievementManager extends DiscordStruct { public IDiscordAchievementManager() {super();} public IDiscordAchievementManager(Pointer pointer) {super(pointer);} - public interface SetUserAchievementCallback extends GameSDKCallback { void setUserAchievement(IDiscordAchievementManager manager, DiscordSnowflake achievementId, UInt8 percentComplete, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public SetUserAchievementCallback SetUserAchievement; - - public interface FetchUserAchievementsCallback extends GameSDKCallback { void fetchUserAchievements(IDiscordAchievementManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public FetchUserAchievementsCallback FetchUserAchievements; - - public interface CountUserAchievementsCallback extends GameSDKCallback { void countUserAchievements(IDiscordAchievementManager manager, IntByReference count); } - public CountUserAchievementsCallback CountUserAchievements; - - public interface GetUserAchievementCallback extends GameSDKCallback { EDiscordResult getUserAchievement(IDiscordAchievementManager manager, DiscordSnowflake userAchievementId, DiscordUserAchievement userAchievement); } - public GetUserAchievementCallback GetUserAchievement; - - public interface GetUserAchievementAtCallback extends GameSDKCallback { EDiscordResult getUserAchievementAt(IDiscordAchievementManager manager, Int32 index, DiscordUserAchievement userAchievement); } - public GetUserAchievementAtCallback GetUserAchievementAt; - - - - public static class ByReference extends IDiscordAchievementManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordAchievementManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("SetUserAchievement", "FetchUserAchievements", "CountUserAchievements", "GetUserAchievement", "GetUserAchievementAt"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordActivityEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordActivityEvents.java deleted file mode 100644 index d6a6ce48..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordActivityEvents.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityActionType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordActivity; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordUser; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordActivityEvents extends DiscordStruct { public IDiscordActivityEvents() {super();} public IDiscordActivityEvents(Pointer pointer) {super(pointer);} - public interface OnActivityJoinCallback extends GameSDKCallback { void onActivityJoin(Pointer eventData, String secret); } - public OnActivityJoinCallback OnActivityJoin; - - public interface OnActivitySpectateCallback extends GameSDKCallback { void onActivitySpectate(Pointer eventData, String secret); } - public OnActivitySpectateCallback OnActivitySpectate; - - public interface OnActivityJoinRequestCallback extends GameSDKCallback { void onActivityJoinRequest(Pointer eventData, DiscordUser user); } - public OnActivityJoinRequestCallback OnActivityJoinRequest; - - public interface OnActivityInviteCallback extends GameSDKCallback { void onActivityInvite(Pointer eventData, EDiscordActivityActionType type, DiscordUser user, DiscordActivity activity); } - public OnActivityInviteCallback OnActivityInvite; - - - - public static class ByReference extends IDiscordActivityEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordActivityEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("OnActivityJoin", "OnActivitySpectate", "OnActivityJoinRequest", "OnActivityInvite"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordActivityManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordActivityManager.java deleted file mode 100644 index b20e6660..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordActivityManager.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityActionType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordActivity; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityJoinRequestReply; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordActivityManager extends DiscordStruct { public IDiscordActivityManager() {super();} public IDiscordActivityManager(Pointer pointer) {super(pointer);} - public interface RegisterCommandCallback extends GameSDKCallback { EDiscordResult registerCommand(IDiscordActivityManager manager, String command); } - public RegisterCommandCallback RegisterCommand; - - public interface RegisterSteamCallback extends GameSDKCallback { EDiscordResult registerSteam(IDiscordActivityManager manager, UInt32 steamId); } - public RegisterSteamCallback RegisterSteam; - - public interface UpdateActivityCallback extends GameSDKCallback { void updateActivity(IDiscordActivityManager manager, DiscordActivity activity, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public UpdateActivityCallback UpdateActivity; - - public interface ClearActivityCallback extends GameSDKCallback { void clearActivity(IDiscordActivityManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public ClearActivityCallback ClearActivity; - - public interface SendRequestReplyCallback extends GameSDKCallback { void sendRequestReply(IDiscordActivityManager manager, DiscordSnowflake userId, EDiscordActivityJoinRequestReply reply, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public SendRequestReplyCallback SendRequestReply; - - public interface SendInviteCallback extends GameSDKCallback { void sendInvite(IDiscordActivityManager manager, DiscordSnowflake userId, EDiscordActivityActionType type, String content, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public SendInviteCallback SendInvite; - - public interface AcceptInviteCallback extends GameSDKCallback { void acceptInvite(IDiscordActivityManager manager, DiscordSnowflake userId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public AcceptInviteCallback AcceptInvite; - - - - public static class ByReference extends IDiscordActivityManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordActivityManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("RegisterCommand", "RegisterSteam", "UpdateActivity", "ClearActivity", "SendRequestReply", "SendInvite", "AcceptInvite"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordApplicationManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordApplicationManager.java deleted file mode 100644 index a8165234..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordApplicationManager.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordOAuth2Token; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordApplicationManager extends DiscordStruct { public IDiscordApplicationManager() {super();} public IDiscordApplicationManager(Pointer pointer) {super(pointer);} - public interface ValidateOrExitCallback extends GameSDKCallback { void validateOrExit(IDiscordApplicationManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public ValidateOrExitCallback ValidateOrExit; - - public interface GetCurrentLocaleCallback extends GameSDKCallback { void getCurrentLocale(IDiscordApplicationManager manager, Pointer locale); } // len 128 memory - public GetCurrentLocaleCallback GetCurrentLocale; - - public interface GetCurrentBranchCallback extends GameSDKCallback { void getCurrentBranch(IDiscordApplicationManager manager, Pointer branch); } // len 4096 mem - public GetCurrentBranchCallback GetCurrentBranch; - - public interface GetOauth2TokenCallback extends GameSDKCallback { void getOauth2Token(IDiscordApplicationManager manager, Pointer callbackData, GetOauth2TokenCallback_Callback callback); } - public interface GetOauth2TokenCallback_Callback extends GameSDKCallback { - void callback(Pointer callbackData, EDiscordResult result, DiscordOAuth2Token oauthToken); - } - - public GetOauth2TokenCallback GetOauth2Token; - - public interface GetTicketCallback extends GameSDKCallback { void getTicket(IDiscordApplicationManager manager, Pointer callbackData, GetTicketCallback_Callback callback); } - public interface GetTicketCallback_Callback extends GameSDKCallback { - void callback(Pointer callbackData, EDiscordResult result, String data); - } - public GetTicketCallback GetTicket; - - - - public static class ByReference extends IDiscordApplicationManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordApplicationManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("ValidateOrExit", "GetCurrentLocale", "GetCurrentBranch", "GetOauth2Token", "GetTicket"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordCore.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordCore.java deleted file mode 100644 index 7519987e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordCore.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.TypeMapper; -import kr.syeyoung.dungeonsguide.gamesdk.jna.GameSDKTypeMapper; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordLogLevel; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordCore extends DiscordStruct { public IDiscordCore() {super();} public IDiscordCore(Pointer pointer) {super(pointer);} - - public static final TypeMapper TYPE_MAPPER = GameSDKTypeMapper.INSTANCE; - public interface DestroyCallback extends GameSDKCallback { void destroy(IDiscordCore core); } - public DestroyCallback Destroy; - - public interface RunCallbacksCallback extends GameSDKCallback { EDiscordResult runCallbacks(IDiscordCore core); } - public RunCallbacksCallback RunCallbacks; - - public interface SetLogHookCallback extends GameSDKCallback { void setLogHook(IDiscordCore core, EDiscordLogLevel minLevel, Pointer hookData, LogHook hook); } - public interface LogHook extends GameSDKCallback { - void hook(Pointer hookData, EDiscordLogLevel level, String message); - } - public SetLogHookCallback SetLogHook; - - public interface GetApplicationManagerCallback extends GameSDKCallback { IDiscordApplicationManager getApplicationManager(IDiscordCore core); } - public GetApplicationManagerCallback GetApplicationManager; - - public interface GetUserManagerCallback extends GameSDKCallback { IDiscordUserManager getUserManager(IDiscordCore core); } - public GetUserManagerCallback GetUserManager; - - public interface GetImageManagerCallback extends GameSDKCallback { IDiscordImageManager getImageManager(IDiscordCore core); } - public GetImageManagerCallback GetImageManager; - - public interface GetActivityManagerCallback extends GameSDKCallback { IDiscordActivityManager getActivityManager(IDiscordCore core); } - public GetActivityManagerCallback GetActivityManager; - - public interface GetRelationshipManagerCallback extends GameSDKCallback { IDiscordRelationshipManager getRelationshipManager(IDiscordCore core); } - public GetRelationshipManagerCallback GetRelationshipManager; - - public interface GetLobbyManagerCallback extends GameSDKCallback { IDiscordLobbyManager getLobbyManager(IDiscordCore core); } - public GetLobbyManagerCallback GetLobbyManager; - - public interface GetNetworkManagerCallback extends GameSDKCallback { IDiscordNetworkManager getNetworkManager(IDiscordCore core); } - public GetNetworkManagerCallback GetNetworkManager; - - public interface GetOverlayManagerCallback extends GameSDKCallback { IDiscordOverlayManager getOverlayManager(IDiscordCore core); } - public GetOverlayManagerCallback GetOverlayManager; - - public interface GetStorageManagerCallback extends GameSDKCallback { IDiscordStorageManager getStorageManager(IDiscordCore core); } - public GetStorageManagerCallback GetStorageManager; - - public interface GetStoreManagerCallback extends GameSDKCallback { IDiscordStoreManager getStoreManager(IDiscordCore core); } - public GetStoreManagerCallback GetStoreManager; - - public interface GetVoiceManagerCallback extends GameSDKCallback { IDiscordVoiceManager getVoiceManager(IDiscordCore core); } - public GetVoiceManagerCallback GetVoiceManager; - - public interface GetAchievementManagerCallback extends GameSDKCallback { IDiscordAchievementManager getAchievementManager(IDiscordCore core); } - public GetAchievementManagerCallback GetAchievementManager; - - - - public static class ByReference extends IDiscordCore implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);} - } - public static class ByValue extends IDiscordCore implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);} - } - - @Override protected List getFieldOrder() { return Arrays.asList("Destroy", "RunCallbacks", "SetLogHook", "GetApplicationManager", "GetUserManager", "GetImageManager", "GetActivityManager", "GetRelationshipManager", "GetLobbyManager", "GetNetworkManager", "GetOverlayManager", "GetStorageManager", "GetStoreManager", "GetVoiceManager", "GetAchievementManager"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordImageManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordImageManager.java deleted file mode 100644 index 7c42ea33..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordImageManager.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordImageDimensions; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordImageHandle; - -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.List; - -public class IDiscordImageManager extends DiscordStruct { public IDiscordImageManager() {super();} public IDiscordImageManager(Pointer pointer) {super(pointer);} - public interface FetchCallback_Callback extends GameSDKCallback { - void callback(Pointer callbackData, EDiscordResult result, DiscordImageHandle.ByValue handleResult); - } - public interface FetchCallback extends GameSDKCallback { void fetch(IDiscordImageManager manager, DiscordImageHandle.ByValue handle, boolean refresh, Pointer callbackData, FetchCallback_Callback callback); } - public FetchCallback Fetch; - - public interface GetDimensionsCallback extends GameSDKCallback { EDiscordResult getDimensions(IDiscordImageManager manager, DiscordImageHandle.ByValue handle, DiscordImageDimensions dimensions); } - public GetDimensionsCallback GetDimensions; - - public interface GetDataCallback extends GameSDKCallback { EDiscordResult getData(IDiscordImageManager manager, DiscordImageHandle.ByValue handle, ByteBuffer data, UInt32 dataLength); } - public GetDataCallback GetData; - - - - public static class ByReference extends IDiscordImageManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordImageManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("Fetch", "GetDimensions", "GetData"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyEvents.java deleted file mode 100644 index 268fe2f5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyEvents.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt8; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.Int64; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordLobbyEvents extends DiscordStruct { public IDiscordLobbyEvents() {super();} public IDiscordLobbyEvents(Pointer pointer) {super(pointer);} - public interface OnLobbyUpdateCallback extends GameSDKCallback { void onLobbyUpdate(Pointer eventData, Int64 lobbyId); } - public OnLobbyUpdateCallback OnLobbyUpdate; - - public interface OnLobbyDeleteCallback extends GameSDKCallback { void onLobbyDelete(Pointer eventData, Int64 lobbyId, UInt32 reason); } - public OnLobbyDeleteCallback OnLobbyDelete; - - public interface OnMemberConnectCallback extends GameSDKCallback { void onMemberConnect(Pointer eventData, Int64 lobbyId, Int64 userId); } - public OnMemberConnectCallback OnMemberConnect; - - public interface OnMemberUpdateCallback extends GameSDKCallback { void onMemberUpdate(Pointer eventData, Int64 lobbyId, Int64 userId); } - public OnMemberUpdateCallback OnMemberUpdate; - - public interface OnMemberDisconnectCallback extends GameSDKCallback { void onMemberDisconnect(Pointer eventData, Int64 lobbyId, Int64 userId); } - public OnMemberDisconnectCallback OnMemberDisconnect; - - public interface OnLobbyMessageCallback extends GameSDKCallback { void onLobbyMessage(Pointer eventData, Int64 lobbyId, Int64 userId, ByteByReference data, UInt32 dataLength); } - public OnLobbyMessageCallback OnLobbyMessage; - - public interface OnSpeakingCallback extends GameSDKCallback { void onSpeaking(Pointer eventData, Int64 lobbyId, Int64 userId, boolean speaking); } - public OnSpeakingCallback OnSpeaking; - - public interface OnNetworkMessageCallback extends GameSDKCallback { void onNetworkMessage(Pointer eventData, Int64 lobbyId, Int64 userId, UInt8 channelId, ByteByReference data, UInt32 dataLength); } - public OnNetworkMessageCallback OnNetworkMessage; - - - - public static class ByReference extends IDiscordLobbyEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordLobbyEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - - @Override protected List getFieldOrder() { return Arrays.asList("OnLobbyUpdate", "OnLobbyDelete", "OnMemberConnect", "OnMemberUpdate", "OnMemberDisconnect", "OnLobbyMessage", "OnSpeaking", "OnNetworkMessage"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyManager.java deleted file mode 100644 index bfaf3c4a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyManager.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import com.sun.jna.ptr.IntByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordLobby; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.Int32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt8; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordUser; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordLobbyManager extends DiscordStruct { public IDiscordLobbyManager() {super();} public IDiscordLobbyManager(Pointer pointer) {super(pointer);} - public interface GetLobbyCreateTransactionCallback extends GameSDKCallback { EDiscordResult getLobbyCreateTransaction(IDiscordLobbyManager manager, IDiscordLobbyTransaction transaction); } - public GetLobbyCreateTransactionCallback GetLobbyCreateTransaction; - - public interface GetLobbyUpdateTransactionCallback extends GameSDKCallback { EDiscordResult getLobbyUpdateTransaction(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, IDiscordLobbyTransaction transaction); } - public GetLobbyUpdateTransactionCallback GetLobbyUpdateTransaction; - - public interface GetMemberUpdateTransactionCallback extends GameSDKCallback { EDiscordResult getMemberUpdateTransaction(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, IDiscordLobbyMemberTransaction transaction); } - public GetMemberUpdateTransactionCallback GetMemberUpdateTransaction; - - public interface DiscordLobbyManagerCallback extends GameSDKCallback { - void callback(Pointer callbackData, EDiscordResult result, DiscordLobby lobby); - } - - public interface CreateLobbyCallback extends GameSDKCallback { void createLobby(IDiscordLobbyManager manager, IDiscordLobbyTransaction transaction, Pointer callbackData,DiscordLobbyManagerCallback callback); } - public CreateLobbyCallback CreateLobby; - - public interface UpdateLobbyCallback extends GameSDKCallback { void updateLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, IDiscordLobbyTransaction transaction, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public UpdateLobbyCallback UpdateLobby; - - public interface DeleteLobbyCallback extends GameSDKCallback { void deleteLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public DeleteLobbyCallback DeleteLobby; - - public interface ConnectLobbyCallback extends GameSDKCallback { void connectLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer secret, Pointer callbackData, DiscordLobbyManagerCallback callback); }// secret 128 byte long str - public ConnectLobbyCallback ConnectLobby; - - public interface ConnectLobbyWithActivitySecretCallback extends GameSDKCallback { void connectLobbyWithActivitySecret(IDiscordLobbyManager manager, Pointer activitySecret, Pointer callbackData, DiscordLobbyManagerCallback callback); } // secret 128 byte long str - public ConnectLobbyWithActivitySecretCallback ConnectLobbyWithActivitySecret; - - public interface DisconnectLobbyCallback extends GameSDKCallback { void disconnectLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public DisconnectLobbyCallback DisconnectLobby; - - public interface GetLobbyCallback extends GameSDKCallback { EDiscordResult getLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordLobby lobby); } - public GetLobbyCallback GetLobby; - - public interface GetLobbyActivitySecretCallback extends GameSDKCallback { EDiscordResult getLobbyActivitySecret(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer secret); } // pointer to char[128] - public GetLobbyActivitySecretCallback GetLobbyActivitySecret; - - public interface GetLobbyMetadataValueCallback extends GameSDKCallback { EDiscordResult getLobbyMetadataValue(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer key, Pointer value); } // key: char[256] value: pointer to char[4096] - public GetLobbyMetadataValueCallback GetLobbyMetadataValue; - - public interface GetLobbyMetadataKeyCallback extends GameSDKCallback { EDiscordResult getLobbyMetadataKey(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Int32 index, Pointer key); }// key: pointer to char[256] - public GetLobbyMetadataKeyCallback GetLobbyMetadataKey; - - public interface LobbyMetadataCountCallback extends GameSDKCallback { EDiscordResult lobbyMetadataCount(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, IntByReference count); } - public LobbyMetadataCountCallback LobbyMetadataCount; - - public interface MemberCountCallback extends GameSDKCallback { EDiscordResult memberCount(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, IntByReference count); } - public MemberCountCallback MemberCount; - - public interface GetMemberUserIdCallback extends GameSDKCallback { EDiscordResult getMemberUserId(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Int32 index, Pointer userId); } // userID: pointer to DiscordUserID - public GetMemberUserIdCallback GetMemberUserId; - - public interface GetMemberUserCallback extends GameSDKCallback { EDiscordResult getMemberUser(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, DiscordUser user); } - public GetMemberUserCallback GetMemberUser; - - public interface GetMemberMetadataValueCallback extends GameSDKCallback { EDiscordResult getMemberMetadataValue(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, Pointer key, Pointer value); }// key: char[256] value: pointer to char[4096] - public GetMemberMetadataValueCallback GetMemberMetadataValue; - - public interface GetMemberMetadataKeyCallback extends GameSDKCallback { EDiscordResult getMemberMetadataKey(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, Int32 index, Pointer key); }// key: pointer to char[256] - public GetMemberMetadataKeyCallback GetMemberMetadataKey; - - public interface MemberMetadataCountCallback extends GameSDKCallback { EDiscordResult memberMetadataCount(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, IntByReference count); } - public MemberMetadataCountCallback MemberMetadataCount; - - public interface UpdateMemberCallback extends GameSDKCallback { void updateMember(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, IDiscordLobbyMemberTransaction transaction, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public UpdateMemberCallback UpdateMember; - - public interface SendLobbyMessageCallback extends GameSDKCallback { void sendLobbyMessage(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, ByteByReference data, UInt32 dataLength, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public SendLobbyMessageCallback SendLobbyMessage; - - public interface GetSearchQueryCallback extends GameSDKCallback { EDiscordResult getSearchQuery(IDiscordLobbyManager manager, IDiscordLobbySearchQuery query); } - public GetSearchQueryCallback GetSearchQuery; - - public interface SearchCallback extends GameSDKCallback { void search(IDiscordLobbyManager manager, IDiscordLobbySearchQuery query, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public SearchCallback Search; - - public interface LobbyCountCallback extends GameSDKCallback { void lobbyCount(IDiscordLobbyManager manager, IntByReference count); } - public LobbyCountCallback LobbyCount; - - public interface GetLobbyIdCallback extends GameSDKCallback { EDiscordResult getLobbyId(IDiscordLobbyManager manager, Int32 index, Pointer lobbyId); } // lobbyID: Pointer to DiscordSnowflake - public GetLobbyIdCallback GetLobbyId; - - public interface ConnectVoiceCallback extends GameSDKCallback { void connectVoice(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public ConnectVoiceCallback ConnectVoice; - - public interface DisconnectVoiceCallback extends GameSDKCallback { void disconnectVoice(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public DisconnectVoiceCallback DisconnectVoice; - - public interface ConnectNetworkCallback extends GameSDKCallback { EDiscordResult connectNetwork(IDiscordLobbyManager manager, DiscordSnowflake lobbyId); } - public ConnectNetworkCallback ConnectNetwork; - - public interface DisconnectNetworkCallback extends GameSDKCallback { EDiscordResult disconnectNetwork(IDiscordLobbyManager manager, DiscordSnowflake lobbyId); } - public DisconnectNetworkCallback DisconnectNetwork; - - public interface FlushNetworkCallback extends GameSDKCallback { EDiscordResult flushNetwork(IDiscordLobbyManager manager); } - public FlushNetworkCallback FlushNetwork; - - public interface OpenNetworkChannelCallback extends GameSDKCallback { EDiscordResult openNetworkChannel(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, UInt8 channelId, boolean reliable); } - public OpenNetworkChannelCallback OpenNetworkChannel; - - public interface SendNetworkMessageCallback extends GameSDKCallback { EDiscordResult sendNetworkMessage(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, UInt8 channelId, ByteByReference data, UInt32 dataLength); } - public SendNetworkMessageCallback SendNetworkMessage; - - - - public static class ByReference extends IDiscordLobbyManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordLobbyManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("GetLobbyCreateTransaction", "GetLobbyUpdateTransaction", "GetMemberUpdateTransaction", "CreateLobby", "UpdateLobby", "DeleteLobby", "ConnectLobby", "ConnectLobbyWithActivitySecret", "DisconnectLobby", "GetLobby", "GetLobbyActivitySecret", "GetLobbyMetadataValue", "GetLobbyMetadataKey", "LobbyMetadataCount", "MemberCount", "GetMemberUserId", "GetMemberUser", "GetMemberMetadataValue", "GetMemberMetadataKey", "MemberMetadataCount", "UpdateMember", "SendLobbyMessage", "GetSearchQuery", "Search", "LobbyCount", "GetLobbyId", "ConnectVoice", "DisconnectVoice", "ConnectNetwork", "DisconnectNetwork", "FlushNetwork", "OpenNetworkChannel", "SendNetworkMessage"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyMemberTransaction.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyMemberTransaction.java deleted file mode 100644 index d061d34b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyMemberTransaction.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordLobbyMemberTransaction extends DiscordStruct { public IDiscordLobbyMemberTransaction() {super();} public IDiscordLobbyMemberTransaction(Pointer pointer) {super(pointer);} - public interface SetMetadataCallback extends GameSDKCallback { EDiscordResult setMetadata(IDiscordLobbyMemberTransaction lobbyMemberTransaction, Pointer key, Pointer value); } // key is 256 bytes, value is 4096 - public SetMetadataCallback SetMetadata; - - public interface DeleteMetadataCallback extends GameSDKCallback { EDiscordResult deleteMetadata(IDiscordLobbyMemberTransaction lobbyMemberTransaction, Pointer key); } // key is 256 bytes, passed by reference - public DeleteMetadataCallback DeleteMetadata; - - - - public static class ByReference extends IDiscordLobbyMemberTransaction implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordLobbyMemberTransaction implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("SetMetadata", "DeleteMetadata"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbySearchQuery.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbySearchQuery.java deleted file mode 100644 index af2bb1ea..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbySearchQuery.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordLobbySearchComparison; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordLobbySearchDistance; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordLobbySearchCast; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordLobbySearchQuery extends DiscordStruct { public IDiscordLobbySearchQuery() {super();} public IDiscordLobbySearchQuery(Pointer pointer) {super(pointer);} - public interface FilterCallback extends GameSDKCallback { EDiscordResult filter(IDiscordLobbySearchQuery lobbySearchQuery, Pointer key, EDiscordLobbySearchComparison comparison, EDiscordLobbySearchCast cast, Pointer value); } - public FilterCallback Filter; - - public interface SortCallback extends GameSDKCallback { EDiscordResult sort(IDiscordLobbySearchQuery lobbySearchQuery, Pointer key, EDiscordLobbySearchCast cast, Pointer value); } - public SortCallback Sort; - - public interface LimitCallback extends GameSDKCallback { EDiscordResult limit(IDiscordLobbySearchQuery lobbySearchQuery, UInt32 limit); } - public LimitCallback Limit; - - public interface DistanceCallback extends GameSDKCallback { EDiscordResult distance(IDiscordLobbySearchQuery lobbySearchQuery, EDiscordLobbySearchDistance distance); } - public DistanceCallback Distance; - - - - public static class ByReference extends IDiscordLobbySearchQuery implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordLobbySearchQuery implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("Filter", "Sort", "Limit", "Distance"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyTransaction.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyTransaction.java deleted file mode 100644 index 354c3b37..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordLobbyTransaction.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordLobbyType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordLobbyTransaction extends DiscordStruct { public IDiscordLobbyTransaction() {super();} public IDiscordLobbyTransaction(Pointer pointer) {super(pointer);} - public interface SetTypeCallback extends GameSDKCallback { EDiscordResult setType(IDiscordLobbyTransaction lobbyTransaction, EDiscordLobbyType type); } - public SetTypeCallback SetType; - - public interface SetOwnerCallback extends GameSDKCallback { EDiscordResult setOwner(IDiscordLobbyTransaction lobbyTransaction, DiscordSnowflake ownerId); } - public SetOwnerCallback SetOwner; - - public interface SetCapacityCallback extends GameSDKCallback { EDiscordResult setCapacity(IDiscordLobbyTransaction lobbyTransaction, UInt32 capacity); } - public SetCapacityCallback SetCapacity; - - public interface SetMetadataCallback extends GameSDKCallback { EDiscordResult setMetadata(IDiscordLobbyTransaction lobbyTransaction, Pointer key, Pointer value); } - public SetMetadataCallback SetMetadata; - - public interface DeleteMetadataCallback extends GameSDKCallback { EDiscordResult deleteMetadata(IDiscordLobbyTransaction lobbyTransaction, Pointer key); } - public DeleteMetadataCallback DeleteMetadata; - - public interface SetLockedCallback extends GameSDKCallback { EDiscordResult setLocked(IDiscordLobbyTransaction lobbyTransaction, boolean locked); } - public SetLockedCallback SetLocked; - - - - public static class ByReference extends IDiscordLobbyTransaction implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordLobbyTransaction implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("SetType", "SetOwner", "SetCapacity", "SetMetadata", "DeleteMetadata", "SetLocked"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordNetworkEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordNetworkEvents.java deleted file mode 100644 index 0c99e5c6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordNetworkEvents.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordNetworkChannelId; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordNetworkPeerId; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordNetworkEvents extends DiscordStruct { public IDiscordNetworkEvents() {super();} public IDiscordNetworkEvents(Pointer pointer) {super(pointer);} - public interface OnMessageCallback extends GameSDKCallback { void onMessage(Pointer eventData, DiscordNetworkPeerId peerId, DiscordNetworkChannelId channelId, ByteByReference data, UInt32 dataLength); } - public OnMessageCallback OnMessage; - - public interface OnRouteUpdateCallback extends GameSDKCallback { void onRouteUpdate(Pointer eventData, String route_data); } - public OnRouteUpdateCallback OnRouteUpdate; - - - - public static class ByReference extends IDiscordNetworkEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordNetworkEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("OnMessage", "OnRouteUpdate"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordNetworkManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordNetworkManager.java deleted file mode 100644 index b14bb832..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordNetworkManager.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import com.sun.jna.ptr.LongByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordNetworkChannelId; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordNetworkPeerId; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordNetworkManager extends DiscordStruct { public IDiscordNetworkManager() {super();} public IDiscordNetworkManager(Pointer pointer) {super(pointer);} - public interface GetPeerIdCallback extends GameSDKCallback { void getPeerId(IDiscordNetworkManager manager, LongByReference peerId); } - public GetPeerIdCallback GetPeerId; - - public interface FlushCallback extends GameSDKCallback { EDiscordResult flush(IDiscordNetworkManager manager); } - public FlushCallback Flush; - - public interface OpenPeerCallback extends GameSDKCallback { EDiscordResult openPeer(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, String routeData); } - public OpenPeerCallback OpenPeer; - - public interface UpdatePeerCallback extends GameSDKCallback { EDiscordResult updatePeer(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, String routeData); } - public UpdatePeerCallback UpdatePeer; - - public interface ClosePeerCallback extends GameSDKCallback { EDiscordResult closePeer(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId); } - public ClosePeerCallback ClosePeer; - - public interface OpenChannelCallback extends GameSDKCallback { EDiscordResult openChannel(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, DiscordNetworkChannelId channelId, boolean reliable); } - public OpenChannelCallback OpenChannel; - - public interface CloseChannelCallback extends GameSDKCallback { EDiscordResult closeChannel(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, DiscordNetworkChannelId channelId); } - public CloseChannelCallback CloseChannel; - - public interface SendMessageCallback extends GameSDKCallback { EDiscordResult sendMessage(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, DiscordNetworkChannelId channelId, ByteByReference data, UInt32 dataLength); } - public SendMessageCallback SendMessage; - - - - public static class ByReference extends IDiscordNetworkManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordNetworkManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("GetPeerId", "Flush", "OpenPeer", "UpdatePeer", "ClosePeer", "OpenChannel", "CloseChannel", "SendMessage"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordOverlayEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordOverlayEvents.java deleted file mode 100644 index 91ab9e81..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordOverlayEvents.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordOverlayEvents extends DiscordStruct { public IDiscordOverlayEvents() {super();} public IDiscordOverlayEvents(Pointer pointer) {super(pointer);} - public interface OnToggleCallback extends GameSDKCallback { void onToggle(Pointer eventData, boolean locked); } - public OnToggleCallback OnToggle; - - - - public static class ByReference extends IDiscordOverlayEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordOverlayEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("OnToggle"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordOverlayManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordOverlayManager.java deleted file mode 100644 index 9c39ed38..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordOverlayManager.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityActionType; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordOverlayManager extends DiscordStruct { public IDiscordOverlayManager() {super();} public IDiscordOverlayManager(Pointer pointer) {super(pointer);} - public interface IsEnabledCallback extends GameSDKCallback { void isEnabled(IDiscordOverlayManager manager, ByteByReference enabled); } - public IsEnabledCallback IsEnabled; - - public interface IsLockedCallback extends GameSDKCallback { void isLocked(IDiscordOverlayManager manager, ByteByReference locked); } - public IsLockedCallback IsLocked; - - public interface SetLockedCallback extends GameSDKCallback { void setLocked(IDiscordOverlayManager manager, boolean locked, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public SetLockedCallback SetLocked; - - public interface OpenActivityInviteCallback extends GameSDKCallback { void openActivityInvite(IDiscordOverlayManager manager, EDiscordActivityActionType type, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public OpenActivityInviteCallback OpenActivityInvite; - - public interface OpenGuildInviteCallback extends GameSDKCallback { void openGuildInvite(IDiscordOverlayManager manager, String code, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public OpenGuildInviteCallback OpenGuildInvite; - - public interface OpenVoiceSettingsCallback extends GameSDKCallback { void openVoiceSettings(IDiscordOverlayManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public OpenVoiceSettingsCallback OpenVoiceSettings; - - - - public static class ByReference extends IDiscordOverlayManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordOverlayManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("IsEnabled", "IsLocked", "SetLocked", "OpenActivityInvite", "OpenGuildInvite", "OpenVoiceSettings"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordRelationshipEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordRelationshipEvents.java deleted file mode 100644 index 259ca819..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordRelationshipEvents.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordRelationship; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordRelationshipEvents extends DiscordStruct { public IDiscordRelationshipEvents() {super();} public IDiscordRelationshipEvents(Pointer pointer) {super(pointer);} - public interface OnRefreshCallback extends GameSDKCallback { void onRefresh(Pointer eventData); } - public OnRefreshCallback OnRefresh; - - public interface OnRelationshipUpdateCallback extends GameSDKCallback { void onRelationshipUpdate(Pointer eventData, DiscordRelationship relationship); } - public OnRelationshipUpdateCallback OnRelationshipUpdate; - - - - public static class ByReference extends IDiscordRelationshipEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordRelationshipEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("OnRefresh", "OnRelationshipUpdate"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordRelationshipManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordRelationshipManager.java deleted file mode 100644 index 1b3ffe16..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordRelationshipManager.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.IntByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordRelationship; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordRelationshipManager extends DiscordStruct { public IDiscordRelationshipManager() {super();} public IDiscordRelationshipManager(Pointer pointer) {super(pointer);} - public interface FilterCallback extends GameSDKCallback { void filter(IDiscordRelationshipManager manager, Pointer filterData, FilterCallback_Callback filter); } - public interface FilterCallback_Callback extends GameSDKCallback { boolean filter(Pointer filterData, DiscordRelationship relationShip);} - public FilterCallback Filter; - - public interface CountCallback extends GameSDKCallback { EDiscordResult count(IDiscordRelationshipManager manager, IntByReference count); } - public CountCallback Count; - - public interface GetCallback extends GameSDKCallback { EDiscordResult get(IDiscordRelationshipManager manager, DiscordSnowflake userId, DiscordRelationship relationship); } - public GetCallback Get; - - public interface GetAtCallback extends GameSDKCallback { EDiscordResult getAt(IDiscordRelationshipManager manager, UInt32 index, DiscordRelationship relationship); } - public GetAtCallback GetAt; - - - - public static class ByReference extends IDiscordRelationshipManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordRelationshipManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("Filter", "Count", "Get", "GetAt"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStorageManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStorageManager.java deleted file mode 100644 index 8e62b115..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStorageManager.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import com.sun.jna.ptr.IntByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.Int32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordFileStat; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt64; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordStorageManager extends DiscordStruct { public IDiscordStorageManager() {super();} public IDiscordStorageManager(Pointer pointer) {super(pointer);} - public interface ReadCallback extends GameSDKCallback { EDiscordResult read(IDiscordStorageManager manager, String name, ByteByReference data, UInt32 dataLength, IntByReference read); } - public ReadCallback Read; - - public interface DiscordStorageManagerCallback extends GameSDKCallback { - void callback(Pointer callbackData, EDiscordResult result, ByteByReference data, IntByReference data_length); - } - - public interface ReadAsyncCallback extends GameSDKCallback { void readAsync(IDiscordStorageManager manager, String name, Pointer callbackData, DiscordStorageManagerCallback callback); } - public ReadAsyncCallback ReadAsync; - - public interface ReadAsyncPartialCallback extends GameSDKCallback { void readAsyncPartial(IDiscordStorageManager manager, String name, UInt64 offset, UInt64 length, Pointer callbackData, DiscordStorageManagerCallback callback); } - public ReadAsyncPartialCallback ReadAsyncPartial; - - public interface WriteCallback extends GameSDKCallback { EDiscordResult write(IDiscordStorageManager manager, String name, ByteByReference data, UInt32 dataLength); } - public WriteCallback Write; - - public interface WriteAsyncCallback extends GameSDKCallback { void writeAsync(IDiscordStorageManager manager, String name, ByteByReference data, UInt32 dataLength, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public WriteAsyncCallback WriteAsync; - - public interface DeleteCallback extends GameSDKCallback { EDiscordResult delete(IDiscordStorageManager manager, String name); } - public DeleteCallback Delete; - - public interface ExistsCallback extends GameSDKCallback { EDiscordResult exists(IDiscordStorageManager manager, String name, ByteByReference exists); } // exists actually boolean - public ExistsCallback Exists; - - public interface CountCallback extends GameSDKCallback { void count(IDiscordStorageManager manager, IntByReference count); } - public CountCallback Count; - - public interface StatCallback extends GameSDKCallback { EDiscordResult stat(IDiscordStorageManager manager, String name, DiscordFileStat stat); } - public StatCallback Stat; - - public interface StatAtCallback extends GameSDKCallback { EDiscordResult statAt(IDiscordStorageManager manager, Int32 index, DiscordFileStat stat); } - public StatAtCallback StatAt; - - public interface GetPathCallback extends GameSDKCallback { EDiscordResult getPath(IDiscordStorageManager manager, Pointer path); } // path str len 4096 - public GetPathCallback GetPath; - - - - public static class ByReference extends IDiscordStorageManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordStorageManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - - @Override protected List getFieldOrder() { return Arrays.asList("Read", "ReadAsync", "ReadAsyncPartial", "Write", "WriteAsync", "Delete", "Exists", "Count", "Stat", "StatAt", "GetPath"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStoreEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStoreEvents.java deleted file mode 100644 index 8b3cbd69..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStoreEvents.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordEntitlement; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordStoreEvents extends DiscordStruct { public IDiscordStoreEvents() {super();} public IDiscordStoreEvents(Pointer pointer) {super(pointer);} - public interface OnEntitlementCreateCallback extends GameSDKCallback { void onEntitlementCreate(Pointer eventData, DiscordEntitlement entitlement); } - public OnEntitlementCreateCallback OnEntitlementCreate; - - public interface OnEntitlementDeleteCallback extends GameSDKCallback { void onEntitlementDelete(Pointer eventData, DiscordEntitlement entitlement); } - public OnEntitlementDeleteCallback OnEntitlementDelete; - - - - public static class ByReference extends IDiscordStoreEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordStoreEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - - @Override protected List getFieldOrder() { return Arrays.asList("OnEntitlementCreate", "OnEntitlementDelete"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStoreManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStoreManager.java deleted file mode 100644 index ce5ec134..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordStoreManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import com.sun.jna.ptr.IntByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordSku; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordEntitlement; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.Int32; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordStoreManager extends DiscordStruct { public IDiscordStoreManager() {super();} public IDiscordStoreManager(Pointer pointer) {super(pointer);} - public interface FetchSkusCallback extends GameSDKCallback { void fetchSkus(IDiscordStoreManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public FetchSkusCallback FetchSkus; - - public interface CountSkusCallback extends GameSDKCallback { void countSkus(IDiscordStoreManager manager, IntByReference count); } - public CountSkusCallback CountSkus; - - public interface GetSkuCallback extends GameSDKCallback { EDiscordResult getSku(IDiscordStoreManager manager, DiscordSnowflake skuId, DiscordSku sku); } - public GetSkuCallback GetSku; - - public interface GetSkuAtCallback extends GameSDKCallback { EDiscordResult getSkuAt(IDiscordStoreManager manager, Int32 index, DiscordSku sku); } - public GetSkuAtCallback GetSkuAt; - - public interface FetchEntitlementsCallback extends GameSDKCallback { void fetchEntitlements(IDiscordStoreManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public FetchEntitlementsCallback FetchEntitlements; - - public interface CountEntitlementsCallback extends GameSDKCallback { void countEntitlements(IDiscordStoreManager manager, IntByReference count); } - public CountEntitlementsCallback CountEntitlements; - - public interface GetEntitlementCallback extends GameSDKCallback { EDiscordResult getEntitlement(IDiscordStoreManager manager, DiscordSnowflake entitlementId, DiscordEntitlement entitlement); } - public GetEntitlementCallback GetEntitlement; - - public interface GetEntitlementAtCallback extends GameSDKCallback { EDiscordResult getEntitlementAt(IDiscordStoreManager manager, Int32 index, DiscordEntitlement entitlement); } - public GetEntitlementAtCallback GetEntitlementAt; - - public interface HasSkuEntitlementCallback extends GameSDKCallback { EDiscordResult hasSkuEntitlement(IDiscordStoreManager manager, DiscordSnowflake skuId, ByteByReference hasEntitlement); } // hasEntitlement bool ptr - public HasSkuEntitlementCallback HasSkuEntitlement; - - public interface StartPurchaseCallback extends GameSDKCallback { void startPurchase(IDiscordStoreManager manager, DiscordSnowflake skuId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public StartPurchaseCallback StartPurchase; - - - - public static class ByReference extends IDiscordStoreManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordStoreManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("FetchSkus", "CountSkus", "GetSku", "GetSkuAt", "FetchEntitlements", "CountEntitlements", "GetEntitlement", "GetEntitlementAt", "HasSkuEntitlement", "StartPurchase"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordUserEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordUserEvents.java deleted file mode 100644 index 72e22b91..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordUserEvents.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordUserEvents extends DiscordStruct { public IDiscordUserEvents() {super();} public IDiscordUserEvents(Pointer pointer) {super(pointer);} - public interface OnCurrentUserUpdateCallback extends GameSDKCallback { void onCurrentUserUpdate(Pointer eventData); } - public OnCurrentUserUpdateCallback OnCurrentUserUpdate; - - - - public static class ByReference extends IDiscordUserEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordUserEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - @Override protected List getFieldOrder() { return Arrays.asList("OnCurrentUserUpdate"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordUserManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordUserManager.java deleted file mode 100644 index f74c233a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordUserManager.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import com.sun.jna.ptr.IntByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordUserFlag; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordUser; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordUserManager extends DiscordStruct { public IDiscordUserManager() {super();} public IDiscordUserManager(Pointer pointer) {super(pointer);} - public interface GetCurrentUserCallback extends GameSDKCallback { EDiscordResult getCurrentUser(IDiscordUserManager manager, DiscordUser currentUser); } - public GetCurrentUserCallback GetCurrentUser; - - public interface GetUserCallback extends GameSDKCallback { void getUser(IDiscordUserManager manager, DiscordSnowflake userId, Pointer callbackData, GetUserCallback_Callback callback); } - public interface GetUserCallback_Callback extends GameSDKCallback { void callback(Pointer callbackData, EDiscordResult result, DiscordUser user);} - public GetUserCallback GetUser; - - public interface GetCurrentUserPremiumTypeCallback extends GameSDKCallback { EDiscordResult getCurrentUserPremiumType(IDiscordUserManager manager, IntByReference premiumType); } // EDiscordPremiumType ptr - public GetCurrentUserPremiumTypeCallback GetCurrentUserPremiumType; - - public interface CurrentUserHasFlagCallback extends GameSDKCallback { EDiscordResult currentUserHasFlag(IDiscordUserManager manager, EDiscordUserFlag flag, ByteByReference hasFlag); } // hasFlag bool ptr - public CurrentUserHasFlagCallback CurrentUserHasFlag; - - - - public static class ByReference extends IDiscordUserManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordUserManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - @Override protected List getFieldOrder() { return Arrays.asList("GetCurrentUser", "GetUser", "GetCurrentUserPremiumType", "CurrentUserHasFlag"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordVoiceEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordVoiceEvents.java deleted file mode 100644 index 301de3ad..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordVoiceEvents.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordVoiceEvents extends DiscordStruct { public IDiscordVoiceEvents() {super();} public IDiscordVoiceEvents(Pointer pointer) {super(pointer);} - public interface OnSettingsUpdateCallback extends GameSDKCallback { void onSettingsUpdate(Pointer eventData); } - public OnSettingsUpdateCallback OnSettingsUpdate; - - - - public static class ByReference extends IDiscordVoiceEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordVoiceEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - - @Override protected List getFieldOrder() { return Arrays.asList("OnSettingsUpdate"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordVoiceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordVoiceManager.java deleted file mode 100644 index f9881008..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/interfacestruct/IDiscordVoiceManager.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct; - -import com.sun.jna.Callback; -import com.sun.jna.Structure; -import com.sun.jna.ptr.ByteByReference; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordStruct; -import com.sun.jna.Pointer; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordResult; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.UInt8; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordInputMode; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.DiscordSnowflake; - -import java.util.Arrays; -import java.util.List; - -public class IDiscordVoiceManager extends DiscordStruct { public IDiscordVoiceManager() {super();} public IDiscordVoiceManager(Pointer pointer) {super(pointer);} - public interface GetInputModeCallback extends GameSDKCallback { EDiscordResult getInputMode(IDiscordVoiceManager manager, DiscordInputMode inputMode); } - public GetInputModeCallback GetInputMode; - - public interface SetInputModeCallback extends GameSDKCallback { void setInputMode(IDiscordVoiceManager manager, DiscordInputMode.ByValue inputMode, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } - public SetInputModeCallback SetInputMode; - - public interface IsSelfMuteCallback extends GameSDKCallback { EDiscordResult isSelfMute(IDiscordVoiceManager manager, ByteByReference mute); } - public IsSelfMuteCallback IsSelfMute; - - public interface SetSelfMuteCallback extends GameSDKCallback { EDiscordResult setSelfMute(IDiscordVoiceManager manager, boolean mute); } - public SetSelfMuteCallback SetSelfMute; - - public interface IsSelfDeafCallback extends GameSDKCallback { EDiscordResult isSelfDeaf(IDiscordVoiceManager manager, ByteByReference deaf); } - public IsSelfDeafCallback IsSelfDeaf; - - public interface SetSelfDeafCallback extends GameSDKCallback { EDiscordResult setSelfDeaf(IDiscordVoiceManager manager, boolean deaf); } - public SetSelfDeafCallback SetSelfDeaf; - - public interface IsLocalMuteCallback extends GameSDKCallback { EDiscordResult isLocalMute(IDiscordVoiceManager manager, DiscordSnowflake userId, ByteByReference mute); } - public IsLocalMuteCallback IsLocalMute; - - public interface SetLocalMuteCallback extends GameSDKCallback { EDiscordResult setLocalMute(IDiscordVoiceManager manager, DiscordSnowflake userId, boolean mute); } - public SetLocalMuteCallback SetLocalMute; - - public interface GetLocalVolumeCallback extends GameSDKCallback { EDiscordResult getLocalVolume(IDiscordVoiceManager manager, DiscordSnowflake userId, ByteByReference volume); } - public GetLocalVolumeCallback GetLocalVolume; - - public interface SetLocalVolumeCallback extends GameSDKCallback { EDiscordResult setLocalVolume(IDiscordVoiceManager manager, DiscordSnowflake userId, UInt8 volume); } - public SetLocalVolumeCallback SetLocalVolume; - - - - public static class ByReference extends IDiscordVoiceManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} - public static class ByValue extends IDiscordVoiceManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} - - - @Override protected List getFieldOrder() { return Arrays.asList("GetInputMode", "SetInputMode", "IsSelfMute", "SetSelfMute", "IsSelfDeaf", "SetSelfDeaf", "IsLocalMute", "SetLocalMute", "GetLocalVolume", "SetLocalVolume"); } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordClientID.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordClientID.java deleted file mode 100644 index df6c4628..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordClientID.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class DiscordClientID extends Int64 { - public DiscordClientID() { - this(0); - } - public DiscordClientID(long value) { - super(value); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordNetworkChannelId.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordNetworkChannelId.java deleted file mode 100644 index 82b34ee7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordNetworkChannelId.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class DiscordNetworkChannelId extends UInt8 { - public DiscordNetworkChannelId() { - this(0); - } - public DiscordNetworkChannelId(long value) { - super(value); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordNetworkPeerId.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordNetworkPeerId.java deleted file mode 100644 index 49d73e3f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordNetworkPeerId.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class DiscordNetworkPeerId extends UInt64 { - public DiscordNetworkPeerId() { - this(0); - } - public DiscordNetworkPeerId(long value) { - super(value); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordSnowflake.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordSnowflake.java deleted file mode 100644 index 3a86f73d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordSnowflake.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class DiscordSnowflake extends Int64 { - public DiscordSnowflake() { - this(0); - } - public DiscordSnowflake(long value) { - super(value); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordTimestamp.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordTimestamp.java deleted file mode 100644 index c8f73da5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordTimestamp.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class DiscordTimestamp extends Int64 { - public DiscordTimestamp() { - this(0); - } - public DiscordTimestamp(long value) { - super(value); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordVersion.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordVersion.java deleted file mode 100644 index ed5fda42..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/DiscordVersion.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class DiscordVersion extends Int32 { - public DiscordVersion() { - this(0); - } - public DiscordVersion(long value) { - super(value); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/Int32.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/Int32.java deleted file mode 100644 index 581aed96..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/Int32.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class Int32 extends IntegerType { - public static final int SIZE = 4; - public Int32() { - this(0); - } - public Int32(long value) { - super(SIZE, value, false); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/Int64.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/Int64.java deleted file mode 100644 index a8dff873..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/Int64.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class Int64 extends IntegerType { - public static final int SIZE = 8; - public Int64() { - this(0); - } - public Int64(long value) { - super(SIZE, value, false); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt32.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt32.java deleted file mode 100644 index 98a903c6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt32.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class UInt32 extends IntegerType { - public static final int SIZE = 4; - public UInt32() { - this(0); - } - public UInt32(long value) { - super(SIZE, value, true); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt64.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt64.java deleted file mode 100644 index a0265b34..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt64.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class UInt64 extends IntegerType { - public static final int SIZE = 8; - public UInt64() { - this(0); - } - public UInt64(long value) { - super(SIZE, value, true); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt8.java b/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt8.java deleted file mode 100644 index 1b10c5a2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gamesdk/jna/typedef/UInt8.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gamesdk.jna.typedef; - -import com.sun.jna.IntegerType; - -public class UInt8 extends IntegerType { - public static final int SIZE = 1; - public UInt8() { - this(0); - } - public UInt8(long value) { - super(SIZE, value, true); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java deleted file mode 100644 index 13c9e00f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui; - -import kr.syeyoung.dungeonsguide.gui.elements.MRootPanel; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import kr.syeyoung.dungeonsguide.utils.cursor.GLCursors; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.Tuple; -import org.lwjgl.LWJGLException; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -public class MGui extends GuiScreen { - - @Getter - private final MRootPanel mainPanel = new MRootPanel(); - private boolean isOpen = false; - - public MGui(){ - try { - Mouse.setNativeCursor(GLCursors.getCursor(EnumCursor.DEFAULT)); - } catch (Throwable e) { - e.printStackTrace(); - } - } - - @Override - public void initGui() { - super.initGui(); - Keyboard.enableRepeatEvents(true); - isOpen = true; - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - mainPanel.setBounds(new Rectangle(0,0,Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight)); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - try { - - int i = Mouse.getEventX(); - int j = this.mc.displayHeight - Mouse.getEventY(); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GlStateManager.pushMatrix(); - GlStateManager.disableDepth(); - GlStateManager.enableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - GlStateManager.color(1, 1, 1, 1); - GlStateManager.scale(1.0/scaledResolution.getScaleFactor(), 1.0/scaledResolution.getScaleFactor(), 1.0d); - mainPanel.render0(1, new Point(0,0), new Rectangle(0,0,Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight), i, j, i, j, partialTicks); - GlStateManager.popMatrix(); - GlStateManager.enableBlend(); - GlStateManager.enableDepth(); - } catch (Throwable e) { - e.printStackTrace(); - } - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } - - @Override - public void keyTyped(char typedChar, int keyCode) throws IOException { - try { - mainPanel.keyPressed0(typedChar, keyCode); - super.keyTyped(typedChar, keyCode); - } catch (Throwable e) { - if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - public void keyHeld(int keyCode, char typedChar) throws IOException { - try { - mainPanel.keyHeld0(typedChar, keyCode); - } catch (Throwable e) { - if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - public void keyReleased(int keyCode, char typedChar) throws IOException { - try { - mainPanel.keyReleased0(typedChar, keyCode); - } catch (Throwable e) { - if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - try { - super.mouseClicked(mouseX, mouseY, mouseButton); - mainPanel.mouseClicked0(mouseX, mouseY - ,mouseX, mouseY, mouseButton); - } catch (Throwable e) { - if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - - @Override - public void onGuiClosed() { - super.onGuiClosed(); - Keyboard.enableRepeatEvents(false); - isOpen = false; - - try { - Mouse.setNativeCursor(null); - mainPanel.setCursor(EnumCursor.DEFAULT); - } catch (LWJGLException e) { - e.printStackTrace(); - } - } - - @Override - public void mouseReleased(int mouseX, int mouseY, int state) { - try { - mainPanel.mouseReleased0(mouseX, mouseY - ,mouseX,mouseY , state); - } catch (Throwable e) { - if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - - @Override - public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { - try { - mainPanel.mouseClickMove0(mouseX, mouseY - ,mouseX ,mouseY, clickedMouseButton, timeSinceLastClick); - } catch (Throwable e) { - if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - - public void mouseMove(int mouseX, int mouseY) { - try { - mainPanel.mouseMoved0(mouseX, mouseY - ,mouseX ,mouseY); - } catch (Throwable e) { - if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - - - private int touchValue; - private int eventButton; - private long lastMouseEvent; - - - private int lastX, lastY; - - - @Override - public void handleMouseInput() throws IOException { - if (!isOpen) return; - try { - int i = Mouse.getEventX(); - int j = this.mc.displayHeight - Mouse.getEventY(); - int k = Mouse.getEventButton(); - - if (Mouse.getEventButtonState()) - { - if (this.mc.gameSettings.touchscreen && this.touchValue++ > 0) - { - return; - } - - this.eventButton = k; - this.lastMouseEvent = Minecraft.getSystemTime(); - this.mouseClicked(i, j, this.eventButton); - } - else if (k != -1) - { - if (this.mc.gameSettings.touchscreen && --this.touchValue > 0) - { - return; - } - - this.eventButton = -1; - this.mouseReleased(i, j, k); - } - else if (this.eventButton != -1 && this.lastMouseEvent > 0L) - { - long l = Minecraft.getSystemTime() - this.lastMouseEvent; - this.mouseClickMove(i, j, this.eventButton, l); - } - if (lastX != i || lastY != j) { - try { - EnumCursor prevCursor = mainPanel.getCurrentCursor(); - mainPanel.setCursor(EnumCursor.DEFAULT); - this.mouseMove(i, j); - EnumCursor newCursor = mainPanel.getCurrentCursor(); - if (prevCursor != newCursor) Mouse.setNativeCursor(GLCursors.getCursor(newCursor)); - } catch (Throwable e) { - if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) - e.printStackTrace(); - } - } - - - int wheel = Mouse.getEventDWheel(); - if (wheel != 0) { - mainPanel.mouseScrolled0(i, j,i,j, wheel); - } - lastX = i; - lastY = j; - } catch (Throwable e) { - e.printStackTrace(); - } - } - public void handleKeyboardInput() throws IOException - { - if (!isOpen) return; - - if (Keyboard.getEventKeyState()) - { - if (Keyboard.isRepeatEvent()) - this.keyHeld(Keyboard.getEventKey(), Keyboard.getEventCharacter()); - else - this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - } else { - this.keyReleased(Keyboard.getEventKey(), Keyboard.getEventCharacter()); - } - - this.mc.dispatchKeypresses(); - } - - @Override - public void handleInput() throws IOException { -// Keyboard.enableRepeatEvents(true); // i hope it's temproary solution - super.handleInput(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java deleted file mode 100644 index b79ec148..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui; - -import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -@Getter -public class MPanel { - protected Rectangle bounds = new Rectangle(0,0,0,0); // relative to parent - - protected List childComponents = new CopyOnWriteArrayList(); - - protected Color backgroundColor = new Color(0,0,0,0); - - protected Rectangle lastAbsClip = new Rectangle(0,0,0,0); - - @Getter(AccessLevel.PUBLIC) - @Setter - protected boolean isFocused; - - @Getter - @Setter - protected MPanel parent; - - private boolean debug; - - public void setBackgroundColor(Color c) { - if (c == null) return; - this.backgroundColor = c; - } - - public void setPosition(Point pt) { - this.setBounds(new Rectangle(pt.x, pt.y, getBounds().width, getBounds().height)); - } - - public void setSize(Dimension dim) { - this.setBounds(new Rectangle(getBounds().x, getBounds().y, dim.width, dim.height)); - } - - public Dimension getSize() { - return getBounds().getSize(); - } - - public Dimension getPreferredSize() { return getSize(); } - - public void setBounds(Rectangle bounds) { - if (bounds == null) return; - this.bounds.x = bounds.x; - this.bounds.y = bounds.y; - this.bounds.width = bounds.width; - this.bounds.height = bounds.height; - - for (MPanel childComponent : childComponents) { - childComponent.resize0(getBounds().width, getBounds().height); - } - onBoundsUpdate(); - } - - public void onBoundsUpdate() { - - } - - public void add(MPanel child) { - if (child.parent != null) throw new IllegalArgumentException("What have you done"); - this.childComponents.add(child); - child.setParent(this); - } - - public void openTooltip(MTooltip mPanel) { - parent.openTooltip(mPanel); - } - public int getTooltipsOpen() { - return parent.getTooltipsOpen(); - } - - public void remove(MPanel panel) { - if (panel != null) - panel.setParent(null); - this.childComponents.remove(panel); - } - - protected Point lastParentPoint; - - @Getter - @Setter - private boolean ignoreBoundOnClip; - - public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a - - lastParentPoint = parentPoint; - int relMousex = relMousex0 - getBounds().x; - int relMousey = relMousey0 - getBounds().y; - - GlStateManager.translate(getBounds().x, getBounds().y, 5); - GlStateManager.color(1,1,1,1); - - - Rectangle absBound = getBounds().getBounds(); - absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); - Rectangle clip; - if (ignoreBoundOnClip) clip = parentClip; - else clip = determineClip(parentClip, absBound); - lastAbsClip = clip; - if (clip.getSize().height * clip.getSize().width == 0) return; - - this.scale = scale; - clip(clip.x, clip.y, clip.width, clip.height); - - GL11.glEnable(GL11.GL_SCISSOR_TEST); - - GuiScreen.drawRect(0,0, getBounds().width, getBounds().height, backgroundColor.getRGB()); - GlStateManager.enableBlend(); - - GlStateManager.pushMatrix(); - - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.enableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - - render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); - GlStateManager.popMatrix(); - if (debug && lastAbsClip.contains(absMousex, absMousey)) { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - Gui.drawRect(0, 0, getBounds().width, getBounds().height, 0x2200FF00); - Gui.drawRect(0, 0, getPreferredSize().width, getPreferredSize().height, 0x220000FF); - } - - GL11.glDisable(GL11.GL_SCISSOR_TEST); - - Point newPt = new Point(parentPoint.x + getBounds().x, parentPoint.y + getBounds().y); - - for (MPanel mPanel : getChildComponents()){ - GlStateManager.pushMatrix(); - mPanel.render0(scale, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); - GlStateManager.popMatrix(); - } - } - protected double scale; - public void clip(int x, int y, int width, int height) { - if (width < 0 || height < 0) return; - - GL11.glScissor((int) (x * scale), Minecraft.getMinecraft().displayHeight - (int) ((y + height) * scale), (int)(width* scale + scale) - 1, (int) (height * scale + scale) - 1); - } - - protected Rectangle determineClip(Rectangle rect1, Rectangle rect2) { - int minX = Math.max(rect1.x, rect2.x); - int minY = Math.max(rect1.y, rect2.y); - int maxX = Math.min(rect1.x + rect1.width, rect2.x + rect2.width); - int maxY = Math.min(rect1.y + rect1.height, rect2.y +rect2.height); - if (minX > maxX) return new Rectangle(0,0,0,0); - if (minY > maxY) return new Rectangle(0,0,0,0); - return new Rectangle(minX, minY, maxX - minX, maxY - minY); - } - - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {} - - public void resize0(int parentWidth, int parentHeight) { - resize(parentWidth, parentHeight); - } - - public void resize(int parentWidth, int parentHeight) {} - - - public void keyPressed0(char typedChar, int keyCode) { - for (MPanel childComponent : getChildComponents()) { - childComponent.keyPressed0(typedChar, keyCode); - } - - if (isFocused) - keyPressed(typedChar, keyCode); - } - public void keyPressed(char typedChar, int keyCode) {} - public void keyHeld0(char typedChar, int keyCode) { - for (MPanel childComponent : getChildComponents()) { - childComponent.keyHeld0(typedChar, keyCode); - } - - if (isFocused) - keyHeld(typedChar, keyCode); - } - public void keyHeld(char typedChar, int keyCode) {} - public void keyReleased0(char typedChar, int keyCode) { - for (MPanel childComponent : getChildComponents()) { - childComponent.keyReleased0(typedChar, keyCode); - } - - if (isFocused) - keyReleased(typedChar, keyCode); - } - public void keyReleased(char typedChar, int keyCode) {} - - - public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - boolean noClip = true; - boolean focusedOverall = false; - for (MPanel childComponent : getChildComponents()) { - if (childComponent.mouseClicked0(absMouseX, absMouseY, relMousex, relMousey, mouseButton)) { - noClip = false; - focusedOverall = true; - } - } - - if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { - isFocused = true; - focusedOverall = true; - } else { - isFocused = false; - } - - mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); - return focusedOverall; - } - - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {} - - public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseReleased0(absMouseX, absMouseY, relMousex, relMousey, state); - } - mouseReleased(absMouseX, absMouseY, relMousex, relMousey, state); - } - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {} - - public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseClickMove0(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); - } - mouseClickMove(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); - } - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {} - - public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseScrolled0(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); - } - mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); - } - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {} - - public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - mouseMoved(absMouseX, absMouseY, relMousex, relMousey); - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseMoved0(absMouseX, absMouseY, relMousex, relMousey); - } - } - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) {} - - public void setCursor(EnumCursor enumCursor) { - parent.setCursor(enumCursor); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java deleted file mode 100755 index 1e9bcd0a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; - -@Getter -@Setter -public class MButton extends MPanel { - private String text; - - private Color foreground = Color.white; - private int background = RenderUtils.blendAlpha(0xFF141414, 0.08f); - private int hover = RenderUtils.blendAlpha(0xFF141414, 0.14f); - private int clicked = RenderUtils.blendAlpha(0xFF141414, 0.16f); - private int border = 0x0; - private int disabled =0xFF141414; - private int roundness = 0; - - private boolean enabled = true; - - private Runnable onActionPerformed; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - int bg = background; - if (!enabled) { - bg = disabled; - } else if (getTooltipsOpen() > 0) { - } else if (isclicked) { - bg = clicked; - } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { - bg = hover; - } - if (roundness == 0) { - if (((border >> 24) & 0xFF) == 0) - Gui.drawRect(0, 0, getBounds().width, getBounds().height, bg); - else { - Gui.drawRect(0, 0, getBounds().width, getBounds().height, border); - Gui.drawRect(1, 1, getBounds().width - 1, getBounds().height - 1, bg); - } - } else { - if (((border >> 24) & 0xFF) == 0) - RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, bg); - else { - RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, border); - RenderUtils.drawRoundedRectangle(1, 1, getBounds().width-2, getBounds().height-2, roundness, Math.PI/8, bg); - } - GlStateManager.enableTexture2D(); - } - FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(getText()); - int x = (getBounds().width - width) / 2; - int y = (getBounds().height - renderer.FONT_HEIGHT) / 2 + 1; - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - renderer.drawString(getText(), x,y, foreground.getRGB()); - } - - boolean isclicked = false; - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { - isclicked = true; - if (onActionPerformed != null) - onActionPerformed.run(); - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - } - } - - @Override - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - isclicked = false; - } - - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (lastAbsClip.contains(absMouseX, absMouseY) && enabled) - setCursor(EnumCursor.POINTING_HAND); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java deleted file mode 100644 index 5a0dd4ba..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -/** - * Note it is passive. - */ -public class MCollapsable extends MPanel { - @Getter - @Setter - private boolean collapsed = true; - - private MPanel representing; - @Getter - private MList lowerElements; - - @Getter @Setter - private int leftPad = 0, leftPadElements = 13; - - private Runnable onPreferedSizeChange; - - public MCollapsable(MPanel representing, Runnable onPreferedSizeChange) { - this.representing = representing; - super.add(representing); - lowerElements = new MList(); - lowerElements.setGap(0); - super.add(lowerElements); - - this.onPreferedSizeChange = onPreferedSizeChange; - } - - @Override - public Dimension getPreferredSize() { - Dimension rep = representing.getPreferredSize(); - if (collapsed) { - return new Dimension(rep.width+leftPad+10, rep.height); - } else { - Dimension lowerElem = lowerElements.getPreferredSize(); - return new Dimension(Math.max(rep.width+leftPad+10, leftPadElements + lowerElem.width), rep.height+lowerElem.height+lowerElements.getGap()); - } - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - Dimension representingSize =this.representing.getPreferredSize(); - Dimension lowerSize = lowerElements.getPreferredSize(); - - representing.setBounds(new Rectangle(new Point(leftPad+10, 0), new Dimension(bounds.width - (leftPad+10), representingSize.height))); - lowerElements.setBounds(new Rectangle(new Point(leftPadElements, representingSize.height+lowerElements.getGap()), new Dimension(bounds.width - (leftPadElements), lowerSize.height))); - lowerElements.realignChildren(); - } - - @Override - public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { - super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); - - clip(lastAbsClip.x, lastAbsClip.y, lastAbsClip.width, lastAbsClip.height); - GL11.glEnable(GL11.GL_SCISSOR_TEST); - - - GlStateManager.pushMatrix(); - - - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.enableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - if (collapsed) { - GlStateManager.translate(leftPad + 10 - fr.getStringWidth(">"),(bounds.height - fr.FONT_HEIGHT)/2,0); - } else { - GlStateManager.translate(leftPad + fr.FONT_HEIGHT,(representing.getPreferredSize().height - fr.getStringWidth(">"))/2,0); - GlStateManager.rotate(90, 0,0,1); - } - - fr.drawString(">", 0,0, -1); - - - GlStateManager.popMatrix(); - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } - - @Override - public void add(MPanel child) { - lowerElements.add(child); - if (onPreferedSizeChange != null) onPreferedSizeChange.run(); - } - - @Override - public void remove(MPanel panel) { - lowerElements.remove(panel); - if (onPreferedSizeChange != null) onPreferedSizeChange.run(); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (relMouseX >= leftPad && relMouseY >= 0 && relMouseX <= leftPad + 10 && relMouseY <= representing.getPreferredSize().height) { - collapsed = !collapsed; - if (onPreferedSizeChange != null) onPreferedSizeChange.run(); - } - } - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX, int relMouseY) { - if (relMouseX >= leftPad && relMouseY >= 0 && relMouseX <= leftPad + 10 && relMouseY <= representing.getPreferredSize().height) - setCursor(EnumCursor.POINTING_HAND); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MColor.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MColor.java deleted file mode 100644 index de1f44a4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MColor.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -@AllArgsConstructor -@NoArgsConstructor -public class MColor extends MPanel { - @Getter - @Setter - private Color color = Color.white; - @Getter - @Setter - private Dimension size = new Dimension(20,15); - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Rectangle rectangle = getBounds(); - - int x = (rectangle.width - getSize().width) / 2; - int y = (rectangle.height - getSize().height) / 2; - - Gui.drawRect(x,y,x+getSize().width,y+getSize().height, getColor().getRGB()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MEditableAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MEditableAColor.java deleted file mode 100644 index 888d1e03..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MEditableAColor.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; - -@AllArgsConstructor -@NoArgsConstructor -public class MEditableAColor extends MPanel { - @Getter - @Setter - private AColor color = new AColor(0xffffffff, true); - @Getter - @Setter - private Dimension size = new Dimension(20,15); - - @Getter - @Setter - private boolean enableEdit = false; - - @Getter - @Setter - private Runnable onUpdate; - - public void setEnableEdit(boolean enableEdit) { - this.enableEdit = enableEdit; - if (portable != null && !enableEdit) { - remove(portable); - portable = null; - } - } - - private MPortableColorEdit portable = null; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Rectangle rectangle = getBounds(); - - int x = (rectangle.width - getSize().width) / 2; - int y = (rectangle.height - getSize().height) / 2; - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - Gui.drawRect(x,y,x+getSize().width,y+getSize().height, RenderUtils.getColorAt(absMousex - relMousex0, absMousey - relMousey0, color)); - - Gui.drawRect(x,y,x+getSize().width,y+1, 0xff333333); - Gui.drawRect(x,y,x+1,y+getSize().height, 0xff333333); - Gui.drawRect(x+getSize().width-1,y,x+getSize().width,y+getSize().height, 0xff333333); - Gui.drawRect(x,y+getSize().height-1,x+getSize().width,y+getSize().height, 0xff333333); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (!enableEdit) return; - if (lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { - portable = new MPortableColorEdit() { - @Override - public void update2() { - super.update2(); - MEditableAColor.this.color = portable.getColor(); - if (onUpdate != null) - onUpdate.run(); - } - }; - portable.setColor(color); - Rectangle startWith = new Rectangle((int)(absMouseX * getScale()), (int) (absMouseY* getScale()), (int) (100 * getScale()), (int) (90 * getScale())); - if (startWith.x < 10) startWith.x = 10; - if (startWith.y < 10) startWith.y = 10; - if (startWith.x + startWith.width > Minecraft.getMinecraft().displayWidth - 10) startWith.x = Minecraft.getMinecraft().displayWidth - 10 - startWith.width; - if (startWith.y + startWith.height > Minecraft.getMinecraft().displayHeight - 10) startWith.y = Minecraft.getMinecraft().displayHeight - 10 - startWith.height; - portable.setBounds(startWith); - - - portable.setScale(2.0f); - portable.open(this); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MFloatSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MFloatSelectionButton.java deleted file mode 100755 index 99d7b322..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MFloatSelectionButton.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; - -@Getter -@Setter -public class MFloatSelectionButton extends MPanel { - - private float data; - - private MButton dec; - private MButton inc; - private MTextField selected; - - @Getter - @Setter - private Runnable onUpdate; - - public MFloatSelectionButton(float data2) { - this.data = data2; - - dec = new MButton(); dec.setText("<"); add(dec); - inc = new MButton(); inc.setText(">"); add(inc); - selected = new MTextField() { - @Override - public String getText() { - return data +""; - } - @Override - public void edit(String str) { - try { - data = Float.parseFloat(str); - onUpdate.run(); - } catch (Exception e) {} - } - }; updateSelected(); add(selected); - - dec.setOnActionPerformed(new Runnable() { - @Override - public void run() { - data--; - updateSelected(); - onUpdate.run(); - } - }); - inc.setOnActionPerformed(new Runnable() { - @Override - public void run() { - data ++; - updateSelected(); - onUpdate.run(); - } - }); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(-1,15); - } - - public float getSelected() { - return data; - } - - public void updateSelected() { - selected.setText(data+""); - } - - @Override - public void onBoundsUpdate() { - dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); - inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); - selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MIntegerSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MIntegerSelectionButton.java deleted file mode 100755 index a80b0e7a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MIntegerSelectionButton.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; -import org.lwjgl.input.Keyboard; - -import java.awt.*; - -@Getter -@Setter -public class MIntegerSelectionButton extends MPanel { - - private int data; - - private MButton dec; - private MButton inc; - private MTextField selected; - - @Getter - @Setter - private Runnable onUpdate; - - public MIntegerSelectionButton(int data2) { - this.data = data2; - - dec = new MButton(); dec.setText("<"); add(dec); - inc = new MButton(); inc.setText(">"); add(inc); - selected = new MTextField() { - @Override - public void edit(String str) { - try { - data = Integer.parseInt(str); - onUpdate.run(); - } catch (Exception e) {} - } - }; updateSelected(); add(selected); - - dec.setOnActionPerformed(new Runnable() { - @Override - public void run() { - data -= (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ? 5 : 1); - updateSelected(); - onUpdate.run(); - } - }); - inc.setOnActionPerformed(new Runnable() { - @Override - public void run() { - data += (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ? 5 : 1); - updateSelected(); - onUpdate.run(); - } - }); - } - - - @Override - public Dimension getPreferredSize() { - return new Dimension(-1,15); - } - - public int getSelected() { - return data; - } - - private void updateSelected() { - selected.setText(data+""); - } - - @Override - public void onBoundsUpdate() { - dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); - inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); - selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MKeyEditButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MKeyEditButton.java deleted file mode 100755 index f02a041b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MKeyEditButton.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; - -@Getter -@Setter -public class MKeyEditButton extends MPanel { - private int key; - private Runnable onKeyEdit; - - private Color foreground = Color.white; - private int background = RenderUtils.blendAlpha(0xFF141414, 0.08f); - private int hover = RenderUtils.blendAlpha(0xFF141414, 0.14f); - private int clicked = RenderUtils.blendAlpha(0xFF141414, 0.16f); - private int border = 0x0; - private int disabled =0xFF141414; - private int roundness = 0; - - private boolean enabled = true; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - int bg = background; - if (!enabled) { - bg = disabled; - } else if (getTooltipsOpen() > 0) { - } else if (selected) { - bg = clicked; - } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { - bg = hover; - } - if (roundness == 0) { - if (((border >> 24) & 0xFF) == 0) - Gui.drawRect(0, 0, getBounds().width, getBounds().height, bg); - else { - Gui.drawRect(0, 0, getBounds().width, getBounds().height, border); - Gui.drawRect(1, 1, getBounds().width - 1, getBounds().height - 1, bg); - } - } else { - if (((border >> 24) & 0xFF) == 0) - RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, bg); - else { - RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, border); - RenderUtils.drawRoundedRectangle(1, 1, getBounds().width-2, getBounds().height-2, roundness, Math.PI/8, bg); - } - GlStateManager.enableTexture2D(); - } - - String str = GameSettings.getKeyDisplayString(key); - if (selected) str = "> "+str+" <"; - FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(str); - int x = (getBounds().width - width) / 2; - int y = (getBounds().height - renderer.FONT_HEIGHT) / 2 + 1; - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - renderer.drawString(str, x,y, foreground.getRGB()); - } - - private boolean selected; - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { - if (selected) { - key = -100 + mouseButton; - selected = false; - if (onKeyEdit != null) - onKeyEdit.run(); - } else { - selected = true; - } - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - } else { - selected = false; - } - } - - @Override - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - - } - - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (lastAbsClip.contains(absMouseX, absMouseY) && enabled) - setCursor(EnumCursor.POINTING_HAND); - } - - @Override - public void keyPressed(char typedChar, int keyCode) { - if (!selected) return; - if (keyCode == 1) { - key = 0; - } else if (keyCode != 0) { - key = keyCode; - } else if (typedChar > 0) { - key = typedChar + 256; - } - selected = false; - if (onKeyEdit != null) - onKeyEdit.run(); - throw new RuntimeException("hack to stop event propagation"); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(80, 15); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabel.java deleted file mode 100755 index b9896802..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabel.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; - -public class MLabel extends MPanel { - @Getter - @Setter - private String text; - - @Getter - @Setter - private Color foreground = Color.white; - - public enum Alignment { - LEFT, CENTER, RIGHT - } - @Getter - @Setter - private Alignment alignment= Alignment.LEFT; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(getText()); - int x,y; - if (alignment == Alignment.CENTER) { - x = (getBounds().width - width) / 2; - y = (getBounds().height - renderer.FONT_HEIGHT) / 2; - } else if (alignment == Alignment.LEFT) { - x = 0; - y = (getBounds().height - renderer.FONT_HEIGHT) / 2; - } else if (alignment == Alignment.RIGHT) { - x = getBounds().width - width; - y = (getBounds().height - renderer.FONT_HEIGHT) / 2; - } else{ - return; - } - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - renderer.drawString(getText(), x,y, 0xffffffff); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabelAndElement.java deleted file mode 100755 index c47eda61..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MLabelAndElement.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -public class MLabelAndElement extends MPanel { - private final MLabel label; - private final MPanel element; - - @Getter @Setter - private Color hover; - @Getter @Setter - private Runnable onClick; - - public MLabelAndElement(String label, MPanel element) { - this.add(this.label = new MLabel()); - this.label.setText(label); - this.add(element); - this.element = element; - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(200, 30); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { - Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); - } - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (onClick!= null && lastAbsClip.contains(absMouseX, absMouseY)) { - onClick.run(); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - label.setBounds(new Rectangle(0,0,parentHeight / 3, getBounds().height)); - element.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, getBounds().height)); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); - element.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java deleted file mode 100644 index cb755963..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MList.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -public class MList extends MPanel { - @Getter - private int gap = 5; - - @Getter @Setter - private boolean drawLine = true; - - public void setGap(int gap) { - this.gap = gap; - realignChildren(); - } - - @Getter @Setter - private int gapLineColor = 0xFFFFFFFF; - - public void realignChildren() { - int y = 0; - for (MPanel childComponent : getChildComponents()) { - Dimension preferedSize = childComponent.getPreferredSize(); - int height = Math.max(10, preferedSize.height); - childComponent.setBounds(new Rectangle(0, y, bounds.width, height)); - y += height; - if (gap > 0) - y += gap; - } - setSize(new Dimension(getSize().width, Math.max(0, y-gap))); - } - - @Override - public Dimension getPreferredSize() { - int maxW = 0; - int h = 0; - for (MPanel childComponent : getChildComponents()) { - Dimension preferedSize = childComponent.getPreferredSize(); - int height = Math.max(10, preferedSize.height); - if (preferedSize.width > maxW) maxW = preferedSize.width; - h += height; - if (gap > 0) h += gap; - } - return new Dimension(maxW, Math.max(0, h-gap)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (gap <= 0) return; - if (!drawLine) return; - for (int i = 1; i < getChildComponents().size(); i++) { - MPanel panel = getChildComponents().get(i); - Rectangle bound = panel.getBounds(); - int top = bound.y - (int)Math.ceil(gap/2.0); - Gui.drawRect(0, top, getBounds().width, top + 1, gapLineColor); - } - } - - @Override - public void add(MPanel child) { - super.add(child); - realignChildren(); - } - - @Override - public void remove(MPanel panel) { - super.remove(panel); - realignChildren(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModal.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModal.java deleted file mode 100644 index be2c64d6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModal.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; - -import java.awt.*; - -public class MModal extends MTooltip { - @Getter - private MPanel modalContent = new MPanel(); - - @Getter @Setter - private String title = "Default Title"; - - public MModal() { - super.add(modalContent); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - super.resize(parentWidth, parentHeight); - setBounds(new Rectangle(0,0, parentWidth, parentHeight)); - } - - @Getter @Setter - private Dimension modalSize = new Dimension(300,200); - - - @Override - public void onBoundsUpdate() { - super.onBoundsUpdate(); - Dimension effDim = getEffectiveDimension(); - - modalContent.setBounds(new Rectangle((effDim.width - modalSize.width)/2, (effDim.height - modalSize.height)/2 + 16, modalSize.width, modalSize.height-16)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - RenderUtils.drawGradientRect(0, 0, bounds.width, bounds.height, -1072689136, -804253680); - Dimension effDim = getEffectiveDimension(); - int x = (effDim.width-modalSize.width)/2; - int y = (effDim.height - modalSize.height)/2; - GlStateManager.translate(x,y, 0); - RenderUtils.drawRoundedRectangle(0,0,modalSize.width, modalSize.height, 3, Math.PI/8, RenderUtils.blendAlpha(0x141414, 0.20f)); - Gui.drawRect(0,15, modalSize.width, 16, 0xFF02EE67); - Gui.drawRect(0,16,modalSize.width, 26, RenderUtils.blendAlpha(0x141414, 0.1f)); - RenderUtils.drawRoundedRectangle(0,16,modalSize.width, modalSize.height-16, 3, Math.PI/8, RenderUtils.blendAlpha(0x141414, 0.1f)); - - GlStateManager.enableTexture2D(); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString(title, 5,(16-fr.FONT_HEIGHT)/2, -1); - } - - @Override - public void add(MPanel child) { - modalContent.add(child); - } - - protected void addSuper(MPanel child) { - super.add(child); - } - - @Override - public void remove(MPanel panel) { - modalContent.remove(panel); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalConfirmation.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalConfirmation.java deleted file mode 100644 index 92f3b258..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalConfirmation.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class MModalConfirmation extends MModal { - private String content; - private Runnable callBackYes; - private Runnable callBackNo; - @Getter - private MButton yes, no; - public MModalConfirmation(String title, String content, Runnable callBackYes, Runnable callBackNo) { - super(); - setTitle(title); - this.content = content; - this.callBackYes = callBackYes; - this.callBackNo = callBackNo; - this.yes = new MButton(); - this.no = new MButton(); - yes.setText("Yes"); no.setText("No"); - no.setBackground(RenderUtils.blendAlpha(0x141414, 0.15f)); - no.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); - yes.setOnActionPerformed(() -> { - close(); - if (callBackYes != null) callBackYes.run(); - }); - no.setOnActionPerformed(() -> { - close(); - if (callBackNo != null) callBackNo.run(); - }); - yes.setBackground(RenderUtils.blendAlpha(0x141414, 0.15f)); - yes.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); - - add(new ConfirmationContent()); - } - - public class ConfirmationContent extends MPanel { - public ConfirmationContent() { - add(yes); add(no); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - GlStateManager.translate(5,5,0); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GL11.glDisable(GL11.GL_SCISSOR_TEST); - fr.drawSplitString(content, 0,0, ConfirmationContent.this.bounds.width-10, -1); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - yes.setBounds(new Rectangle(10,bounds.height-25,(bounds.width-30)/2, 15)); - no.setBounds(new Rectangle(yes.getBounds().x + yes.getBounds().width + 10,bounds.height-25,(bounds.width-30)/2, 15)); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalMessage.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalMessage.java deleted file mode 100644 index 28d23d48..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalMessage.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class MModalMessage extends MModal { - private String content; - private Runnable callBackOk; - @Getter - private MButton yes; - public MModalMessage(String title, String content, Runnable callBackOk) { - super(); - setTitle(title); - this.content = content; - this.callBackOk = callBackOk; - this.yes = new MButton(); - yes.setText("Ok"); - yes.setOnActionPerformed(() -> { - close(); - if (callBackOk != null) callBackOk.run(); - }); - yes.setBackground(RenderUtils.blendAlpha(0x141414, 0.15f)); - yes.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); - - add(new MessageContent()); - } - - public class MessageContent extends MPanel { - public MessageContent() { - add(yes); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - GlStateManager.translate(5,5,0); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GL11.glDisable(GL11.GL_SCISSOR_TEST); - fr.drawSplitString(content, 0,0, MModalMessage.MessageContent.this.bounds.width-10, -1); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - yes.setBounds(new Rectangle(10,bounds.height-25,(bounds.width-20), 15)); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java deleted file mode 100755 index 4ad6bd45..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import com.google.common.base.Function; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class MNavigatingPane extends MPanel { - - private final Map pages = new HashMap(); - private final List bookMarks = new ArrayList(); - - @Getter - @Setter - private Function pageGenerator; - - @Getter - private String currentPage = ""; - - public void setCurrentPage(String currentPage) { - this.history.push(this.currentPage); - this.currentPage = currentPage; - } - - @Getter - private Color background2; - - private final Stack history = new Stack(); - - private final MButton back = new MButton(); - - public MNavigatingPane() { - back.setText("<"); - back.setOnActionPerformed(new Runnable() { - @Override - public void run() { - if (history.size() > 0) - currentPage = history.pop(); - } - }); - back.setBackgroundColor(Color.darkGray); - back.setBounds(new Rectangle(3,18,12,12)); - add(back); - } - - public void setBackground2(Color background2) { - this.background2 = background2; - for (MPanel value : pages.values()) { - value.setBackgroundColor(background2); - } - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - - Gui.drawRect(0, 15, getBounds().width, getBounds().height, 0xFF444444); - Gui.drawRect(1, 16, getBounds().width-1, getBounds().height-1, background2 != null ? background2.getRGB() : 0); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(currentPage.replace(".", " > "), 20, 20, 0xFFFFFFFF); - - } - - public void addBookmark(String name, String addr) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - MTabButton button = new MTabButton(this, name, addr); - int totalX = 0; - for (MTabButton button1:bookMarks) - totalX += button1.getBounds().width; - button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(name) + 6), 15)); - bookMarks.add(button); - if (currentPage.isEmpty()) - currentPage = addr; - } - public void addBookmarkRunnable(String name, final Runnable toRun) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - MTabButton button = new MTabButton(this, name, null) { - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY)) { - toRun.run(); - } - } - }; - int totalX = 0; - for (MTabButton button1:bookMarks) - totalX += button1.getBounds().width; - button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(name) + 6), 15)); - bookMarks.add(button); - } - - @Override - public List getChildComponents() { - ArrayList dynamic = new ArrayList(bookMarks); - if (!pages.containsKey(currentPage)) { - MPanel panel = pageGenerator.apply(currentPage); - MPanel panel2 = new MPanel() ; - if (panel != null) - panel2.add(panel); - panel2.setBackgroundColor(background2); - pages.put(currentPage, panel2); - panel2.setBounds(new Rectangle(1,30,getBounds().width-2, getBounds().height-31)); - panel2.setParent(this); - } - dynamic.add(pages.get(currentPage)); - dynamic.add(back); - return dynamic; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - for (MPanel ma:pages.values()) - ma.setBounds(new Rectangle(1,30,getBounds().width-2, getBounds().height-31)); - } - - @Override - public void setBounds(Rectangle bounds) { - if (bounds == null) return; - this.bounds.x = bounds.x; - this.bounds.y = bounds.y; - this.bounds.width = bounds.width; - this.bounds.height = bounds.height; - } - - @Getter - @Setter - public static class MTabButton extends MPanel { - private String text; - private String address; - - private Color foreground = Color.white; - private Color hover = new Color(154, 154, 154, 255); - private Color clicked = new Color(88, 88, 88,255); - private Color selected = new Color(111, 111, 111,255); - private Color disabled = new Color(0,0,0); - - private boolean enabled = true; - - private MNavigatingPane tabbedPane; - - public MTabButton(MNavigatingPane tabbedPane, String key, String address) { - this.tabbedPane = tabbedPane; - this.text = key; - this.address = address; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - Color bg = null; - if (!enabled) { - bg = disabled; - } else if (tabbedPane.getCurrentPage().equals(address)) { - bg = selected; - } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { - bg = hover; - } - Gui.drawRect(0, tabbedPane.getCurrentPage().equals(address) ? 0 : 2, getBounds().width, getBounds().height, 0xFF444444); - if (bg != null) - Gui.drawRect(1,tabbedPane.getCurrentPage().equals(address) ? 1 : 3,getBounds().width - 1, getBounds().height, bg.getRGB()); - - FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(text); - int x = (getBounds().width - width) / 2; - int y = (getBounds().height - 3 - renderer.FONT_HEIGHT) / 2 + 3; - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - renderer.drawString(text, x,y, foreground.getRGB()); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY)) { - tabbedPane.setCurrentPage(address); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java deleted file mode 100644 index ed84b880..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class MPanelScaledGUI extends MPanel { - @Getter - protected double scale = 1.0; - @Getter - protected double relativeScale; - - public void setScale(double scale) { - this.scale = scale; - for (MPanel childComponent : childComponents) { - childComponent.resize0((int) (getBounds().width/scale), (int) (getBounds().height/scale)); - } - onBoundsUpdate(); - } - - @Override - public void setBounds(Rectangle bounds) { - if (bounds == null) return; - this.bounds.x = bounds.x; - this.bounds.y = bounds.y; - this.bounds.width = bounds.width; - this.bounds.height = bounds.height; - - for (MPanel childComponent : childComponents) { - childComponent.resize0((int) (getBounds().width/scale), (int) (getBounds().height/scale)); - } - onBoundsUpdate(); - } - - public Dimension getEffectiveDimension() { - return new Dimension((int)(getBounds().width / scale), (int)(getBounds().height / scale)); - } - - @Override - public void render0(double parentScale, Point parentPoint, Rectangle parentClip, int absMousex0, int absMousey0, int relMousex0, int relMousey0, float partialTicks) { - lastParentPoint = parentPoint; - - GlStateManager.translate(getBounds().x, getBounds().y, 5); - GlStateManager.color(1,1,1,1); - - Rectangle absBound = getBounds().getBounds(); - absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); - - Rectangle clip; - if (isIgnoreBoundOnClip()) clip = parentClip; - else clip = determineClip(parentClip, absBound); - lastAbsClip = clip; - - if (clip.getSize().height * clip.getSize().width == 0) return; - - int absMousex = (int) (absMousex0 / scale), absMousey = (int) (absMousey0 / scale); - int relMousex = (int) ((relMousex0 - getBounds().x) / scale); - int relMousey = (int) ((relMousey0 - getBounds().y) /scale); - - // FROM HERE, IT IS SCALED - - GlStateManager.scale(this.scale, this.scale, 1); - clip = new Rectangle((int) (clip.x / scale), (int) (clip.y / scale), (int) (clip.width / scale), (int) (clip.height / scale)); - lastAbsClip = clip; - - - this.relativeScale = parentScale * this.scale; - clip(clip.x, clip.y, clip.width, clip.height); - - - - GL11.glEnable(GL11.GL_SCISSOR_TEST); - - - GuiScreen.drawRect(0,0, (int) (getBounds().width / scale), (int) (getBounds().height / scale), backgroundColor.getRGB()); - GlStateManager.enableBlend(); - - - GlStateManager.pushMatrix(); - - - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.enableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - - render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); - - GlStateManager.popMatrix(); - - GL11.glDisable(GL11.GL_SCISSOR_TEST); - - - - Point newPt = new Point((int) ((parentPoint.x + getBounds().x) / scale), (int) ((parentPoint.y + getBounds().y) / scale)); - - for (MPanel mPanel : getChildComponents()){ - GlStateManager.pushMatrix(); - - mPanel.render0(relativeScale, newPt,clip,absMousex, absMousey, relMousex, relMousey, partialTicks); - - GlStateManager.popMatrix(); - } - } - - @Override - public void clip(int x, int y, int width, int height) { - if (width < 0 || height < 0) return; - - GL11.glScissor((int) (x * relativeScale), Minecraft.getMinecraft().displayHeight - (int) ((y + height+1) * relativeScale), (int)((width+1)* relativeScale), (int) ((height+1) * relativeScale)); - } - - @Override - public void resize0(int parentWidth, int parentHeight) { - super.resize0(parentWidth, parentHeight); - } - - - public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { - int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); - int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); - absMouseX = (int) (absMouseX / scale); - absMouseY = (int) (absMouseY / scale); - - boolean noClip = true; - boolean focusedOverall = false; - for (MPanel childComponent : getChildComponents()) { - if (childComponent.mouseClicked0(absMouseX, absMouseY,relMousex, relMousey, mouseButton)) { - noClip = false; - focusedOverall = true; - } - } - - if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { - isFocused = true; - focusedOverall = true; - } else { - isFocused = false; - } - mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); - - return focusedOverall; - } - public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { - int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); - int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); - absMouseX = (int) (absMouseX / scale); - absMouseY = (int) (absMouseY / scale); - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseReleased0(absMouseX, absMouseY, relMousex, relMousey, state); - } - mouseReleased(absMouseX, absMouseY, relMousex, relMousey, state); - } - public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { - int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); - int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); - absMouseX = (int) (absMouseX / scale); - absMouseY = (int) (absMouseY / scale); - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseClickMove0(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); - } - mouseClickMove(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); - } - public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); - int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); - absMouseX = (int) (absMouseX / scale); - absMouseY = (int) (absMouseY / scale); - - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseScrolled0(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); - } - mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); - } - - @Override - public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); - int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); - absMouseX = (int) (absMouseX / scale); - absMouseY = (int) (absMouseY / scale); - - mouseMoved(absMouseX, absMouseY, relMousex, relMousey); - for (MPanel childComponent : getChildComponents()) { - childComponent.mouseMoved0(absMouseX, absMouseY, relMousex, relMousey); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MParameter.java deleted file mode 100755 index ee9b0619..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MParameter.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; -import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -public class MParameter extends MPanel { - private final MLabel label; - private final MLabel data; - - @Getter @Setter - private Color hover = Color.gray; - - @Getter @Setter - private Parameter parameter; - private final DynamicEditor processorParameterEditPane; - - public MParameter(final Parameter parameter, DynamicEditor processorParameterEditPane) { - this.processorParameterEditPane = processorParameterEditPane; - this.add(this.label = new MLabel() { - @Override - public String getText() { - return parameter.getName(); - } - }); - this.add(this.data = new MLabel() { - @Override - public String getText() { - return parameter.getNewData() != null ?parameter.getNewData().toString() :"-empty-"; - } - }); - this.label.setAlignment(MLabel.Alignment.LEFT); - this.data.setAlignment(MLabel.Alignment.RIGHT); - - this.parameter = parameter; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { - Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); - } - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (this.getBounds().x > -20 && lastAbsClip.contains(absMouseX, absMouseY)) { - // open new gui; - EditingContext.getEditingContext().openGui(new GuiDungeonParameterEdit(this, processorParameterEditPane)); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - label.setBounds(new Rectangle(0,0,parentHeight / 3, getBounds().height)); - data.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, getBounds().height)); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); - data.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java deleted file mode 100755 index 4a56d411..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; - -public class MPassiveLabelAndElement extends MPanel { - private final MLabel label; - private final MPanel element; - - @Getter @Setter - private Color hover; - @Getter @Setter - private Runnable onClick; - - @Getter @Setter - private double divideRatio = 1/3.0; - - public MPassiveLabelAndElement(String label, MPanel element) { - this.add(this.label = new MLabel()); - this.label.setText(label); - this.add(element); - this.element = element; - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(100, 20); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { - Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); - } - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (onClick!= null && lastAbsClip.contains(absMouseX, absMouseY)) { - onClick.run(); - } - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0, (int) (getBounds().width * divideRatio), getBounds().height)); - element.setBounds(new Rectangle((int) (getBounds().width * divideRatio),0, (int) (getBounds().width * (1-divideRatio)), getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPopupMenu.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPopupMenu.java deleted file mode 100644 index 6db97d51..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPopupMenu.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.MathHelper; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.List; - -public class MPopupMenu extends MTooltip { - private int x, y; - public MPopupMenu(int x, int y, List popupMenuElementList) { - this.x = x; this.y = y; - int maxWidth = 150; - for (MPanel mPanel : popupMenuElementList) { - Dimension dimension = mPanel.getPreferredSize(); - if (dimension.width > maxWidth) maxWidth = dimension.width; - } - int h1 = 7; - for (MPanel mPanel : popupMenuElementList) { - Dimension dimension = mPanel.getPreferredSize(); - mPanel.setBounds(new Rectangle(7,h1, maxWidth-13, dimension.height)); - h1 += dimension.height + 7; - add(mPanel); - } - - if (y + h1 > Minecraft.getMinecraft().displayHeight) - y = Minecraft.getMinecraft().displayHeight - h1; - if (x + maxWidth+ 2 > Minecraft.getMinecraft().displayWidth) - x = Minecraft.getMinecraft().displayWidth - maxWidth-2; - setBounds(new Rectangle(x,y,maxWidth+2, h1)); - } - - @Override - public void setScale(double scale) { - super.setScale(scale); - - int maxWidth = 150; - for (MPanel mPanel : getChildComponents()) { - Dimension dimension = mPanel.getPreferredSize(); - if (dimension.width > maxWidth) maxWidth = dimension.width; - } - int h1 = 7; - for (MPanel mPanel : getChildComponents()) { - Dimension dimension = mPanel.getPreferredSize(); - mPanel.setBounds(new Rectangle(7,h1, maxWidth-13, dimension.height)); - h1 += dimension.height + 7; - } - maxWidth += 2; - maxWidth *= scale; h1 *= scale; - - if (y + h1 > Minecraft.getMinecraft().displayHeight) - y = Minecraft.getMinecraft().displayHeight - h1; - if (x + maxWidth > Minecraft.getMinecraft().displayWidth) - x = Minecraft.getMinecraft().displayWidth - maxWidth; - setBounds(new Rectangle(x,y,maxWidth, h1)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); - int radius = 7; - double deltaDegree = Math.PI/6; - Dimension effectiveDim = getEffectiveDimension(); - RenderUtils.drawRoundedRectangle(0,0,effectiveDim.width,effectiveDim.height,radius,deltaDegree, RenderUtils.blendAlpha(0x121212, 0.0f)); - for (int i = 1; i < getChildComponents().size(); i++) { - MPanel childComponent = getChildComponents().get(i); - Gui.drawRect(7,childComponent.getBounds().y - 4, effectiveDim.width-7, childComponent.getBounds().y - 3, RenderUtils.blendAlpha(0x121212, 0.10f)); - } - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (!lastAbsClip.contains(absMouseX, absMouseY)) { - close(); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPortableColorEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPortableColorEdit.java deleted file mode 100644 index f8a7281a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPortableColorEdit.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.MathHelper; -import org.apache.commons.lang3.StringUtils; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class MPortableColorEdit extends MTooltip { - - private final float[] hsv = new float[3]; - private float alpha = 0; - private float chromaSpeed = 0; - - @Getter - private AColor color; - - private final MTextField textField; - - public MPortableColorEdit() { - textField = new MTextField() { - @Override - public void edit(String str) { - if (str.length() >= 7 && str.startsWith("#")) { - String color = str.substring(1); - try { - long colorInt = Long.parseLong(color, 16); - - Color.RGBtoHSB((int) (colorInt >> 16) & 0xFF, (int) (colorInt >> 8) & 0xFF, (int) colorInt & 0xFF, hsv); - if (color.length() >= 8) - alpha = ((int) ((colorInt >> 24) & 0xFF)) / 255.0f; - update2(); - } catch (Exception e) {} - } - } - }; - add(textField); - } - - @Override - public void onBoundsUpdate() { - super.onBoundsUpdate(); - - textField.setBounds(new Rectangle(5, getEffectiveDimension().height - 25, getEffectiveDimension().width - 10, 20)); - } - - public void setColor(AColor color) { - this.color = color; - - alpha = color.getAlpha() / 255.0f; - chromaSpeed = color.isChroma() ? color.getChromaSpeed() : 0; - Color.RGBtoHSB(color.getRed(), color.getBlue(), color.getGreen(), hsv); - - int rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); - rgb = (rgb & 0xFFFFFF) | ((int)(alpha * 255) << 24); - textField.setText("#" + StringUtils.leftPad(Integer.toHexString(rgb).toUpperCase(), 8, '0')); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Dimension size = getEffectiveDimension(); - - Gui.drawRect(0,0,size.width,size.height, 0xff333333); - Gui.drawRect(1,1,size.width-1,size.height-1, 0xffa1a1a1); - - int width = size.height- 35; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - int shademodel = GL11.glGetInteger(GL11.GL_SHADE_MODEL); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - GlStateManager.enableBlend(); - GlStateManager.disableDepth(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - // worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); - - int rgb = Color.HSBtoRGB(hsv[0], hsv[1], 1); - float r = (rgb >> 16 & 255) / 255.0f; - float g = (rgb >> 8 & 255) / 255.0f; - float b = (rgb & 255) / 255.0f; - GL11.glBegin(GL11.GL_TRIANGLES); - GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(15+width ,5, 0); - GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(10+width , 5, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(15+width , 5+width, 0); - - GlStateManager.color(0,0,0,alpha); GL11.glVertex3i(10+width , 5, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(10+width , 5 + width, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(15+width , 5+width, 0); - GL11.glEnd(); - rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); - r = (rgb >> 16 & 255) / 255.0f; - g = (rgb >> 8 & 255) / 255.0f; - b = (rgb & 255) / 255.0f; - GL11.glBegin(GL11.GL_TRIANGLES); - GlStateManager.color(r,g,b,0);GL11.glVertex3i(25+width ,5, 0); - GlStateManager.color(r,g,b,0);GL11.glVertex3i(20+width , 5, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 5+width, 0); - - GlStateManager.color(r,g,b,0); GL11.glVertex3i(20+width , 5, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(20+width , 5+ width, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 5+width, 0); - GL11.glEnd(); - - - GL11.glBegin(GL11.GL_TRIANGLES); - rgb = RenderUtils.getChromaColorAt(0,0, chromaSpeed, hsv[1], hsv[2], alpha); - r = (rgb >> 16 & 255) / 255.0f; - g = (rgb >> 8 & 255) / 255.0f; - b = (rgb & 255) / 255.0f; - GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width ,5, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(30+width , 5, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width , 5+width, 0); - - GlStateManager.color(r,g,b,1); GL11.glVertex3i(30+width , 5, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(30+width , 5+ width, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width , 5+width, 0); - GL11.glEnd(); - - - - float radius = width/2f; - float cx = 5 + radius; - float cy = 5 + radius; - - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GlStateManager.color(1,1,1,alpha); - GL11.glVertex3f(cx,cy,0); - for (int i = 0; i <= 360; i++) { - float rad = 3.141592653f * i / 180; - int rgb2 = Color.HSBtoRGB(i / 360f, 1, hsv[2]); - float r2 = (rgb2 >> 16 & 255) / 255.0f; - float g2 = (rgb2 >> 8 & 255) / 255.0f; - float b2 = (rgb2 & 255) / 255.0f; - GlStateManager.color(r2,g2,b2, alpha); - GL11.glVertex3f(MathHelper.sin(rad) * radius + cx, MathHelper.cos(rad) * radius + cy, 0); - } - GL11.glEnd(); - GlStateManager.shadeModel(shademodel); - - GlStateManager.color(1,1,1,1); - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); - float rad2 = 2 * 3.141592653f * hsv[0] ; - float x = 5 + radius + (MathHelper.sin(rad2)) * hsv[1] * radius; - float y = 5 + radius + (MathHelper.cos(rad2))* hsv[1] * radius; - for (int i = 0; i < 100; i++) { - float rad = 2 * 3.141592653f * (i / 100f); - worldrenderer.pos(MathHelper.sin(rad) * 2 + x, MathHelper.cos(rad) * 2 + y, 0).endVertex(); - } - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(8+width, 5 + (hsv[2]) * width, 0.5).endVertex(); - worldrenderer.pos(17+width, 5 + (hsv[2]) * width, 0.5).endVertex(); - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(18+width, 5 + (alpha) * width, 0.5).endVertex(); - worldrenderer.pos(27+width, 5 + (alpha) * width, 0.5).endVertex(); - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(28+width, 5 + (chromaSpeed) * width, 0.5).endVertex(); - worldrenderer.pos(37+width, 5 + (chromaSpeed) * width, 0.5).endVertex(); - tessellator.draw(); - - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.color(1,1,1,1); - GlStateManager.color(1,1,1,1); - } - - private int selected = 0; - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - int width = getEffectiveDimension().height- 35; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 5 + radius; - - selected = 0; - if (!lastAbsClip.contains(absMouseX, absMouseY)) { - close(); - return; - } - - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (dx * dx + dy * dy <= radius * radius) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180+90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.sqrt_float(dx * dx + dy * dy) / radius; - selected = 1; - } - } - { - if (10+width <= relMouseX && relMouseX <= 15 + width && - 5 <= relMouseY && relMouseY <= 5 + width) { - hsv[2] = (relMouseY - 5) / (float)width; - selected = 2; - } - } - { - if (20+width <= relMouseX && relMouseX <= 25 + width && - 5 <= relMouseY && relMouseY <= 5 + width) { - alpha = (relMouseY - 5) / (float)width; - selected = 3; - } - } - { - if (30+width <= relMouseX && relMouseX <= 35 + width && - 5 <= relMouseY && relMouseY <= 5 + width) { - chromaSpeed = (relMouseY - 5) / (float)width; - selected = 4; - } - } - update(); - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - int width = getEffectiveDimension().height- 35; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 5 + radius; - { - // check circle - float dx = relMouseX - circleX; // sin theta - float dy = circleY - relMouseY; // cos theta - if (selected == 1) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180+90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.clamp_float(MathHelper.sqrt_float(dx * dx + dy * dy) / radius, 0, 1); - } - } - { - if (selected == 2) { - hsv[2] = MathHelper.clamp_float((relMouseY - 5) / (float)width, 0, 1); - } - if (selected == 3) { - alpha = MathHelper.clamp_float((relMouseY - 5) / (float)width, 0, 1); - } - if (selected == 4) { - chromaSpeed = MathHelper.clamp_float((relMouseY - 5) / (float)width, 0, 1); - } - } - update(); - } - - - public void update() { - int rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); - rgb = (rgb & 0xFFFFFF) | ((int)(alpha * 255) << 24); - textField.setText("#" + StringUtils.leftPad(Integer.toHexString(rgb).toUpperCase(), 8, '0')); - update2(); - } - - public void update2() { - color = new AColor(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0xffffff | (MathHelper.clamp_int((int)(alpha * 255), 0, 255) << 24), true); - color.setChromaSpeed(chromaSpeed); - color.setChroma(chromaSpeed != 0); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java deleted file mode 100644 index 4172acb8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.Getter; -import lombok.Setter; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -@Getter -public class MRootPanel extends MPanel { - @Getter - private List tooltips = new CopyOnWriteArrayList<>(); - - - @Override - public void openTooltip(MTooltip mPanel) { - mPanel.setRoot(this); - tooltips.add(mPanel); - mPanel.resize(getBounds().width, getBounds().height); - add(mPanel); - } - - @Override - public int getTooltipsOpen() { - return tooltips.size(); - } - - public void removeTooltip(MTooltip mTooltip) { - mTooltip.setRoot(null); - tooltips.remove(mTooltip); - remove(mTooltip); - } - - @Getter @Setter - private EnumCursor currentCursor = EnumCursor.DEFAULT; - @Override - public void setCursor(EnumCursor enumCursor) { - currentCursor = enumCursor; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java deleted file mode 100644 index dbc30e7e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; -import net.minecraft.util.MathHelper; - -import java.awt.*; - -public class MScrollBar extends MPanel { - private final Axis axis; - @Setter - @Getter - private int thumbSize, max, min; - @Setter - @Getter - private int current; - - @Getter - @Setter - private int width = 10; - - public void setMax(int max) { - if (max < min) max = min; - this.max = max; - - current = MathHelper.clamp_int(current, min, max); - if (onUpdate != null) onUpdate.run(); - } - - public void setMin(int min) { - if (max < min) max = min; - this.min = min; - - current = MathHelper.clamp_int(current, min, max); - if (onUpdate != null) onUpdate.run(); - } - - public void setThumbSize(int thumbSize) { - this.thumbSize = thumbSize; - - current = MathHelper.clamp_int(current, min, max); - if (onUpdate != null) onUpdate.run(); - } - - public void addToCurrent(int dv) { - int current2 = current + dv; - - current = MathHelper.clamp_int(current2, min, max); - - if (onUpdate != null) onUpdate.run(); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(axis == Axis.X ? -1 : width, axis == Axis.Y ? -1 : width); - } - - @Getter - @Setter - private int background = RenderUtils.blendAlpha(0xFF141414, 0.04f), - thumb = RenderUtils.blendAlpha(0xFF141414, 0.14f), - thumbHover = RenderUtils.blendAlpha(0xFF141414, 0.15f), - thumbClick = RenderUtils.blendAlpha(0xFF141414, 0.20f); - - private Runnable onUpdate; - - public MScrollBar(int min, int max, int thumbSize, int current, Axis axis, Runnable onUpdate) { - if (max < min) max = min; - this.min = min; this.min = max; this.thumbSize = thumbSize; this.current = current; this.axis = axis; - this.current = MathHelper.clamp_int(current, min, max); - this.onUpdate = onUpdate; - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - lastThumbRect.width = 0; lastThumbRect.height = 0; - } - - private Rectangle lastThumbRect = new Rectangle(); - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - // RENDER SUPER NICE SCROLL BAR - int minimalThumbLen = 20; - - Gui.drawRect(0,0,getBounds().width, getBounds().height, background); - int length = axis == Axis.X ? bounds.width :bounds.height; - int totalUnscaledLength = max-min + thumbSize; - double subPoint = ((double)max-min) * length / totalUnscaledLength; - if (length - subPoint < minimalThumbLen) { - subPoint = length - minimalThumbLen; - } - double thumbSize = length - subPoint; - - double startPt; - if (max - min == 0) { - startPt =0; - } else { - startPt = subPoint * (current - min)/((double)max - min); - } - - int color = thumbHover; - if (getBounds().contains(relMousex0, relMousey0)) color = thumbHover; - if (grabbed) color = thumbClick; - - if (axis == Axis.X) { - int startX = (int) startPt; - int endX = (int) (startPt + thumbSize); - - Gui.drawRect(startX,0,endX,getBounds().height, color); - lastThumbRect.x = startX; lastThumbRect.y = 0; lastThumbRect.width = endX - startX; lastThumbRect.height = getBounds().height; - } else if (axis == Axis.Y) { - int startY = (int) startPt; - int endY = (int) (startPt + thumbSize); - - Gui.drawRect(0,startY,getBounds().width,endY, color); - lastThumbRect.x = 0; lastThumbRect.y = startY; lastThumbRect.width = getBounds().width; lastThumbRect.height = endY - startY; - } - } - - private int lastX; - private int lastY; - private int actualValue; - private boolean grabbed; - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (!lastAbsClip.contains(absMouseX, absMouseY)) return; - if (getTooltipsOpen() > 0) return; - grabbed = true; - actualValue = current; - lastX = absMouseX; - lastY = absMouseY; - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - if (!grabbed) return; - - int minimalThumbLen = 20; - - Gui.drawRect(0,0,getBounds().width, getBounds().height, background); - int length = axis == Axis.X ? bounds.width :bounds.height; - int totalUnscaledLength = max-min + thumbSize; - double subPoint = ((double)max-min) * length / totalUnscaledLength; - if (length - subPoint < minimalThumbLen) { - subPoint = length - minimalThumbLen; - } - double thumbSize = length - subPoint; - - - - int dx = absMouseX - lastX, dy = absMouseY - lastY; - - lastX = absMouseX; - lastY = absMouseY; - - int prevVal = current; - if (axis == Axis.Y) { - actualValue += dy * (max - min) / subPoint; - } else if (axis == Axis.X) { - actualValue += dx * (max - min) / subPoint; - } - - current = MathHelper.clamp_int(actualValue, min, max); - - if (onUpdate != null && prevVal != current) onUpdate.run(); - } - - @Override - public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { - grabbed= false; - } - - public static enum Axis { - X, Y - } - - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (grabbed) - setCursor(EnumCursor.CLOSED_HAND); - else if (lastThumbRect.contains(relMouseX0, relMouseY0)) { - setCursor(EnumCursor.OPEN_HAND); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java deleted file mode 100644 index d5f27227..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; -import net.minecraft.util.MathHelper; -import org.w3c.dom.css.Rect; - -import java.awt.*; - -public class MScrollablePanel extends MPanel { - @Getter - private boolean hideScrollBarWhenNotNecessary = false; - - public void setHideScrollBarWhenNotNecessary(boolean hideScrollBarWhenNotNecessary) { - this.hideScrollBarWhenNotNecessary = hideScrollBarWhenNotNecessary; - setBounds(getBounds()); - } - - private final int axis; // 1: Y 2: X 3: both. - - - private MPanel viewPort; - @Getter - private MPanel contentArea; - @Getter - private MScrollBar scrollBarX, scrollBarY; - - private Rectangle contentAreaDim; - - public MScrollablePanel(int axis) { - this.axis = axis; - viewPort = new MPanel(); - scrollBarX = new MScrollBar(0, 1, 1, 0, MScrollBar.Axis.X, this::onScrollBarUpdate); - scrollBarY = new MScrollBar(0, 1, 1, 0, MScrollBar.Axis.Y, this::onScrollBarUpdate); - - if ((axis & 1) > 0) - super.add(scrollBarY); - if ((axis & 2) > 0) - super.add(scrollBarX); - super.add(viewPort); - - - contentArea = new MPanel() { - @Override - public void add(MPanel child) { - super.add(child); - evalulateContentArea(); - } - - @Override - public void remove(MPanel panel) { - super.remove(panel); - evalulateContentArea(); - } - - @Override - public void setBounds(Rectangle bounds) { - if (bounds == null) return; - this.bounds.x = bounds.x; - this.bounds.y = bounds.y; - this.bounds.width = bounds.width; - this.bounds.height = bounds.height; - - onBoundsUpdate(); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - for (MPanel childComponent : childComponents) { - childComponent.resize0(parentWidth, parentHeight); - } - evalulateContentArea(); - } - }; - viewPort.add(contentArea); - contentArea.setIgnoreBoundOnClip(true); - evalulateContentArea(); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); - - boolean hideX = (axis & 2) == 0, hideY = (axis & 1) == 0; - if (bounds.width >= contentAreaDim.width && hideScrollBarWhenNotNecessary) hideX = true; - if (bounds.height >= contentAreaDim.height && hideScrollBarWhenNotNecessary) hideY = true; - if (axis == 3 && !(hideX && hideY)) { - Gui.drawRect(scrollBarX.getBounds().width, scrollBarY.getBounds().height, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.03f)); - } - } - - public void evalulateContentArea() { - if (contentArea.getChildComponents().size() == 0) { - contentAreaDim= new Rectangle(0,0,0,0); - return; - } - int minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE; - for (MPanel childComponent : contentArea.getChildComponents()) { - Rectangle bounds = childComponent.getBounds(); - if (bounds.x < minX) minX = bounds.x; - if (bounds.x + bounds.width > maxX) maxX = bounds.x + bounds.width; - if (bounds.y < minY) minY = bounds.y; - if (bounds.y + bounds.height > maxY) maxY = bounds.y + bounds.height; - } - contentAreaDim = new Rectangle(minX, minY, maxX - minX, maxY - minY); - scrollBarX.setMin(contentAreaDim.x); - scrollBarX.setMax(contentAreaDim.x + contentAreaDim.width-scrollBarX.getThumbSize()); - scrollBarY.setMin(contentAreaDim.y); - scrollBarY.setMax(contentAreaDim.y + contentAreaDim.height-scrollBarY.getThumbSize()); - } - - @Override - public void setBounds(Rectangle bounds) { - super.setBounds(bounds); - boolean hideX = (axis & 2) == 0, hideY = (axis & 1) == 0; - viewPort.setBounds(new Rectangle(0,0,bounds.width, bounds.height)); - evalulateContentArea(); - if (bounds.width >= contentAreaDim.width && hideScrollBarWhenNotNecessary) hideX = true; - if (bounds.height >= contentAreaDim.height && hideScrollBarWhenNotNecessary) hideY = true; - - if (!(hideX || hideY)) { - Dimension preferedX = scrollBarX.getPreferredSize(); - Dimension preferedY = scrollBarY.getPreferredSize(); - scrollBarY.setBounds(new Rectangle(bounds.width - preferedY.width, 0, preferedY.width, bounds.height - preferedX.height)); - scrollBarX.setBounds(new Rectangle(0, bounds.height - preferedX.height, bounds.width - preferedY.width, preferedX.height)); - } else if ((hideY && !hideX)) { - Dimension preferedX = scrollBarX.getPreferredSize(); - scrollBarY.setBounds(new Rectangle(0,0,0,0)); - scrollBarX.setBounds(new Rectangle(0, bounds.height - preferedX.height, bounds.width, preferedX.height)); - } else if ((hideX && !hideY)) { - Dimension preferedY = scrollBarY.getPreferredSize(); - scrollBarX.setBounds(new Rectangle(0,0,0,0)); - scrollBarY.setBounds(new Rectangle(bounds.width - preferedY.width, 0, preferedY.width, bounds.height)); - } else if (hideX && hideY){ - scrollBarY.setBounds(new Rectangle(0,0,0,0)); - scrollBarX.setBounds(new Rectangle(0,0,0,0)); - } - - viewPort.setBounds(new Rectangle(0,0,bounds.width-scrollBarY.getBounds().width, bounds.height - scrollBarX.getBounds().height)); - - scrollBarX.setThumbSize(viewPort.getBounds().width); - scrollBarY.setThumbSize(viewPort.getBounds().height); - scrollBarX.setMax(contentAreaDim.x + contentAreaDim.width-scrollBarX.getThumbSize()); - scrollBarY.setMax(contentAreaDim.y + contentAreaDim.height-scrollBarY.getThumbSize()); - evalulateContentArea(); - } - - - private void onScrollBarUpdate() { - contentArea.setPosition(new Point(-scrollBarX.getCurrent(), -scrollBarY.getCurrent())); - } - - - @Override - public void add(MPanel child) { contentArea.add(child); } - - @Override - public void remove(MPanel panel) { contentArea.remove(panel); } - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (lastAbsClip.contains(absMouseX, absMouseY) && (axis == 1 || axis == 3)) { - scrollBarY.addToCurrent(MathHelper.clamp_int(scrollAmount, -1, 1) * -30); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MSpacer.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MSpacer.java deleted file mode 100644 index 11336a7c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MSpacer.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; - -import java.awt.*; - -public class MSpacer extends MPanel { - - int width, height; - public MSpacer(int x, int y, int width, int height) { - setBounds(new Rectangle(x,y,width,height)); - this.width = width; this.height = height; - } - @Override - public Dimension getPreferredSize() { - return new Dimension(width, height); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MStringSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MStringSelectionButton.java deleted file mode 100755 index f2dcadce..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MStringSelectionButton.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; -import java.util.List; - -@Getter -@Setter -public class MStringSelectionButton extends MPanel { - - private List possible; - private int selectedIndex; - - private MButton dec; - private MButton inc; - private MLabel selected; - - @Getter - @Setter - private Runnable onUpdate; - - public MStringSelectionButton(final List possible, String defaultValue) { - this.possible = possible; - selectedIndex = possible.indexOf(defaultValue); - if (selectedIndex == -1) selectedIndex = 0; - - dec = new MButton(); dec.setText("<"); add(dec); - inc = new MButton(); inc.setText(">"); add(inc); - selected = new MLabel(); updateSelected(); add(selected); - selected.setBackgroundColor(Color.black); - selected.setAlignment(MLabel.Alignment.CENTER); - - dec.setOnActionPerformed(new Runnable() { - @Override - public void run() { - selectedIndex --; - if (selectedIndex < 0) selectedIndex = possible.size() - 1; - updateSelected(); - onUpdate.run(); - } - }); - inc.setOnActionPerformed(new Runnable() { - @Override - public void run() { - selectedIndex++; - if (selectedIndex >= possible.size()) selectedIndex = 0; - updateSelected(); - onUpdate.run(); - } - }); - } - - public String selectionToDisplay(String selection) { - return selection; - } - - public String getSelected() { - if (possible.size() == 0) return null; - return possible.get(selectedIndex); - } - - private void updateSelected() { - if (possible.size() == 0) selected.setText("-Empty-"); - else selected.setText(selectionToDisplay(possible.get(selectedIndex))); - } - - @Override - public void onBoundsUpdate() { - dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); - inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); - selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java deleted file mode 100755 index ba56679b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class MTabbedPane extends MPanel { - - private final Map tabs = new HashMap(); - private final Map buttons = new HashMap(); - - @Getter - @Setter - private String selectedKey = ""; - - @Getter - private Color background2; - - public void setBackground2(Color background2) { - this.background2 = background2; - for (MPanel value : tabs.values()) { - value.setBackgroundColor(background2); - } - for (MTabButton value : buttons.values()) { - value.setBackgroundColor(background2.brighter()); - } - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - Gui.drawRect(0, 15, getBounds().width, getBounds().height, 0xFF444444); - } - - public void addTab(String tab, MPanel panel) { - MPanel panel2 = new MPanel() ; - panel2.add(panel); - panel2.setBackgroundColor(background2); - tabs.put(tab, panel2); - panel2.setParent(this); - panel2.setBounds(new Rectangle(1,16,getBounds().width-2, getBounds().height-17)); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - MTabButton button = new MTabButton(this, tab); - int totalX = 0; - for (MTabButton button1:buttons.values()) - totalX += button1.getBounds().width; - button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(tab) + 6), 15)); - buttons.put(tab, button); - if (tabs.size() == 1) - selectedKey = tab; - } - - @Override - public List getChildComponents() { - ArrayList dynamic = new ArrayList(buttons.values()); - dynamic.add(tabs.get(selectedKey)); - return dynamic; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - for (MPanel ma:tabs.values()) - ma.setBounds(new Rectangle(1,16,getBounds().width-2, getBounds().height-17)); - } - - @Override - public void setBounds(Rectangle bounds) { - if (bounds == null) return; - this.bounds.x = bounds.x; - this.bounds.y = bounds.y; - this.bounds.width = bounds.width; - this.bounds.height = bounds.height; - } - - @Getter - @Setter - public static class MTabButton extends MPanel { - private String text; - - private Color foreground = Color.white; - private Color hover = new Color(154, 154, 154, 255); - private Color clicked = new Color(88, 88, 88,255); - private Color selected = new Color(111, 111, 111,255); - private Color disabled = new Color(0,0,0); - - private boolean enabled = true; - - private MTabbedPane tabbedPane; - - public MTabButton(MTabbedPane tabbedPane, String key) { - this.tabbedPane = tabbedPane; - this.text = key; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - Color bg = null; - if (!enabled) { - bg = disabled; - } else if (tabbedPane.getSelectedKey().equals(text)) { - bg = selected; - } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { - bg = hover; - } - Gui.drawRect(0, tabbedPane.getSelectedKey().equals(text) ? 0 : 2, getBounds().width, getBounds().height, 0xFF444444); - if (bg != null) - Gui.drawRect(1,tabbedPane.getSelectedKey().equals(text) ? 1 : 3,getBounds().width - 1, getBounds().height, bg.getRGB()); - - FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(text); - int x = (getBounds().width - width) / 2; - int y = (getBounds().height - 3 - renderer.FONT_HEIGHT) / 2 + 3; - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - renderer.drawString(text, x,y, foreground.getRGB()); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY)) { - tabbedPane.setSelectedKey(text); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java deleted file mode 100755 index d87c08e3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.MathHelper; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.awt.datatransfer.*; -import java.awt.event.KeyEvent; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -@Getter -public class MTextField extends MPanel { - private final Color foreground = Color.white; - private final Color placeHolderColor = Color.lightGray; - - private String text = ""; - @Setter - private String placeHolder = ""; - private int cursorBlickTicker = 0; - - private int selectionStart = 0; - private int selectionEnd = 0; - - private int cursor = 0; - - private int xOffset = 0; - - public void edit(String str) { - - } - - - @Override - public Dimension getPreferredSize() { - return new Dimension(-1,15); - } - - public void setText(String text) { - this.text = text; - } - private void setText0(String text) { - this.text = text; - edit(text); - } - - private void setCursor0(int cursor) { - if (cursor > text.length()) cursor = text.length(); - if (cursor < 0) cursor = 0; - this.cursor = cursor; - - - int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text.substring(0, cursor)); - int cursorX = width + 3- xOffset; - cursorX = MathHelper.clamp_int(cursorX,10, getBounds().width - 10); - xOffset = width+ 3 - cursorX; - xOffset = MathHelper.clamp_int(xOffset, 0,Math.max(0, Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) - getBounds().width+10)); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - clip(clip.x - 1, clip.y - 1, clip.width +2, clip.height + 2); - Gui.drawRect(0,0,getBounds().width, getBounds().height, isFocused ? Color.white.getRGB() : Color.gray.getRGB()); - Gui.drawRect(1,1,getBounds().width - 1, getBounds().height - 1, Color.black.getRGB()); - - Minecraft mc = Minecraft.getMinecraft(); - clip(clip.x + 1, clip.y + 1, clip.width - 2, clip.height - 2); - FontRenderer fr = mc.fontRendererObj; - int y = (getBounds().height - fr.FONT_HEIGHT) / 2; - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(text, 3 - xOffset, y, foreground.getRGB()); - if (text.isEmpty()) - fr.drawString(placeHolder, 3, y, placeHolderColor.getRGB()); - // draw selection - if (isFocused) { - if (selectionStart != -1) { - int startX = fr.getStringWidth(text.substring(0, selectionStart)) - xOffset; - int endX = fr.getStringWidth(text.substring(0, selectionEnd)) - xOffset; - Gui.drawRect(3 + startX, y, 3 + endX, y + fr.FONT_HEIGHT, 0xFF00FF00); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(text.substring(selectionStart, selectionEnd), 3 + startX, y, foreground.getRGB()); - } - - // draw cursor - if (cursor != -1) { - if (cursor > text.length()) setCursor0(text.length()); - int x = fr.getStringWidth(text.substring(0, cursor)) - xOffset; - cursorBlickTicker++; - if (cursorBlickTicker < 10) - Gui.drawRect(3 + x, y, 4 + x, y + fr.FONT_HEIGHT, 0xFFFFFFFF); - if (cursorBlickTicker == 20) cursorBlickTicker = 0; - } - } - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - Rectangle actualField = new Rectangle(1, 3,getBounds().width - 2, getBounds().height - 6); - if (!actualField.contains(relMouseX, relMouseY)) return; - if (!lastAbsClip.contains(absMouseX, absMouseY)) return; - if (getTooltipsOpen() > 0) return; - - - - int relStartT = relMouseX-3; - int offseted = relStartT + xOffset; - - selectionStart = -1; - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - for (int i = 0; i < text.length(); i++) { - int totalWidth = fr.getStringWidth(text.substring(0, i)); - if (offseted < totalWidth) { - setCursor0(i); - return; - } - } - setCursor0(text.length()); - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - if (!isFocused) return; - selectionStart = cursor; - selectionEnd = cursor; - - int relStartT = relMouseX-3; - int offseted = relStartT + xOffset; - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - for (int i = 0; i < text.length(); i++) { - int totalWidth = fr.getStringWidth(text.substring(0, i)); - if (offseted < totalWidth) { - if (i < cursor) { - selectionStart = i; - selectionEnd = cursor; - } else { - selectionStart = cursor; - selectionEnd = i; - } - return; - } - } - selectionEnd = text.length(); - if (selectionStart == selectionEnd) { - selectionStart = -1; - } - } - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (!isFocused) return; - if (scrollAmount > 0) { - xOffset += 5; - } else if (scrollAmount < 0){ - xOffset -= 5; - } - if (xOffset < 0) { - xOffset = 0; - } - int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); - int overflow = getBounds().width - 3 - width; - if (overflow >= 0) { - xOffset = 0; - } else if (width - xOffset + 10 < getBounds().width) { - xOffset = width - getBounds().width+10; - } - } - - @Override - public void keyHeld(char typedChar, int keyCode) { - if (!isFocused) return; - this.keyPressed(typedChar, keyCode); - } - - @Override - public void keyPressed(char typedChar, int keycode) { - if (!isFocused) return; - - if (selectionStart == -1) { - if (keycode == 199) { // home - setCursor0(0); - xOffset = 0; - return; - } - - if (keycode == 207) { // end - setCursor0(text.length()); - - int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); - xOffset = Integer.max(0, width - getBounds().width+10); - return; - } - - if (keycode == 203) { // left - setCursor0(this.cursor-1);; - if (cursor < 0) setCursor0(0); - return; - } - - if (keycode == 205) { // right - setCursor0(this.cursor+1); - if (cursor > text.length()) setCursor0(text.length()); - return; - } - - // backspace - if (keycode == 14 && cursor > 0) { - setText0(this.text.substring(0, cursor-1) + this.text.substring(cursor)); - setCursor0(this.cursor-1); - return; - } - - //del - if (keycode == 211 && cursor < text.length()) { - setText0(this.text.substring(0, cursor) + this.text.substring(cursor+1)); - return; - } - - // paste - boolean shouldPaste = false; - if (keycode == 47) { - if (Minecraft.isRunningOnMac) { // mac - if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { - shouldPaste = true; - } - } else { // literally everything else - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { - shouldPaste = true; - } - } - } - if (shouldPaste) { - Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); - if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { - try { - Object theText = transferable.getTransferData(DataFlavor.stringFlavor); - setText0( - this.text.substring(0, this.cursor) - + theText - + this.text.substring(this.cursor)); - - cursor += theText.toString().length(); - } catch (UnsupportedFlavorException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return; - } - - // text - if (isPrintableChar(typedChar)) { - setText0( - this.text.substring(0, this.cursor) - + typedChar - + this.text.substring(this.cursor)); - this.setCursor0(this.cursor+1);; - return; - } - } else { - if (keycode == 199) { // home - setCursor0(0); - selectionStart = -1; - xOffset =0; - return; - } - - if (keycode == 207) { // end - selectionStart = -1; - setCursor0(text.length()); - int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); - xOffset = Integer.max(0, width - getBounds().width+10); - return; - } - - if (keycode == 203) { // left - setCursor0(selectionStart); - selectionStart = -1; - return; - } - - if (keycode == 205) { // right - setCursor0(selectionEnd); - selectionStart = -1; - return; - } - - // backspace - if (keycode == 14 && cursor > 0) { - setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); - setCursor0(selectionStart); - selectionStart = -1; - return; - } - - //del - if (keycode == 211 && cursor < text.length()) { - setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); - setCursor0(selectionStart); - selectionStart = -1; - return; - } - - // paste - boolean shouldPaste = false; - if (keycode == 47) { - if (Minecraft.isRunningOnMac) { // mac - if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { - shouldPaste = true; - } - } else { // literally everything else - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { - shouldPaste = true; - } - } - } - if (shouldPaste) { - Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); - if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { - try { - Object theText = transferable.getTransferData(DataFlavor.stringFlavor); - setText0( - this.text.substring(0, this.selectionStart) - + theText - + this.text.substring(this.selectionEnd)); - setCursor0(this.selectionStart + theText.toString().length()); - } catch (UnsupportedFlavorException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - selectionStart = -1; - } - return; - } - boolean shouldCopy = false; - if (keycode == 46) { - if (Minecraft.isRunningOnMac) { // mac - if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { - shouldCopy = true; - } - } else { // literally everything else - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { - shouldCopy = true; - } - } - } - if (shouldCopy) { - StringSelection selection = new StringSelection(text.substring(selectionStart, selectionEnd)); - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - clipboard.setContents(selection, selection); - return; - } - - // text - if (isPrintableChar(typedChar)) { - setText0( - this.text.substring(0, this.selectionStart) - + typedChar - + this.text.substring(this.selectionEnd)); - this.setCursor0(this.selectionStart + 1); - selectionStart = -1; - return; - } - } - } - public boolean isPrintableChar( char c ) { - Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); - return (!Character.isISOControl(c)) && - c != KeyEvent.CHAR_UNDEFINED && - block != null && - block != Character.UnicodeBlock.SPECIALS; - } - - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (lastAbsClip.contains(absMouseX, absMouseY)) - setCursor(EnumCursor.BEAM_CURSOR); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java deleted file mode 100755 index 4d1e6fb7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; - -@Getter -@Setter -public class MToggleButton extends MPanel { - private boolean enabled = true; - private Runnable onToggle; - - private int border = 0xFF333333, background = 0xFF171717; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - Dimension bounds = getSize(); - - int gap = 1; - - Gui.drawRect(0, 0, bounds.width, bounds.height, border); - Gui.drawRect(gap, gap, bounds.width-gap, bounds.height-gap, background); - - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - double scale = 1; - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - if (enabled) { - int x = (int) ((scale * bounds.height - fr.FONT_HEIGHT)/2 + gap); - GlStateManager.pushMatrix(); - GlStateManager.scale(1.0/scale,1.0/scale,0); - fr.drawString("ON", x, x, 0xFF9B9B9B); - GlStateManager.popMatrix(); - Gui.drawRect(bounds.width - bounds.height+gap,gap, bounds.width - gap, bounds.height - gap, 0xFF00B200); - } else { - GlStateManager.pushMatrix(); - GlStateManager.scale(1.0/scale,1.0/scale,0); - int x = (int) ((scale * bounds.height - fr.FONT_HEIGHT)/2 + gap); - fr.drawString("OFF", (int) (scale * bounds.width - x - fr.getStringWidth("OFF")), x, 0xFF9B9B9B); - GlStateManager.popMatrix(); - Gui.drawRect(gap,gap, bounds.height - gap, bounds.height - gap, 0xFFCD4000); - } - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(40,15); - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (onToggle != null && lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { - enabled = !enabled; - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); - onToggle.run(); - } - } - - - @Override - public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { - if (lastAbsClip.contains(absMouseX, absMouseY)) - setCursor(EnumCursor.POINTING_HAND); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java deleted file mode 100644 index 62ff1e2f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class MTooltip extends MPanelScaledGUI { - @Getter @Setter - private MRootPanel root; - - public void open(MPanel component) { - if (root == null) - component.openTooltip(this); - } - public void close() { - if (root != null) - root.removeTooltip(this); - } - - - public boolean isOpen() { - return root != null; - } - - @Override - public int getTooltipsOpen() { - return super.getTooltipsOpen() - 1; - } - - @Override - public void render0(double parentScale, Point parentPoint, Rectangle parentClip, int absMousex0, int absMousey0, int relMousex0, int relMousey0, float partialTicks) { - lastParentPoint = parentPoint; - - GlStateManager.translate(getBounds().x, getBounds().y, 300); - GlStateManager.color(1,1,1,1); - - Rectangle absBound = getBounds().getBounds(); - absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); - - Rectangle clip = absBound; - lastAbsClip = clip; - - if (clip.getSize().height * clip.getSize().width == 0) return; - - int absMousex = (int) (absMousex0 / scale), absMousey = (int) (absMousey0 / scale); - int relMousex = (int) ((relMousex0 - getBounds().x) / scale); - int relMousey = (int) ((relMousey0 - getBounds().y) /scale); - - // FROM HERE, IT IS SCALED - - GlStateManager.scale(this.scale, this.scale, 1); - clip = new Rectangle((int) (clip.x / scale), (int) (clip.y / scale), (int) (clip.width / scale), (int) (clip.height / scale)); - lastAbsClip = clip; - - GL11.glEnable(GL11.GL_SCISSOR_TEST); - this.relativeScale = parentScale * this.scale; - clip(clip.x, clip.y, clip.width, clip.height); - - - GuiScreen.drawRect(0,0, (int) (getBounds().width / scale), (int) (getBounds().height / scale), backgroundColor.getRGB()); - GlStateManager.enableBlend(); - - - GlStateManager.pushMatrix(); - - render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); - - GlStateManager.popMatrix(); - - GL11.glDisable(GL11.GL_SCISSOR_TEST); - - - - Point newPt = new Point((int) ((parentPoint.x + getBounds().x) / scale), (int) ((parentPoint.y + getBounds().y) / scale)); - - for (MPanel mPanel : getChildComponents()){ - GlStateManager.pushMatrix(); - - mPanel.render0(relativeScale, newPt,clip,absMousex, absMousey, relMousex, relMousey, partialTicks); - - GlStateManager.popMatrix(); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltipText.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltipText.java deleted file mode 100644 index e3d0a3c4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltipText.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.client.config.GuiUtils; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -@AllArgsConstructor -public class MTooltipText extends MTooltip { - @Getter @Setter - private List tooltipText = new ArrayList<>(); - @Override - public Rectangle getBounds() { - return new Rectangle(0,0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - GuiUtils.drawHoveringText(tooltipText, relMousex0, relMousey0, (int) (Minecraft.getMinecraft().displayWidth/getRelativeScale()), (int) (Minecraft.getMinecraft().displayHeight/getRelativeScale()), -1, Minecraft.getMinecraft().fontRendererObj); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MValue.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MValue.java deleted file mode 100755 index db461d60..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MValue.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.gui.elements; - -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditOffsetPointSet; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; - -import java.awt.*; -import java.util.List; -public class MValue extends MPanel { - @Getter - private final T data; - private ValueEditOffsetPointSet valueEditOffsetPointSet; - private final MLabel dataLab; - - @Getter @Setter - private Color hover = Color.gray; - - private final List addons; - - public MValue(final T parameter, List addons) { - this.addons = addons; - this.add(this.dataLab = new MLabel() { - @Override - public String getText() { - return data != null ?data.toString() :"-empty-"; - } - }); - this.dataLab.setAlignment(MLabel.Alignment.RIGHT); - - this.data = parameter; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { - Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); - } - } - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (this.getBounds().x > -20 && lastAbsClip.contains(absMouseX, absMouseY)) { - EditingContext.getEditingContext().openGui(new GuiDungeonValueEdit(data, addons)); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setSize(new Dimension(parentWidth, getBounds().height)); - dataLab.setBounds(new Rectangle(0,0,parentWidth, getBounds().height)); - } - - @Override - public void onBoundsUpdate() { - dataLab.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java new file mode 100755 index 00000000..45c403fd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java @@ -0,0 +1,260 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod; + +import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.IDungeonGuide; +import kr.syeyoung.dungeonsguide.Main; +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.commands.CommandDgDebug; +import kr.syeyoung.dungeonsguide.mod.commands.CommandDungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.commands.CommandReparty; +import kr.syeyoung.dungeonsguide.mod.config.Config; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.RichPresenceManager; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonFacade; +import kr.syeyoung.dungeonsguide.mod.events.listener.FeatureListener; +import kr.syeyoung.dungeonsguide.mod.events.listener.PacketListener; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.resources.DGTexturePack; +import kr.syeyoung.dungeonsguide.mod.utils.AhUtils; +import kr.syeyoung.dungeonsguide.mod.utils.BlockCache; +import kr.syeyoung.dungeonsguide.mod.utils.TimeScoreUtil; +import kr.syeyoung.dungeonsguide.mod.utils.TitleRender; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.GLCursors; +import kr.syeyoung.dungeonsguide.mod.wsresource.StaticResourceCache; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.*; +import net.minecraft.client.resources.IReloadableResourceManager; +import net.minecraft.client.resources.IResourcePack; +import net.minecraft.launchwrapper.LaunchClassLoader; +import net.minecraftforge.client.ClientCommandHandler; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.ProgressManager; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.ReflectionHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Set; + +public class DungeonsGuide implements IDungeonGuide { + + @Getter + private static boolean firstTimeUsingDG = false; + Logger logger = LogManager.getLogger("DungeonsGuide"); + + public boolean verbose = false; + private SkyblockStatus skyblockStatus; + + @Getter + private CosmeticsManager cosmeticsManager; + @Getter + private DungeonFacade dungeonFacade; + + @Getter + private BlockCache blockCache; + + public DungeonsGuide(){ + instance = this; + } + private static DungeonsGuide instance; + + public static DungeonsGuide getDungeonsGuide() { + return instance; + } + + @Getter + CommandReparty commandReparty; + + + + + public void init() { + ProgressManager.ProgressBar progressbar = ProgressManager.push("DungeonsGuide", 4); + MinecraftForge.EVENT_BUS.register(this); + + progressbar.step("Registering Events & Commands"); + + skyblockStatus = new SkyblockStatus(); + + MinecraftForge.EVENT_BUS.register(skyblockStatus); + + + (new FeatureRegistry()).init(); + + new ChatTransmitter(); + + try { + Set invalid = ReflectionHelper.getPrivateValue(LaunchClassLoader.class, (LaunchClassLoader) Main.class.getClassLoader(), "invalidClasses"); + ((LaunchClassLoader) Main.class.getClassLoader()).clearNegativeEntries(Sets.newHashSet("org.slf4j.LoggerFactory")); + invalid.clear(); + } catch (Exception e) { + e.printStackTrace(); + } + + + this.blockCache = new BlockCache(); + + this.dungeonFacade = new DungeonFacade(); + dungeonFacade.init(); + + + + TitleRender.getInstance(); + + CommandDungeonsGuide commandDungeonsGuide = new CommandDungeonsGuide(); + CommandDgDebug command = new CommandDgDebug(); + + ClientCommandHandler.instance.registerCommand(commandDungeonsGuide); + ClientCommandHandler.instance.registerCommand(command); + + MinecraftForge.EVENT_BUS.register(command); + MinecraftForge.EVENT_BUS.register(commandDungeonsGuide); + + commandReparty = new CommandReparty(); + MinecraftForge.EVENT_BUS.register(commandReparty); + + MinecraftForge.EVENT_BUS.register(new FeatureListener()); + MinecraftForge.EVENT_BUS.register(new PacketListener()); + MinecraftForge.EVENT_BUS.register(new Keybinds()); + + MinecraftForge.EVENT_BUS.register(PartyManager.INSTANCE); + MinecraftForge.EVENT_BUS.register(ChatProcessor.INSTANCE); + MinecraftForge.EVENT_BUS.register(StaticResourceCache.INSTANCE); + + MinecraftForge.EVENT_BUS.register(new AhUtils()); + + + progressbar.step("Opening connection"); + cosmeticsManager = new CosmeticsManager(); + MinecraftForge.EVENT_BUS.register(cosmeticsManager); + + + progressbar.step("Loading Config"); + try { + Config.loadConfig(null); + } catch (IOException e) { + e.printStackTrace(); + } + + if (FeatureRegistry.ETC_REPARTY.isEnabled()) { + ClientCommandHandler.instance.registerCommand(commandReparty); + } + + if (FeatureRegistry.DISCORD_DONOTUSE.isEnabled()) { + System.setProperty("dg.safe", "true"); + } + + MinecraftForge.EVENT_BUS.register(RichPresenceManager.INSTANCE); + TimeScoreUtil.init(); + + Main.finishUpProgressBar(progressbar); + + ProgressManager.pop(progressbar); + + ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(resourceManager -> GLCursors.setupCursors()); + } + + private boolean showedStartUpGuide; + @SubscribeEvent + public void onGuiOpen(GuiOpenEvent guiOpenEvent){ + if(!showedStartUpGuide){ + showedStartUpGuide = true; + + if(isFirstTimeUsingDG()){ + GuiScreen originalGUI = guiOpenEvent.gui; + guiOpenEvent.gui = new GuiScreen() { + final String welcomeText = "Thank you for installing ยงeDungeonsGuideยงf, the most intelligent skyblock dungeon mod!\nThe gui for relocating GUI Elements and enabling or disabling features can be opened by typing ยงe/dg\nType ยงe/dg help ยงfto view full list of commands offered by dungeons guide!"; + + @Override + public void initGui() { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + this.buttonList.add(new GuiButton(0, sr.getScaledWidth()/2-100,sr.getScaledHeight()-70 ,"Continue")); + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + super.actionPerformed(button); + if (button.id == 0) { + Minecraft.getMinecraft().displayGuiScreen(originalGUI); + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawBackground(1); + + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + fontRenderer.drawString("ยงeWelcome To DungeonsGuide", (sr.getScaledWidth()-fontRenderer.getStringWidth("Welcome To DungeonsGuide"))/2,40,0xFFFF0000); + int tenth = sr.getScaledWidth() / 10; + Gui.drawRect(tenth, 70,sr.getScaledWidth()-tenth, sr.getScaledHeight()-80, 0xFF5B5B5B); + + String[] split = welcomeText.split("\n"); + for (int i = 0; i < split.length; i++) { + fontRenderer.drawString(split[i].replace("\t", " "), tenth + 2,i*fontRenderer.FONT_HEIGHT + 72, 0xFFFFFFFF); + } + + super.drawScreen(mouseX, mouseY, partialTicks); + } + + }; + } + + } + } + + + public void preinit(){ + + File configFile = new File(Main.getConfigDir(), "config.json"); + if (!configFile.exists()) { + Main.getConfigDir().mkdirs(); + firstTimeUsingDG = true; + } + + Config.f = configFile; + Minecraft.getMinecraft().getFramebuffer().enableStencil(); + + try { + List resourcePackList = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "aA", "field_110449_ao"); + resourcePackList.add(new DGTexturePack()); + Minecraft.getMinecraft().refreshResources(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + public SkyblockStatus getSkyblockStatus() { + return skyblockStatus; + } + + + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/Keybinds.java new file mode 100755 index 00000000..39f89834 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/Keybinds.java @@ -0,0 +1,47 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod; + +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +public class Keybinds +{ + + @SubscribeEvent + public void onTogglePathfindStatus(InputEvent.KeyInputEvent keyInputEvent) { + if (Keyboard.getEventKeyState()) { + int key = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey(); + KeyBindPressedEvent keyBindPressedEvent = new KeyBindPressedEvent(key); + MinecraftForge.EVENT_BUS.post(keyBindPressedEvent); + } + } + @SubscribeEvent + public void onMousePressed(InputEvent.MouseInputEvent mouseInputEvent) { + if (Mouse.getEventButtonState()) { + int key = Mouse.getEventButton() - 100; + KeyBindPressedEvent keyBindPressedEvent = new KeyBindPressedEvent(key); + MinecraftForge.EVENT_BUS.post(keyBindPressedEvent); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/SkyblockStatus.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/SkyblockStatus.java new file mode 100755 index 00000000..4cd4e3ee --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/SkyblockStatus.java @@ -0,0 +1,155 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod; + +import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonLeftEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.HypixelJoinedEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.SkyblockJoinedEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.SkyblockLeftEvent; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.relauncher.Side; + +import java.util.Collection; +import java.util.Set; + +public class SkyblockStatus { + boolean wasOnHypixel = false; + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent ev) { + if (ev.side == Side.SERVER || ev.phase != TickEvent.Phase.START) return; + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + boolean isOnDungeonPrev = isOnDungeon(); + boolean isOnSkyblockPrev = isOnSkyblock(); + skyblockStatus.updateStatus(); + + if (!wasOnHypixel && skyblockStatus.isOnHypixel()) { + MinecraftForge.EVENT_BUS.post(new HypixelJoinedEvent()); + } + wasOnHypixel = skyblockStatus.isOnHypixel(); + + if (isOnSkyblockPrev && !isOnSkyblock()) { + MinecraftForge.EVENT_BUS.post(new SkyblockLeftEvent()); + } else if (!isOnSkyblockPrev && isOnSkyblock()) { + MinecraftForge.EVENT_BUS.post(new SkyblockJoinedEvent()); + } + + if (isOnDungeonPrev && !isOnDungeon()) { + MinecraftForge.EVENT_BUS.post(new DungeonLeftEvent()); + } + + + + } + + + public static boolean isOnSkyblock(){ + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + return skyblockStatus != null && skyblockStatus.isOnSkyblock; + } + + public static boolean isOnDungeon() { + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + + + return skyblockStatus != null && (skyblockStatus.forceIsOnDungeon || skyblockStatus.isOnDungeon); + } + + + private boolean isOnSkyblock; + private boolean isOnDungeon; + + @Getter @Setter + private boolean forceIsOnDungeon; + + public boolean isOnHypixel() { + Minecraft mc = Minecraft.getMinecraft(); + if (mc == null || mc.thePlayer == null) return false; + if (!mc.isSingleplayer() && mc.thePlayer.getClientBrand() != null) { + return mc.thePlayer.getClientBrand().startsWith("Hypixel BungeeCord"); + } + return false; + } + + private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK"); + + public void updateStatus() { + if (!isOnHypixel()) { + isOnDungeon = false; + isOnSkyblock = false; + return; + } + + Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); + ScoreObjective scoreObjective = scoreboard.getObjectiveInDisplaySlot(1); + if (scoreObjective == null) return; + + String objectiveName = TextUtils.stripColor(scoreObjective.getDisplayName()); + boolean skyblockFound = false; + for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { + if (objectiveName.startsWith(skyblock)) { + skyblockFound = true; + isOnSkyblock = true; + break; + } + } + + if (!skyblockFound) { + isOnSkyblock = false; + isOnDungeon = false; + return; + } + + Collection scores = scoreboard.getSortedScores(scoreObjective); + boolean foundDungeon = false; + for (Score sc : scores) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); + if (strippedLine.contains("Cleared: ")) { + foundDungeon = true; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if(context != null){ + context.setPercentage(Integer.parseInt(strippedLine.substring(9).split(" ")[0])); + } + } + if (ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()).startsWith(" ยง7โฃ")) { + DungeonContext.setDungeonName(strippedLine.trim()); + } + } + + isOnDungeon = foundDungeon; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatProcessResult.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatProcessResult.java new file mode 100644 index 00000000..bacd7c4b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatProcessResult.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.chat; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum ChatProcessResult { + NONE(false, false), REMOVE_LISTENER(true, false), REMOVE_LISTENER_AND_CHAT(true, true), REMOVE_CHAT(false, true); + + private boolean removeListener; + private boolean removeChat; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatProcessor.java new file mode 100644 index 00000000..b65e64aa --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatProcessor.java @@ -0,0 +1,118 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.chat; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiNewChat; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.simple.SimpleLogger; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; + +public class ChatProcessor { + public static final ChatProcessor INSTANCE = new ChatProcessor(); + + private static final Logger logger = LogManager.getLogger("DG-ChatProcessor"); + private ChatProcessor() { + Logger l = LogManager.getLogger(GuiNewChat.class); + if (l instanceof SimpleLogger) { + ((SimpleLogger) l).setLevel(Level.OFF); + } else if (l instanceof org.apache.logging.log4j.core.Logger) { + ((org.apache.logging.log4j.core.Logger) l).setLevel(Level.OFF); + } + } + + private Queue chatSubscriberQueue = new ConcurrentLinkedQueue<>(); + private Queue> chatQueue = new ConcurrentLinkedQueue<>(); + + + public void subscribe(ChatSubscriber chatSubscribed) { + chatSubscriberQueue.add(chatSubscribed); + } + public void addToChatQueue(String chat, Runnable onSend, boolean noDupe) { + if (noDupe && chatQueue.stream().anyMatch(a -> a.getFirst().trim().equalsIgnoreCase(chat.trim()))) return; + chatQueue.add(new Tuple<>(chat, onSend)); + } + + + private long minimumNext = 0; + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent clientTickEvent) { + try { + if (clientTickEvent.phase == TickEvent.Phase.START && Minecraft.getMinecraft().thePlayer != null && minimumNext < System.currentTimeMillis()) { + if (!chatQueue.isEmpty()) { + Tuple tuple = chatQueue.poll(); + Minecraft.getMinecraft().thePlayer.sendChatMessage(tuple.getFirst()); + if (tuple.getSecond() != null) + tuple.getSecond().run(); + minimumNext = System.currentTimeMillis() + 200; + ChatTransmitter.sendDebugChat(new ChatComponentText("Sending " + tuple.getFirst() + " Secretly")); + } + + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + + + @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) + public void onMessage(ClientChatReceivedEvent chatReceivedEvent) { + if (chatReceivedEvent.type == 2) return; + String txt = chatReceivedEvent.message.getFormattedText(); + logger.info("[CHAT] {}", txt); + + int processed = 0; + int listenened = 0; + Map context = new HashMap<>(); + Iterator it = chatSubscriberQueue.iterator(); + while (it.hasNext()) { + ChatSubscriber chatSubscribed = it.next(); + context.put("removed", processed); + context.put("onceListenered", listenened); + ChatProcessResult chatProcessResult = chatSubscribed.process(txt, context); + if (chatProcessResult.isRemoveChat()) processed++; + if (chatProcessResult.isRemoveListener()) listenened++; + + if (chatProcessResult.isRemoveChat()) chatReceivedEvent.setResult(Event.Result.DENY); + if (chatProcessResult.isRemoveListener()) it.remove(); + } + } + + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void cancelMessage(ClientChatReceivedEvent chatReceivedEvent) { + if (chatReceivedEvent.getResult() == Event.Result.DENY) + chatReceivedEvent.setCanceled(true); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatSubscriber.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatSubscriber.java new file mode 100644 index 00000000..fa7e70af --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatSubscriber.java @@ -0,0 +1,26 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.chat; + +import java.util.Map; + +@FunctionalInterface +public interface ChatSubscriber { + ChatProcessResult process(String txt, Map context); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatTransmitter.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatTransmitter.java new file mode 100644 index 00000000..bfdbd5db --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/chat/ChatTransmitter.java @@ -0,0 +1,69 @@ +package kr.syeyoung.dungeonsguide.mod.chat; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; + +public class ChatTransmitter { + + public static final String PREFIX = "ยงeDungeons Guide ยง7:: "; + public static String prefix = "ยงeDungeons Guide ยง7:: "; + + public ChatTransmitter() { + MinecraftForge.EVENT_BUS.register(this); + } + + static Queue receiveQueue = new ConcurrentLinkedQueue<>(); + + public static void addToQueue(String chat, boolean noDupe) { + addToQueue(new ChatComponentText(chat), noDupe); + } + + public static void addToQueue(ChatComponentText chat) { + addToQueue(chat, false); + } + public static void addToQueue(ChatComponentText chat, boolean noDupe) { + if(noDupe && receiveQueue.stream().anyMatch(a -> a.equals(chat))) return; + receiveQueue.add(chat); + } + + public static void addToQueue(String s) { + addToQueue(s, false); + } + + public static void sendDebugChat(IChatComponent iChatComponent) { + if(FeatureRegistry.DEBUG == null) return; + if (FeatureRegistry.DEBUG.isEnabled()) + addToQueue((ChatComponentText) iChatComponent); + } + + public static void sendDebugChat(String text) { + sendDebugChat(new ChatComponentText(text)); + } + + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent clientTickEvent) { + if(clientTickEvent.phase != TickEvent.Phase.START && Minecraft.getMinecraft().thePlayer == null) return; + + if (!receiveQueue.isEmpty()) { + ClientChatReceivedEvent event = new ClientChatReceivedEvent((byte) 1, receiveQueue.poll()); + MinecraftForge.EVENT_BUS.post(event); + if (!event.isCanceled()) { + Minecraft.getMinecraft().thePlayer.addChatMessage(event.message); + } + } + + + } + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java new file mode 100644 index 00000000..b3f8dd19 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java @@ -0,0 +1,450 @@ +package kr.syeyoung.dungeonsguide.mod.commands; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.Main; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.NestedCategory; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.MapProcessor; +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonSpecificDataProvider; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonSpecificDataProviderRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventHolder; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonRoomEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoomInfoRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessor; +import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonLeftEvent; +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.party.PartyContext; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.utils.*; +import kr.syeyoung.dungeonsguide.mod.wsresource.StaticResourceCache; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.Tuple; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.vecmath.Vector2d; +import java.awt.*; +import java.io.*; +import java.nio.file.Files; +import java.security.*; +import java.security.cert.CertificateException; +import java.util.List; +import java.util.*; +import java.util.regex.Pattern; + +public class CommandDgDebug extends CommandBase { + @Override + public String getCommandName() { + return "dgdebug"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "dgdebug"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length == 0) return; + String arg = args[0].toLowerCase(); + + + if ("scoreboard".equals(arg)) { + ScoreBoardUtils.forEachLine(l -> { + ChatTransmitter.addToQueue("LINE: " + l, false); + }); + } else if ("scoreboardclean".equals(arg)) { + ScoreBoardUtils.forEachLineClean(l -> { + ChatTransmitter.addToQueue("LINE: " + l, false); + }); + } else if ("title".equals(arg)) { + if (args.length == 2) { + System.out.println("Displayuing title:" + args[1]); + TitleRender.displayTitle(args[1], "", 10, 40, 20); + } + } else if ("mockdungeonstart".equals(arg)) { + if (!Minecraft.getMinecraft().isSingleplayer()) { + ChatTransmitter.addToQueue("This only works in singlepauer", false); + return; + } + + if (args.length == 2) { + int time = Integer.parseInt(args[1]); + ChatTransmitter.addToQueue("ยงrยงaDungeon starts in " + time + " seconds.ยงr", false); + return; + } + + + (new Thread(() -> { + try { + ChatTransmitter.addToQueue("ยงrยงaDungeon starts in 15 seconds.ยงr", false); + Thread.sleep(6000); + ChatTransmitter.addToQueue("ยงrยงaDungeon starts in 10 seconds.ยงr", false); + Thread.sleep(700); + ChatTransmitter.addToQueue("ยงrยงaDungeon starts in 5 seconds.ยงr", false); + Thread.sleep(1000); + ChatTransmitter.addToQueue("ยงrยงaDungeon starts in 4 seconds.ยงr", false); + Thread.sleep(1000); + ChatTransmitter.addToQueue("ยงrยงaDungeon starts in 3 seconds.ยงr", false); + Thread.sleep(1000); + ChatTransmitter.addToQueue("ยงrยงaDungeon starts in 2 seconds.ยงr", false); + Thread.sleep(1000); + ChatTransmitter.addToQueue("ยงrยงaDungeon starts in 1 seconds.ยงr", false); + } catch (InterruptedException ignored) { + } + })).start(); + } else if ("saverooms".equals(arg)) { + DungeonRoomInfoRegistry.saveAll(Main.getConfigDir()); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully saved user generated roomdata")); + } else if ("loadrooms".equals(arg)) { + try { + DungeonRoomInfoRegistry.loadAll(Main.getConfigDir()); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully loaded roomdatas")); + return; + } catch (BadPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | + NoSuchAlgorithmException | IOException | IllegalBlockSizeException | + NoSuchPaddingException e) { + e.printStackTrace(); + } + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcAn error has occurred while loading roomdata")); + } else if ("reloadah".equals(arg)) { + try { + AhUtils.loadAuctions(); + } catch (CertificateException | NoSuchAlgorithmException | InvalidKeyException | + InvalidAlgorithmParameterException | NoSuchPaddingException | BadPaddingException | + KeyStoreException | IllegalBlockSizeException | KeyManagementException e) { + e.printStackTrace(); + } + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfReloaded Ah data")); + } else if ("brand".equals(arg)) { + String serverBrand = Minecraft.getMinecraft().thePlayer.getClientBrand(); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + serverBrand)); + } else if ("pathfind".equals(arg)) { + try { + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + if (thePlayer == null) return; + if (context.getBossfightProcessor() != null) context.getBossfightProcessor().tick(); + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); + grp.pathfind("COMMAND", args[1], args[2], FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.getRouteProperties()); + } catch (Throwable t) { + t.printStackTrace(); + } + } else if ("process".equals(arg)) { + File fileRoot = Main.getConfigDir(); + File dir = new File(fileRoot, "processorinput"); + File outsecret = new File(fileRoot, "processoroutsecret"); + for (File f : dir.listFiles()) { + if (!f.getName().endsWith(".roomdata")) continue; + try { + InputStream fis = new FileInputStream(f); + ObjectInputStream ois = new ObjectInputStream(fis); + DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); + ois.close(); + fis.close(); + dri.setUserMade(false); + + FileOutputStream fos = new FileOutputStream(new File(outsecret, dri.getUuid().toString() + ".roomdata")); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(dri); + oos.flush(); + oos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } else if ("check".equals(arg)) { + File fileroot = Main.getConfigDir(); + for (File f : fileroot.listFiles()) { + if (!f.getName().endsWith(".roomdata")) continue; + try { + InputStream fis = new FileInputStream(f); + ObjectInputStream ois = new ObjectInputStream(fis); + DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); + ois.close(); + fis.close(); + System.out.println("Starting at " + dri.getName() + " - " + dri.getUuid()); + for (Map.Entry value2 : dri.getMechanics().entrySet()) { + DungeonMechanic value = value2.getValue(); + if (value instanceof DungeonSecret && + (((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.BAT + || ((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.CHEST) + && ((DungeonSecret) value).getSecretPoint().getY() == 0) { + OffsetPoint offsetPoint = ((DungeonSecret) value).getSecretPoint(); + if (dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { + dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; + System.out.println("Fixing " + value2.getKey() + " - as secret " + ((DungeonSecret) value).getSecretType() + " - at " + ((DungeonSecret) value).getSecretPoint()); + } + } else if (value instanceof DungeonOnewayDoor) { + for (OffsetPoint offsetPoint : ((DungeonOnewayDoor) value).getSecretPoint().getOffsetPointList()) { + if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { + dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; + System.out.println("Fixing " + value2.getKey() + " - o-door - at " + offsetPoint); + } + } + } else if (value instanceof DungeonDoor) { + for (OffsetPoint offsetPoint : ((DungeonDoor) value).getSecretPoint().getOffsetPointList()) { + if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { + dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; + System.out.println("Fixing " + value2.getKey() + " - door - at " + offsetPoint); + } + } + } else if (value instanceof DungeonBreakableWall) { + for (OffsetPoint offsetPoint : ((DungeonBreakableWall) value).getSecretPoint().getOffsetPointList()) { + if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { + dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; + System.out.println("Fixing " + value2.getKey() + " - wall - at " + offsetPoint); + } + } + } else if (value instanceof DungeonTomb) { + for (OffsetPoint offsetPoint : ((DungeonTomb) value).getSecretPoint().getOffsetPointList()) { + if (offsetPoint.getY() == 0 && dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] != -1) { + dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; + System.out.println("Fixing " + value2.getKey() + " - crypt - at " + offsetPoint); + } + } + } + } + FileOutputStream fos = new FileOutputStream(f); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(dri); + oos.flush(); + oos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } else if ("reloaddungeon".equals(arg)) { + try { + MinecraftForge.EVENT_BUS.post(new DungeonLeftEvent()); + + DungeonsGuide.getDungeonsGuide().getDungeonFacade().setContext(null); + MapUtils.clearMap(); + } catch (Throwable t) { + t.printStackTrace(); + } + } else if ("partyid".equals(arg)) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfInternal Party id: " + Optional.ofNullable(PartyManager.INSTANCE.getPartyContext()).map(PartyContext::getPartyID).orElse(null))); + } else if ("loc".equals(arg)) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfYou're in " + DungeonContext.getDungeonName())); + } else if ("saverun".equals(arg)) { + try { + File f = Main.getConfigDir(); + File runDir = new File(f, "dungeonruns"); + runDir.mkdirs(); + + File runFile = new File(runDir, UUID.randomUUID() + ".dgrun"); + + DungeonContext dungeonContext = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (dungeonContext == null) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCouldn't find dungeon to save!")); + return; + } + DungeonEventHolder dungeonEventHolder = new DungeonEventHolder(); + dungeonEventHolder.setDate(dungeonContext.getInit()); + dungeonEventHolder.setPlayers(dungeonContext.getPlayers()); + dungeonEventHolder.setEventDataList(dungeonContext.getEvents()); + + + ObjectOutputStream oos = new ObjectOutputStream(Files.newOutputStream(runFile.toPath())); + oos.writeObject(dungeonEventHolder); + oos.flush(); + oos.close(); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully saved dungeon run to " + runFile.getAbsolutePath())); + } catch (Exception e) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcAn error occured while writing rundata " + e.getMessage())); + e.printStackTrace(); + } + } else if ("requeststaticresource".equals(arg)) { + UUID uid = UUID.fromString(args[1]); + StaticResourceCache.INSTANCE.getResource(uid).thenAccept(a -> { + sender.addChatMessage(new ChatComponentText(a.getResourceID() + ": " + a.getValue() + ": " + a.isExists())); + }); + } else if ("createfakeroom".equals(arg)) {// load schematic + File f = new File(Main.getConfigDir(), "schematics/new roonm-b2df250c-4af2-4201-963c-0ee1cb6bd3de-5efb1f0c-c05f-4064-bde7-cad0874fdf39.schematic"); + NBTTagCompound compound; + try { + compound = CompressedStreamTools.readCompressed(new FileInputStream(f)); + } catch (IOException e) { + e.printStackTrace(); + return; + } + + byte[] blocks = compound.getByteArray("Blocks"); + byte[] meta = compound.getByteArray("Data"); + for (int x = 0; x < compound.getShort("Width"); x++) { + for (int y = 0; y < compound.getShort("Height"); y++) { + for (int z = 0; z < compound.getShort("Length"); z++) { + int index = x + (y * compound.getShort("Length") + z) * compound.getShort("Width"); + BlockPos pos = new BlockPos(x, y, z); + World w = MinecraftServer.getServer().getEntityWorld(); + w.setBlockState(pos, Block.getBlockById(blocks[index] & 0xFF).getStateFromMeta(meta[index] & 0xFF), 2); + } + } + } + + + DungeonSpecificDataProviderRegistry.doorFinders.put(Pattern.compile("TEST DG"), new DungeonSpecificDataProvider() { + @Override + public BlockPos findDoor(World w, String dungeonName) { + return new BlockPos(0, 0, 0); + } + + @Override + public Vector2d findDoorOffset(World w, String dungeonName) { + return null; + } + + @Override + public BossfightProcessor createBossfightProcessor(World w, String dungeonName) { + return null; + } + + @Override + public boolean isTrapSpawn(String dungeonName) { + return false; + } + + @Override + public double secretPercentage(String dungeonName) { + return 0; + } + + @Override + public int speedSecond(String dungeonName) { + return 0; + } + }); + DungeonContext.setDungeonName("TEST DG"); + DungeonContext fakeContext = new DungeonContext(Minecraft.getMinecraft().theWorld); + DungeonsGuide.getDungeonsGuide().getDungeonFacade().setContext(fakeContext); + DungeonsGuide.getDungeonsGuide().getSkyblockStatus().setForceIsOnDungeon(true); + MapProcessor mapProcessor = fakeContext.getMapProcessor(); + mapProcessor.setUnitRoomDimension(new Dimension(16, 16)); + mapProcessor.setBugged(false); + mapProcessor.setDoorDimensions(new Dimension(4, 4)); + mapProcessor.setTopLeftMapPoint(new Point(0, 0)); + fakeContext.setDungeonMin(new BlockPos(0, 70, 0)); + + DungeonRoom dungeonRoom = new DungeonRoom(Arrays.asList(new Point(0, 0)), ShortUtils.topLeftifyInt((short) 1), (byte) 63, new BlockPos(0, 70, 0), new BlockPos(31, 70, 31), fakeContext, Collections.emptySet()); + + fakeContext.getDungeonRoomList().add(dungeonRoom); + for (Point p : Arrays.asList(new Point(0, 0))) { + fakeContext.getRoomMapper().put(p, dungeonRoom); + } + + EditingContext.createEditingContext(dungeonRoom); + EditingContext.getEditingContext().openGui(new GuiDungeonRoomEdit(dungeonRoom)); + } else if ("closecontext".equals(arg)) { + DungeonsGuide.getDungeonsGuide().getSkyblockStatus().setForceIsOnDungeon(false); + + DungeonsGuide.getDungeonsGuide().getDungeonFacade().setContext(null); + } else if ("dumpsettings".equals(arg)) { + NestedCategory nestedCategory = new NestedCategory("ROOT"); + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + String category = abstractFeature.getCategory(); + NestedCategory currentRoot = nestedCategory; + for (String s : category.split("\\.")) { + NestedCategory finalCurrentRoot = currentRoot; + if (currentRoot.children().containsKey(s)) + currentRoot = currentRoot.children().get(s); + else { + currentRoot.child(currentRoot = new NestedCategory(finalCurrentRoot.categoryFull() + "." + s)); + } + } + } + + StringBuilder stringBuilder = new StringBuilder(); + StringBuilder stringBuilder2 = new StringBuilder(); + + Stack> stak = new Stack<>(); + stak.push(new Tuple<>(nestedCategory, 0)); + Set discovered = new HashSet<>(); + while (!stak.isEmpty()) { + Tuple n = stak.pop(); + if (discovered.contains(n.getFirst())) continue; + discovered.add(n.getFirst()); + for (Map.Entry stringNestedCategoryEntry : n.getFirst().children().entrySet()) { + stak.push(new Tuple<>(stringNestedCategoryEntry.getValue(), n.getSecond() + 1)); + } + + if (n.getFirst().categoryFull().equals("ROOT")) continue; + + String prefix = ""; + for (int i = 0; i < n.getSecond() - 1; i++) { + prefix += " "; + } + + List abstractFeatureList = FeatureRegistry.getFeaturesByCategory().getOrDefault(n.getFirst().categoryFull().substring(5), Collections.emptyList()); + stringBuilder.append(prefix).append("- C ").append(n.getFirst().categoryFull()).append("\n"); + stringBuilder2.append(n.getFirst().categoryFull()).append("\n"); + for (AbstractFeature abstractFeature : abstractFeatureList) { + stringBuilder.append(prefix).append(" - F ").append(abstractFeature.getName()).append(" / ").append(abstractFeature.getDescription().replace("\n", "$NEW_LINE$")).append("\n"); + } + } + System.out.println(stringBuilder.toString()); + System.out.println(stringBuilder2.toString()); + } else if ("readmap".equals(arg)) { + try { + int fromX = Integer.parseInt(args[1]); + int fromY = Integer.parseInt(args[2]); + sender.addChatMessage(new ChatComponentText(MapUtils.readDigit(MapUtils.getColors(), fromX, fromY) + "-")); +// int cntY = Integer.parseInt(args[3]); +// int target = Integer.parseInt(args[4]); +// StringBuilder sb = new StringBuilder("{"); +// for (int y = fromY; y < fromY + cntY; y++) { +// int curr = 0; +// for (int x = fromX; x < fromX+8; x++) { +// byte clr = MapUtils.getMapColorAt(MapUtils.getColors(), x,y); +// if (clr == target) curr = (curr << 1) | 1; +// else curr <<= 1; +// } +// sb.append("0x").append(Integer.toHexString(curr).toUpperCase()); +// if (y != fromY + cntY - 1) sb.append(", "); +// } +// sb.append("}"); +// System.out.println("\n"+sb.toString()); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + sender.addChatMessage(new ChatComponentText("ain't gonna find much anything here")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg loadrooms ยง7-ยงf Reloads dungeon roomdata.")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg brand ยง7-ยงf View server brand.")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg info ยง7-ยงf View Current DG User info.")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg saverun ยง7-ยงf Save run to be sent to developer.")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg saverooms ยง7-ยงf Saves usergenerated dungeon roomdata.")); + } + } + + + @Override + public int getRequiredPermissionLevel() { + return 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDungeonsGuide.java new file mode 100644 index 00000000..9b9811cd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDungeonsGuide.java @@ -0,0 +1,172 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.commands; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.GuiConfigV2; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.RichPresenceManager; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.FeatureViewPlayerStatsOnJoin; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.ApiFetcher; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.stomp.StompManager; +import kr.syeyoung.dungeonsguide.mod.stomp.StompPayload; +import kr.syeyoung.dungeonsguide.mod.wsresource.StaticResourceCache; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.json.JSONObject; + +public class CommandDungeonsGuide extends CommandBase { + private boolean openConfig = false; + + @Override + public String getCommandName() { + return "dg"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "dg"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (args.length == 0) { + openConfig = true; + } else if (args[0].equalsIgnoreCase("reparty")) { + if (!DungeonsGuide.getDungeonsGuide().getCommandReparty().requestReparty(false)) { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCurrently Repartying")); + } + } else if (args[0].equalsIgnoreCase("gui")) { + openConfig = true; + } else if (args[0].equalsIgnoreCase("pvall")) { + PartyManager.INSTANCE.requestPartyList((context) -> { + if (context == null) { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcNot in Party")); + return; + } + FeatureViewPlayerStatsOnJoin.processPartyMembers(context); + }); + } else if (args[0].equalsIgnoreCase("asktojoin") || args[0].equalsIgnoreCase("atj")) { + if (RichPresenceManager.INSTANCE.getLastSetupCode() == -9999) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcDiscord GameSDK has been disabled, or it failed to load!")); + return; + } + if (!PartyManager.INSTANCE.canInvite()) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcYou don't have perms in the party to invite people!")); + } else { + PartyManager.INSTANCE.toggleAllowAskToJoin(); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfToggled Ask to join to " + (PartyManager.INSTANCE.getAskToJoinSecret() != null ? "ยงeon" : "ยงcoff"))); + } + + if (!FeatureRegistry.DISCORD_RICHPRESENCE.isEnabled()) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcDiscord Rich Presence is disabled! Enable at /dg -> Discord ")); + } + if (!FeatureRegistry.DISCORD_ASKTOJOIN.isEnabled()) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcDiscord Invite Viewer is disabled! Enable at /dg -> Discord ")); // how + } + } else if (args[0].equals("pv")) { + try { + ApiFetcher.fetchUUIDAsync(args[1]) + .thenAccept(a -> { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + args[1] + "ยงf's Profile ").appendSibling(new ChatComponentText("ยง7view").setChatStyle(new ChatStyle().setChatHoverEvent(new FeatureViewPlayerStatsOnJoin.HoverEventRenderPlayer(a.orElse(null)))))); + }); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (args[0].equals("purge")) { + ApiFetcher.purgeCache(); + CosmeticsManager cosmeticsManager = DungeonsGuide.getDungeonsGuide().getCosmeticsManager(); + cosmeticsManager.requestPerms(); + cosmeticsManager.requestCosmeticsList(); + cosmeticsManager.requestActiveCosmetics(); + StaticResourceCache.INSTANCE.purgeCache(); + FeatureRegistry.DISCORD_ASKTOJOIN.imageMap.clear(); + FeatureRegistry.DISCORD_ASKTOJOIN.futureMap.clear(); + + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully purged API Cache!")); + } else if (args[0].equals("pbroadcast")) { + try { + String[] payload = new String[args.length - 1]; + System.arraycopy(args, 1, payload, 0, payload.length); + String actualPayload = String.join(" ", payload).replace("$C$", "ยง"); + StompManager.getInstance().send(new StompPayload().header("destination", "/app/party.broadcast").payload( + new JSONObject().put("partyID", PartyManager.INSTANCE.getPartyContext().getPartyID()) + .put("payload", actualPayload).toString() + )); + } catch (Exception e) { + e.printStackTrace(); + } + + + } else if (args[0].equals("partymax") || args[0].equals("pm")) { + if (args.length == 1) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfCurrent party max is ยงe" + PartyManager.INSTANCE.getMaxParty())); + } else if (args.length == 2) { + try { + int partyMax = Integer.parseInt(args[1]); + if (partyMax < 2) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcparty max can't be smaller than 2")); + return; + } + + PartyManager.INSTANCE.setMaxParty(partyMax); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSuccessfully set partymax to ยงe" + PartyManager.INSTANCE.getMaxParty())); + } catch (Exception e) { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงc" + args[1] + " is not valid number.")); + } + } + } else { + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg ยง7-ยงfOpens configuration gui")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg gui ยง7-ยงfOpens configuration gui")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg help ยง7-ยงfShows command help")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg reloadah ยง7-ยงf Reloads price data from server.")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg reparty ยง7-ยงf Reparty.")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg asktojoin or /dg atj ยง7-ยงf Toggle ask to join ยงcRequires Discord Rich Presence enabled. (/dg -> Advanced)")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg partymax [number] or /dg pm [number] ยง7-ยงf Sets partymax ยง7(maximum amount people in party, for discord rpc)")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg pv [ign] ยง7-ยงf Profile Viewer")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg pvall ยง7-ยงf Profile Viewer For all people on party")); + sender.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe/dg purge ยง7-ยงf Purge api cache.")); + } + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent e) { + try { + if (openConfig && e.phase == TickEvent.Phase.START) { + openConfig = false; + Minecraft.getMinecraft().displayGuiScreen(new GuiConfigV2()); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandReparty.java new file mode 100644 index 00000000..65eccb3b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandReparty.java @@ -0,0 +1,104 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.commands; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import java.util.stream.Collectors; + +public class CommandReparty extends CommandBase { + private String command; + public CommandReparty() { + command = FeatureRegistry.ETC_REPARTY.getParameter("command").getValue(); + command = command.replace(" ", ""); + } + + @Override + public String getCommandName() { + return command; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return command; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (!requestReparty(false)) { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcCurrently Repartying")); + } + } + + private boolean reparting = false; + + + public boolean requestReparty(boolean noerror) { + if (reparting) { + return false; + } + reparting = true; + + PartyManager.INSTANCE.requestPartyList(pc -> { + if (pc == null) { + if (!noerror) + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcNot in Party")); + reparting = false; + return; + } + if (!pc.hasLeader(Minecraft.getMinecraft().getSession().getUsername())) { + if (!noerror) + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcYou're not leader")); + reparting = false; + return; + } + if (pc.isSelfSolo()) { + if (!noerror) + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcYou can not reparty yourself")); + reparting = false; + return; + } + String members = pc.getPartyRawMembers().stream().filter(a -> !a.equalsIgnoreCase(Minecraft.getMinecraft().getSession().getUsername())).collect(Collectors.joining(" ")); + String command = "/p invite "+members; + + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeDisbanding Party...")); + ChatProcessor.INSTANCE.addToChatQueue("/p disband", () -> { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeRunning invite command ยงf"+command)); + ChatProcessor.INSTANCE.addToChatQueue(command, () -> { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeSuccessfully repartied!ยงf")); + + reparting = false; + }, false); + }, false); + }); + return true; + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/Config.java new file mode 100644 index 00000000..0e1bf7fd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/Config.java @@ -0,0 +1,65 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; + +import java.io.*; + +public class Config { + public static JsonObject configuration; + + public static File f; + + public static void loadConfig(File f) throws IOException { + try { + configuration = (JsonObject) new JsonParser().parse(new InputStreamReader(new FileInputStream(Config.f = f == null ? Config.f : f))); + } catch (Exception e) { + configuration = new JsonObject(); + } + for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { + JsonObject object = configuration.getAsJsonObject(feature.getKey()); + if (object != null) feature.loadConfig(object); + } + + saveConfig(); + } + + public static void saveConfig() throws IOException { + for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { + JsonObject object = feature.saveConfig(); + configuration.add(feature.getKey(), object); + } + + String str = new Gson().toJson(configuration); + FileOutputStream fos = null; + try { + fos = new FileOutputStream(f); + BufferedWriter bos = new BufferedWriter(new OutputStreamWriter(fos)); + bos.write(str); + bos.flush(); + } finally { + fos.close(); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/ConfigPanelCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/ConfigPanelCreator.java new file mode 100644 index 00000000..da3974a3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/ConfigPanelCreator.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +public class ConfigPanelCreator implements Function { + public static final ConfigPanelCreator INSTANCE = new ConfigPanelCreator(); + + public static final Map> map = new HashMap>(); + + @Nullable + @Override + public MPanel apply(@Nullable String input) { + if (!map.containsKey(input)) return null; + return map.get(input).get(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/GuiConfigV2.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/GuiConfigV2.java new file mode 100644 index 00000000..0f6be522 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/GuiConfigV2.java @@ -0,0 +1,59 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import kr.syeyoung.dungeonsguide.mod.gui.MGui; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.util.MathHelper; + +import java.awt.*; + +public class GuiConfigV2 extends MGui { + + @Getter + private RootConfigPanel rootConfigPanel; + + public GuiConfigV2() { + rootConfigPanel = new RootConfigPanel(this); + getMainPanel().add(rootConfigPanel); + } + + + @Override + public void initGui() { + super.initGui(); + int dw = Minecraft.getMinecraft().displayWidth; + int dh = Minecraft.getMinecraft().displayHeight; + int width = MathHelper.clamp_int(dw - 200, 1250, 1500), height = MathHelper.clamp_int(dh - 200, 600, 800); + double scale = 2.0; + if (dw <= width || dh <= height) { + width = width/2; height = height/2; + scale = 1.0; + } + rootConfigPanel.setBounds(new Rectangle((dw-width)/2, (dh-height)/2, width,height)); + rootConfigPanel.setScale(scale); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MCategory.java new file mode 100644 index 00000000..c4561c09 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MCategory.java @@ -0,0 +1,103 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +public class MCategory extends MPanel { + + private NestedCategory nestedCategory; + private RootConfigPanel rootConfigPanel; + @Getter + @Setter + private Color hover = new Color(94, 94, 94, 255); + public MCategory(NestedCategory nestedCategory, RootConfigPanel rootConfigPanel) { + this.nestedCategory = nestedCategory; + this.rootConfigPanel = rootConfigPanel; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + int border = RenderUtils.blendAlpha(0x141414, 0.12f); + if (!rootConfigPanel.getSearchWord().isEmpty() && (nestedCategory.categoryName().toLowerCase().contains(rootConfigPanel.getSearchWord()))) { + border = 0xFF02EE67; + } + + Gui.drawRect(0,0,getBounds().width, getBounds().height,border); + if (getBounds().height >= 28) + Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); + Gui.drawRect(1,1,getBounds().width-1, 18, RenderUtils.blendAlpha(0x141414, 0.12f)); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.pushMatrix(); + GlStateManager.translate(5,5,0); + GlStateManager.scale(1.0,1.0,0); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + + fr.drawString((lastAbsClip.contains(absMousex, absMousey) ? "ยงn" : "") + nestedCategory.categoryName(), 0,0, 0xFFFFFFFF); + GlStateManager.popMatrix(); + + fr.drawSplitString(FeatureRegistry.getCategoryDescription().getOrDefault(nestedCategory.categoryFull(), ""), 5, 23, getBounds().width -10, 0xFFBFBFBF); + } + + + @Override + public Dimension getPreferredSize() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + int descriptionHeight = + FeatureRegistry.getCategoryDescription().containsKey(nestedCategory.categoryFull()) ? + fr.listFormattedStringToWidth(FeatureRegistry.getCategoryDescription().get(nestedCategory.categoryFull()), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT + : -9; + + return new Dimension(100, descriptionHeight + 28); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY)) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); + rootConfigPanel.setCurrentPageAndPushHistory(nestedCategory.categoryFull()); + } + } + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY)) + setCursor(EnumCursor.POINTING_HAND); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MCategoryElement.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MCategoryElement.java new file mode 100644 index 00000000..74f5f352 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MCategoryElement.java @@ -0,0 +1,82 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.util.ResourceLocation; + +import java.awt.*; + +public class MCategoryElement extends MPanel { + private String category; + private Runnable onClick; + private int leftPad = 0; + private int offsetX; + private RootConfigPanel rootConfigPanel; + public MCategoryElement(String category, Runnable onClick, int leftPad, int offsetX, RootConfigPanel rooot) { + this.category = category; + this.onClick = onClick; + this.leftPad = leftPad; + this.offsetX = offsetX; + this.rootConfigPanel = rooot; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (rootConfigPanel.getCurrentPage().equals(category)) { + clip(0,scissor.y, Minecraft.getMinecraft().displayWidth, scissor.height); + Gui.drawRect(leftPad - offsetX, 0, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.13f)); + } else if (lastAbsClip.contains(absMousex, absMousey) && getTooltipsOpen() == 0) { + clip(0,scissor.y, Minecraft.getMinecraft().displayWidth, scissor.height); + Gui.drawRect(leftPad - offsetX, 0, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.09f)); + } + clip(scissor.x, scissor.y, scissor.width, scissor.height); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String name = category.substring(category.lastIndexOf(".")+1); + fr.drawString(name, leftPad,2,-1); + + } + + @Override + public Dimension getPreferredSize() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + return new Dimension(fr.getStringWidth(category.substring(category.lastIndexOf(".")+1)) + leftPad+10, fr.FONT_HEIGHT+4); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!lastAbsClip.contains(absMouseX, absMouseY) || getTooltipsOpen() > 0) { return; } + if (onClick != null) onClick.run(); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); + + } + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY)) + setCursor(EnumCursor.POINTING_HAND); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MFeature.java new file mode 100644 index 00000000..070f4fce --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MFeature.java @@ -0,0 +1,154 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MToggleButton; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class MFeature extends MPanel { + + @Getter + private final AbstractFeature feature; + + private final List addons = new ArrayList(); + + @Getter @Setter + private Color hover; + + private final RootConfigPanel panel; + + public MFeature(final AbstractFeature abstractFeature, final RootConfigPanel panel) { + this.panel = panel; + this.feature = abstractFeature; + + if (abstractFeature.isDisyllable()) { + final MToggleButton mStringSelectionButton = new MToggleButton(); + mStringSelectionButton.setOnToggle(new Runnable() { + @Override + public void run() { + boolean selected = mStringSelectionButton.isEnabled(); + feature.setEnabled(selected); + } + }); + mStringSelectionButton.setBackground(RenderUtils.blendAlpha(0x141414, 0.07f)); + addons.add(mStringSelectionButton); + mStringSelectionButton.setEnabled(feature.isEnabled()); + mStringSelectionButton.setSize(new Dimension(40, 15)); + add(mStringSelectionButton); + } + if (abstractFeature.getParameters().size() != 0) { + MButton button = new MButton(); + button.setText("Settings"); + button.setOnActionPerformed(new Runnable() { + @Override + public void run() { + panel.setCurrentPageAndPushHistory(abstractFeature.getEditRoute(panel)); + } + }); + button.setBackground(RenderUtils.blendAlpha(0x141414, 0.07f)); + button.setClicked(RenderUtils.blendAlpha(0x141414, 0.17f)); + button.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); + addons.add(button); + button.setSize(new Dimension(50, 15)); + add(button); + } + if (abstractFeature instanceof GuiFeature) { + MButton button = new MButton(); + button.setText("Relocate"); + button.setOnActionPerformed(new Runnable() { + @Override + public void run() { + Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(Minecraft.getMinecraft().currentScreen, abstractFeature)); + button.setIsclicked(false); + } + }); + button.setBackground(RenderUtils.blendAlpha(0x141414, 0.07f)); + button.setClicked(RenderUtils.blendAlpha(0x141414, 0.17f)); + button.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); + addons.add(button); + button.setSize(new Dimension(75, 15)); + add(button); + } + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + + int border = RenderUtils.blendAlpha(0x141414, 0.12f); + if (!panel.getSearchWord().isEmpty() && (feature.getName().toLowerCase().contains(panel.getSearchWord()) || feature.getDescription().toLowerCase().contains(panel.getSearchWord()))) { + border = 0xFF02EE67; + } + + Gui.drawRect(0,0,getBounds().width, getBounds().height,border); + Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); + Gui.drawRect(1,1,getBounds().width-1, 18, RenderUtils.blendAlpha(0x141414, 0.12f)); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.pushMatrix(); + GlStateManager.translate(5,5,0); + GlStateManager.scale(1.0,1.0,0); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(feature.getName(), 0,0, 0xFFFFFFFF); + GlStateManager.popMatrix(); + + fr.drawSplitString(feature.getDescription(), 5, 23, getBounds().width -10, 0xFFBFBFBF); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + } + + @Override + public Dimension getPreferredSize() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int descriptionHeight = fr.listFormattedStringToWidth(feature.getDescription(), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT; + + return new Dimension(100, descriptionHeight + 28); + } + + @Override + public void onBoundsUpdate() { + int x = getBounds().width - 5; + for (MPanel panel : addons) { + panel.setBounds(new Rectangle(x - panel.getPreferredSize().width, 3, panel.getPreferredSize().width, 12)); + x -= panel.getPreferredSize().width + 5; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MFeatureEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MFeatureEdit.java new file mode 100644 index 00000000..87e1b6f1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MFeatureEdit.java @@ -0,0 +1,113 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MList; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MModalConfirmation; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +public class MFeatureEdit extends MPanel { + private MList list; + private MButton goBack, resetToDefault; + private RootConfigPanel rootConfigPanel; + private AbstractFeature abstractFeature; + + private Map parameterEdits = new HashMap<>(); + + public MFeatureEdit(AbstractFeature abstractFeature, RootConfigPanel rootConfigPanel) { + this.abstractFeature = abstractFeature; + this.rootConfigPanel = rootConfigPanel; + list = new MList(); + list.setGap(5); + list.setDrawLine(false); + add(list); + + goBack = new MButton(); + goBack.setText("< Go Back"); + goBack.setOnActionPerformed(rootConfigPanel::goBack); + add(goBack); + resetToDefault = new MButton(); + resetToDefault.setText("Reset To Default"); + resetToDefault.setForeground(Color.red); + resetToDefault.setOnActionPerformed(() -> { + openResetConfirmation(); + }); + add(resetToDefault); + } + + public void openResetConfirmation() { + MModalConfirmation mModal = new MModalConfirmation("Are you sure?", + "Resetting to default will reset your configuration for the selected feature to default", + () -> { + for (FeatureParameter parameter : abstractFeature.getParameters()) { + parameter.setToDefault(); + } + abstractFeature.onParameterReset(); + rootConfigPanel.invalidatePage(abstractFeature.getEditRoute(rootConfigPanel)); + }, () -> {}); + mModal.setScale(getScale()); + mModal.getYes().setBorder(0xFFFF0000); + mModal.getYes().setText("Yes, Reset it"); + mModal.getNo().setText("Cancel"); + mModal.open(MFeatureEdit.this); + } + + public void addParameterEdit(String name, MPanel paramEdit) { + parameterEdits.put(name, paramEdit); + list.add(paramEdit); + } + public MPanel removeParameterEdit(String name) { + MPanel panel = parameterEdits.remove(name); + list.remove(panel); + return panel; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + super.resize(parentWidth, parentHeight); + setBounds(new Rectangle(0,0,parentWidth,parentHeight)); + Dimension prefSize = getPreferredSize(); + int hei = prefSize.height; + setBounds(new Rectangle(0,0,parentWidth,hei)); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + goBack.setBounds(new Rectangle(5,5,75,15)); + resetToDefault.setBounds(new Rectangle(bounds.width - 105, 5, 100, 15)); + + list.setBounds(new Rectangle(5,25,bounds.width - 10, bounds.height - 10)); + list.realignChildren(); + + } + + @Override + public Dimension getPreferredSize() { + Dimension listPref = list.getPreferredSize(); + return new Dimension(listPref.width + 10, listPref.height + 30); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MNotFound.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MNotFound.java new file mode 100644 index 00000000..b63c4e90 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MNotFound.java @@ -0,0 +1,38 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; + +public class MNotFound extends MPanel { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,0,parentWidth,parentHeight)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("404 Not Found", (getBounds().width - fr.getStringWidth("404 Not Found")) / 2, (getBounds().height - fr.FONT_HEIGHT) / 2, -1); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MPanelCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MPanelCategory.java new file mode 100644 index 00000000..435940d3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MPanelCategory.java @@ -0,0 +1,83 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MList; + +import java.awt.*; + +public class MPanelCategory extends MPanel { + + private NestedCategory key; + private RootConfigPanel rootConfigPanel; + + private MList list; + + public MPanelCategory(NestedCategory nestedCategory, RootConfigPanel rootConfigPanel) { + this.key = nestedCategory; + this.rootConfigPanel = rootConfigPanel; + + list = new MList(); + list.setDrawLine(false); + list.setGap(5); + add(list); + + for (NestedCategory value : nestedCategory.children().values()) { + list.add(new MCategory(value, rootConfigPanel)); + } + if (nestedCategory.parent() != null) { + String actualCategory = nestedCategory.categoryFull().substring(5); + if (FeatureRegistry.getFeaturesByCategory().containsKey(actualCategory)) + for (AbstractFeature abstractFeature : FeatureRegistry.getFeaturesByCategory().get(actualCategory)) { + MFeature mFeature = new MFeature(abstractFeature, rootConfigPanel); + list.add(mFeature); + mFeature.setHover(new Color(94, 94, 94, 255)); + } + } + list.realignChildren(); + + } + + @Override + public void resize(int parentWidth, int parentHeight) { + super.resize(parentWidth, parentHeight); + setBounds(new Rectangle(0,0,parentWidth,parentHeight)); + Dimension prefSize = getPreferredSize(); + int hei = prefSize.height; + setBounds(new Rectangle(0,0,parentWidth,hei)); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + list.setBounds(new Rectangle(5,5,bounds.width- 10, bounds.height - 10)); + list.realignChildren(); + } + + @Override + public Dimension getPreferredSize() { + Dimension prefSize = list.getPreferredSize(); + int wid = prefSize.width + 10; + int hei = prefSize.height + 10; + return new Dimension(wid, hei); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MParameterEdit.java new file mode 100644 index 00000000..e73e851b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/MParameterEdit.java @@ -0,0 +1,219 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.util.function.Predicate; + +public class MParameterEdit extends MPanel { + private AbstractFeature abstractFeature; + private FeatureParameter featureParameter; + private RootConfigPanel rootConfigPanel; + private MPanel valueEditHolder; + private MPanel valueEdit; + + private Predicate isDisabled ; + + public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel) { + this(abstractFeature, parameter, rootConfigPanel, (a) -> false); + } + + public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, Predicate isDisabled ) { + this.abstractFeature = abstractFeature; + this.featureParameter = parameter; + this.rootConfigPanel = rootConfigPanel; + this.isDisabled = isDisabled; + + if (parameter.getValue_type().equals("string")) { + valueEdit = new MTextField() { + @Override + public void edit(String str) { + parameter.setValue(str); + } + }; + ((MTextField)valueEdit).setText((String) parameter.getValue()); + } else if (parameter.getValue_type().equals("integer")) { + valueEdit = new MIntegerSelectionButton((Integer) parameter.getValue()); + ((MIntegerSelectionButton)valueEdit).setOnUpdate(() -> { + parameter.setValue(((MIntegerSelectionButton) valueEdit).getData()); + }); + } else if (parameter.getValue_type().equals("float")) { + valueEdit = new MFloatSelectionButton((Float) parameter.getValue()); + ((MFloatSelectionButton)valueEdit).setOnUpdate(() -> { + parameter.setValue(((MFloatSelectionButton) valueEdit).getData()); + }); + } else if (parameter.getValue_type().equals("acolor")) { + valueEdit = new MEditableAColor(); + ((MEditableAColor)valueEdit).setColor((AColor) parameter.getValue()); + ((MEditableAColor)valueEdit).setEnableEdit(true); + ((MEditableAColor)valueEdit).setOnUpdate(() -> { + parameter.setValue(((MEditableAColor) valueEdit).getColor()); + }); + } else if (parameter.getValue_type().equals("color")) { + valueEdit = new MEditableAColor(); + ((MEditableAColor)valueEdit).setColor(new AColor(((Color) parameter.getValue()).getRGB(), true)); + ((MEditableAColor)valueEdit).setEnableEdit(true); + ((MEditableAColor)valueEdit).setOnUpdate(() -> { + parameter.setValue(((MEditableAColor) valueEdit).getColor()); + }); + } else if (parameter.getValue_type().equals("boolean")) { + valueEdit = new MToggleButton(); + ((MToggleButton)valueEdit).setEnabled((Boolean) parameter.getValue()); + ((MToggleButton)valueEdit).setOnToggle(() -> { + parameter.setValue(((MToggleButton) valueEdit).isEnabled()); + }); + } else if (parameter.getValue_type().equals("keybind")) { + valueEdit = new MKeyEditButton(); + ((MKeyEditButton)valueEdit).setKey((Integer) parameter.getValue()); + ((MKeyEditButton)valueEdit).setOnKeyEdit(() -> { + parameter.setValue(((MKeyEditButton) valueEdit).getKey()); + }); + ((MKeyEditButton)valueEdit).setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); + }else { + valueEdit = new MLabel(); + ((MLabel)valueEdit).setText("????"); + } + + + valueEditHolder = new MPanel() { + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + Dimension dimension = valueEdit.getPreferredSize(); + if (dimension.width <= 0) dimension.width = bounds.width/2; + if (dimension.height <= 0) dimension.height = bounds.height/2; + valueEdit.setBounds(new Rectangle((bounds.width - dimension.width)/2,(bounds.height - dimension.height)/2,dimension.width, dimension.height)); + } + }; + add(valueEditHolder); + valueEditHolder.add(valueEdit); + } + public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, MPanel valueEdit, Predicate isDisabled) { + this.abstractFeature = abstractFeature; + this.featureParameter = parameter; + this.rootConfigPanel = rootConfigPanel; + this.isDisabled = isDisabled; + + + valueEditHolder = new MPanel() { + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + Dimension dimension = valueEdit.getPreferredSize(); + if (dimension.width <= 0) dimension.width = bounds.width/2; + if (dimension.height <= 0) dimension.height = bounds.height/2; + valueEdit.setBounds(new Rectangle((bounds.width - dimension.width)/2,(bounds.height - dimension.height)/2,dimension.width, dimension.height)); + } + }; + add(valueEditHolder); + valueEditHolder.add(valueEdit); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f)); + Gui.drawRect(2*bounds.width / 3,1,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); + Gui.drawRect(4, 15,2*bounds.width / 3-5, 16, RenderUtils.blendAlpha(0x141414, 0.3f)); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString(featureParameter.getName(), 5,5, 0xFFFFFFFF); + fr.drawSplitString(featureParameter.getDescription(), 5,18, 2*bounds.width /3-10, 0xFFAAAAAA); + + } + + @Override + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { + super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); + if (isDisabled.test(featureParameter)) { + Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55000000); + } + } + + @Override + public Dimension getPreferredSize() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int descriptionHeight = fr.listFormattedStringToWidth(featureParameter.getDescription(), Math.max(50, 2*bounds.width/3-10)).size() * fr.FONT_HEIGHT; + return new Dimension(100, Math.max(30, descriptionHeight + 23)); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + valueEditHolder.setBounds(new Rectangle(2*bounds.width / 3, 0, bounds.width / 3, bounds.height)); + } + + @Override + public void keyPressed0(char typedChar, int keyCode) { + if (isDisabled.test(featureParameter)) return; + super.keyPressed0(typedChar, keyCode); + } + + @Override + public void keyHeld0(char typedChar, int keyCode) { + if (isDisabled.test(featureParameter)) return; + super.keyHeld0(typedChar, keyCode); + } + + @Override + public void keyReleased0(char typedChar, int keyCode) { + if (isDisabled.test(featureParameter)) return; + super.keyReleased0(typedChar, keyCode); + } + + @Override + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + if (isDisabled.test(featureParameter)) return false; + return super.mouseClicked0(absMouseX, absMouseY, relMouseX0, relMouseY0, mouseButton); + } + + @Override + public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { + if (isDisabled.test(featureParameter)) return ; + super.mouseReleased0(absMouseX, absMouseY, relMouseX0, relMouseY0, state); + } + + @Override + public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { + if (isDisabled.test(featureParameter)) return ; + super.mouseClickMove0(absMouseX, absMouseY, relMouseX0, relMouseY0, clickedMouseButton, timeSinceLastClick); + } + + @Override + public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (isDisabled.test(featureParameter)) return ; + super.mouseScrolled0(absMouseX, absMouseY, relMouseX0, relMouseY0, scrollAmount); + } + + @Override + public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (isDisabled.test(featureParameter)) return ; + super.mouseMoved0(absMouseX, absMouseY, relMouseX0, relMouseY0); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/NestedCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/NestedCategory.java new file mode 100644 index 00000000..28a3d4d1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/NestedCategory.java @@ -0,0 +1,54 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.LinkedHashMap; +import java.util.Map; + +@Data +@Accessors(chain = true, fluent = true) +public +class NestedCategory { + private final String categoryFull; + @EqualsAndHashCode.Exclude + private String categoryName; + @EqualsAndHashCode.Exclude + @ToString.Exclude + private NestedCategory parent; + + public NestedCategory(String categoryFull) { + this.categoryFull = categoryFull; + this.categoryName = categoryFull.substring(categoryFull.lastIndexOf(".") + 1); + } + + @EqualsAndHashCode.Exclude + @ToString.Exclude + private Map children = new LinkedHashMap<>(); + + public NestedCategory child(NestedCategory child) { + this.children.put(child.categoryName, child); + child.parent = this; + return this; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/RootConfigPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/RootConfigPanel.java new file mode 100644 index 00000000..d4d7dcf9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/RootConfigPanel.java @@ -0,0 +1,311 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig; + +import com.google.common.base.Function; +import kr.syeyoung.dungeonsguide.auth.AuthManager; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; + +public class RootConfigPanel extends MPanelScaledGUI { + private MScrollablePanel navigationScroll; + + private MList navigation = new MList(); + + private MScrollablePanel contentScroll; + + + private final Map pages = new HashMap(); + @Getter + @Setter + private Function pageGenerator = ConfigPanelCreator.INSTANCE; + @Getter + private String currentPage = ""; + + private GuiConfigV2 gui; + + private long lastPageSet = System.currentTimeMillis(); + + private MTextField search; + private MButton guiRelocate; + + private MButton github, discord; + + private final Stack history = new Stack(); + + public String getSearchWord() { + return search.getText().trim().toLowerCase(); + } + + public RootConfigPanel(GuiConfigV2 guiConfigV2) { + this.gui = guiConfigV2; + + search = new MTextField() { + @Override + public void edit(String str) { + setupNavigation(); + + setCurrentPageAndPushHistory(""); + if (!categoryMap.containsKey(lastOpenCategory)) { + for (Map.Entry nestedCategoryMPanelEntry : categoryMap.entrySet()) { + if (nestedCategoryMPanelEntry.getValue() instanceof MCategoryElement) { + setCurrentPageAndPushHistory(nestedCategoryMPanelEntry.getKey().categoryFull()); + lastOpenCategory = nestedCategoryMPanelEntry.getKey(); + break; + } + } + } + for (Map.Entry nestedCategoryMPanelEntry : categoryMap.entrySet()) { + if (nestedCategoryMPanelEntry.getValue() instanceof MCollapsable) { + ((MCollapsable) nestedCategoryMPanelEntry.getValue()).setCollapsed(false); + } + } + rePlaceElements(); + } + }; + search.setPlaceHolder("Search..."); + add(search); + guiRelocate = new MButton(); + guiRelocate.setText("Edit Gui Locations"); + guiRelocate.setOnActionPerformed(() -> { + Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(gui, null)); + guiRelocate.setIsclicked(false); + }); + guiRelocate.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); + add(guiRelocate); + + discord = new MButton(); github = new MButton(); + discord.setText("Discord"); github.setText("Github"); + discord.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); + github.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); + github.setOnActionPerformed(() -> { + try { + Desktop.getDesktop().browse(new URI("https://github.com/Dungeons-Guide/Skyblock-Dungeons-Guide/")); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + }); + discord.setOnActionPerformed(() -> { + try { + Desktop.getDesktop().browse(new URI("https://discord.gg/VuxayCWGE8")); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + }); + add(discord); add(github); + + navigationScroll = new MScrollablePanel(1); + navigationScroll.setHideScrollBarWhenNotNecessary(false); + + + add(navigationScroll); + navigationScroll.add(navigation); + + contentScroll = new MScrollablePanel(3); + contentScroll.setHideScrollBarWhenNotNecessary(true); + add(contentScroll); + + setupNavigation(); + navigation.setGap(0); + navigation.setDrawLine(false); + + setCurrentPageAndPushHistory("ROOT"); + rePlaceElements(); + + search.setFocused(true); + } + + + private Map categoryMap = new HashMap<>(); + private NestedCategory lastOpenCategory; + private void setupNavigation() { + categoryMap.clear(); + for (MPanel childComponent : navigation.getChildComponents()) { + navigation.remove(childComponent); + } + NestedCategory root = new NestedCategory("ROOT"); + Set categoryAllowed = new HashSet<>(); + String search = this.search.getText().trim().toLowerCase(); + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (search.isEmpty()) { + categoryAllowed.add("ROOT."+abstractFeature.getCategory()+"."); + } else if (abstractFeature.getName().toLowerCase().contains(search)) { + categoryAllowed.add("ROOT."+abstractFeature.getCategory()+"."); + } else if (abstractFeature.getDescription().toLowerCase().contains(search)) { + categoryAllowed.add("ROOT."+abstractFeature.getCategory()+"."); + } + } + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + String category = abstractFeature.getCategory(); + boolean test =false; + for (String s : categoryAllowed) { + if (s.startsWith("ROOT."+category+".")) { + test = true; + break; + } + } + if (!test) continue; + + NestedCategory currentRoot = root; + for (String s : category.split("\\.")) { + NestedCategory finalCurrentRoot = currentRoot; + if (currentRoot.children().containsKey(s)) + currentRoot = currentRoot.children().get(s); + else { + currentRoot.child(currentRoot = new NestedCategory(finalCurrentRoot.categoryFull()+"."+s)); + } + } + + } + + for (NestedCategory value : root.children().values()) { + setupNavigationRecursive(value, navigation, 0, 17); + } + ConfigPanelCreator.map.put("ROOT", () -> new MPanelCategory(root, this)); + } + private void setupNavigationRecursive(NestedCategory nestedCategory, MPanel parent, int depth, int offset) { + ConfigPanelCreator.map.put(nestedCategory.categoryFull(), () -> new MPanelCategory(nestedCategory, this)); + + if (nestedCategory.children().size() == 0) { + MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull(),() -> { + setCurrentPageAndPushHistory(nestedCategory.categoryFull()); + lastOpenCategory = nestedCategory; + }, 13 * depth + 17, offset, this); + parent.add(current); + categoryMap.put(nestedCategory, current); + } else { + MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull(),() -> { + setCurrentPageAndPushHistory(nestedCategory.categoryFull()); + lastOpenCategory = nestedCategory; + }, 3,offset, this); + MCollapsable mCollapsable = new MCollapsable(current, this::rePlaceElements); + mCollapsable.setLeftPad(offset-13); + mCollapsable.getLowerElements().setDrawLine(false); + mCollapsable.getLowerElements().setGap(0); + mCollapsable.setLeftPadElements(0); + parent.add(mCollapsable); + categoryMap.put(nestedCategory, mCollapsable); + + for (NestedCategory value : nestedCategory.children().values()) { + setupNavigationRecursive(value, mCollapsable, depth+1, offset+13); + } + } + } + + + public void setCurrentPageAndPushHistory(String currentPage) { + if (!this.currentPage.equals(currentPage)) + history.push(this.currentPage); + lastOpenCategory = null; + this.currentPage = currentPage; + setupPage(); + } + public void goBack() { + if (history.size() == 0) return; + this.currentPage = history.pop(); + setupPage(); + } + + private void setupPage() { + contentScroll.getContentArea().getChildComponents().forEach(contentScroll.getContentArea()::remove); + if (!pages.containsKey(currentPage)) { + MPanel page = pageGenerator.apply(currentPage); + if (page == null) page = new MNotFound(); + pages.put(currentPage, page); + } + contentScroll.getContentArea().add(pages.get(currentPage)); + rePlaceElements(); + } + + public void invalidatePage(String page) { + pages.remove(page); + if (page.equals(currentPage)) + setupPage(); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Dimension effectiveDim = getEffectiveDimension(); + Gui.drawRect(0,0, (int) (effectiveDim.width), (int) (effectiveDim.height), RenderUtils.blendAlpha(0x141414, 0.00f)); + Gui.drawRect(0,0, (int) (effectiveDim.width), 25, RenderUtils.blendAlpha(0x0, 0.20f)); +// Gui.drawRect(navigationScroll.getBounds().x + navigationScroll.getBounds().width - 10, 25, navigationScroll.getBounds().x + navigationScroll.getBounds().width , 50, RenderUtils.blendAlpha(0xFF141414, 0.04f)); + Gui.drawRect(0, 25,navigationScroll.getBounds().x + navigationScroll.getBounds().width , 50, RenderUtils.blendAlpha(0xFF141414, 0.08f)); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + if(AuthManager.getInstance().getToken() == null) { + fr.drawString("ERROR CONNECTING TO DG, YOUR COSMETICS ARE NOT VISIBLE",(effectiveDim.width - fr.getStringWidth("ERROR CONNECTING TO DG, YOUR COSMETICS ARE NOT VISIBLE"))/2, (10 - fr.FONT_HEIGHT)/2, 0xFFFF0000); + } + + fr.drawString("DungeonsGuide By syeyoung", (effectiveDim.width - fr.getStringWidth("DungeonsGuide By syeyoung"))/2, (25 - fr.FONT_HEIGHT)/2, 0xFF02EE67); + } + + @Override + public void render0(double parentScale, Point parentPoint, Rectangle parentClip, int absMousex0, int absMousey0, int relMousex0, int relMousey0, float partialTicks) { + super.render0(parentScale, parentPoint, parentClip, absMousex0, absMousey0, relMousex0, relMousey0, partialTicks); + Dimension effectiveDim = getEffectiveDimension(); + Gui.drawRect(0,24, (int) (Double.min(1, (System.currentTimeMillis() - lastPageSet)/1000.0) * effectiveDim.width), 25, 0xFF02EE67); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + rePlaceElements(); + } + + @Override + public void setScale(double scale) { + super.setScale(scale); + rePlaceElements(); + } + + private void rePlaceElements() { + Dimension effectiveDim = getEffectiveDimension(); + + navigation.setBounds(new Rectangle(new Point(0,1), new Dimension(Math.max(100, Math.max(navigation.getPreferredSize().width, navigationScroll.getBounds().width-10)), navigation.getPreferredSize().height))); + navigation.realignChildren(); + + navigationScroll.evalulateContentArea(); + Rectangle navBound; + navigationScroll.setBounds(navBound = new Rectangle(0,50, navigation.getBounds().width+10, effectiveDim.height-50)); + contentScroll.setBounds(new Rectangle(navBound.x + navBound.width, 25, effectiveDim.width - navBound.x - navBound.width, effectiveDim.height-25)); + + search.setBounds(new Rectangle(5,30,navBound.x + navBound.width - 10,15)); + + guiRelocate.setBounds(new Rectangle(5,5,100,15)); + github.setBounds(new Rectangle(effectiveDim.width - 80,5,75,15)); + discord.setBounds(new Rectangle(effectiveDim.width - 160,5,75,15)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/GuiGuiLocationConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/GuiGuiLocationConfig.java new file mode 100755 index 00000000..0b4193da --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/GuiGuiLocationConfig.java @@ -0,0 +1,166 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig.location; + +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.gui.MGui; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.io.IOException; +import java.util.*; +import java.util.List; + +public class GuiGuiLocationConfig extends MGui { + + @Getter + private final GuiScreen before; + + @Getter + private TreeMap> markerTreeMapByX = new TreeMap<>(); + @Getter + private TreeMap> markerTreeMapByY = new TreeMap<>(); + @Getter + private Set markerSet = new HashSet<>(); + + + Marker[] markers = new Marker[4]; + + + public GuiGuiLocationConfig(final GuiScreen before, AbstractFeature featureWhitelist) { + this.before = before; + for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { + if (feature instanceof GuiFeature && feature.isEnabled()) { + getMainPanel().add(new PanelDelegate((GuiFeature) feature, featureWhitelist == null || feature == featureWhitelist, this)); + } + } + + getMainPanel().setBackgroundColor(new Color(0,0,0, 100)); + } + + public static final Vec3[] facing = new Vec3[] { + new Vec3(0, 0.5, 2), + new Vec3(0.5, 0, 1), + new Vec3(0.5, 1, 3), + new Vec3(1, 0.5, 4), + }; + + public void removeAndAddMarker(Marker prev, Marker newM) { + if (prev != null) { + markerTreeMapByX.computeIfPresent(prev.getX(),(k,v) -> { + v.remove(prev); + if (v.isEmpty()) return null; + else return v; + }); + markerTreeMapByY.computeIfPresent(prev.getY(),(k,v) -> { + v.remove(prev); + if (v.isEmpty()) return null; + else return v; + }); + markerSet.remove(prev); + } + if (newM != null) { + markerTreeMapByX.compute(newM.getX(), (k,v) -> { + if (v == null) { + return new ArrayList<>(Arrays.asList(newM)); + } else { + v.add(newM); + return v; + } + }); + markerTreeMapByY.compute(newM.getY(), (k,v) -> { + if (v == null) { + return new ArrayList<>(Arrays.asList(newM)); + } else { + v.add(newM); + return v; + } + }); + markerSet.add(newM); + } + } + + public void setupMarkers() { + for (int i1 = 0; i1 < markers.length; i1++) { + Marker orig = markers[i1]; + Vec3 pt = facing[i1]; + markers[i1] = new Marker((int) (pt.xCoord * getMainPanel().getBounds().width), (int) (pt.yCoord * getMainPanel().getBounds().height), (int) pt.zCoord, this); + + removeAndAddMarker(orig, markers[i1]); + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + GlStateManager.pushMatrix(); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GlStateManager.translate(scaledResolution.getScaledWidth()/2, scaledResolution.getScaledHeight()/2, 0); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GlStateManager.color(1, 1, 1, 1); + fr.drawString("Right Click On Elements to Open Popup Menu", + -fr.getStringWidth("Right Click On Elements to Open Popup Menu")/2 + ,-fr.FONT_HEIGHT/2, -1); + GlStateManager.popMatrix(); + super.drawScreen(mouseX, mouseY, partialTicks); + } + + @Override + public void keyTyped(char typedChar, int keyCode) throws IOException { + try { + getMainPanel().keyPressed0(typedChar, keyCode); + + if (keyCode == 1) { + Minecraft.getMinecraft().displayGuiScreen(before); + } + } catch (Throwable e) { + if (!e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + @Override + public void initGui() { + super.initGui(); + getMainPanel().setBounds(new Rectangle(0,0,Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight)); + markerTreeMapByX.clear(); + markerTreeMapByY.clear(); + markerSet.clear(); + setupMarkers(); + for (MPanel childComponent : getMainPanel().getChildComponents()) { + if (childComponent instanceof PanelDelegate) { + ((PanelDelegate) childComponent).rebuildMarker(); + } + } + + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/Marker.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/Marker.java new file mode 100644 index 00000000..10683425 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/Marker.java @@ -0,0 +1,45 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig.location; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.ToString; + +@Getter +@ToString +@AllArgsConstructor +public class Marker { + private final int x; + private final int y; + /** + * 0xABCDEFGH + * A: ? + * B: ? + * C: ? + * D: ? + * EF: 0~3 (TC 0x00 CL 0x01 BC 0x10 CR 0x11) + */ + private final int type; + private final Object parent; + + public int distanceSQ(Marker m2) { + return (m2.x - x)*(m2.x - x) + (m2.y - y)*(m2.y - y); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/PanelDelegate.java new file mode 100644 index 00000000..3c03fb73 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/location/PanelDelegate.java @@ -0,0 +1,403 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig.location; + +import kr.syeyoung.dungeonsguide.mod.config.types.GUIRectangle; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MPopupMenu; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltip; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Tuple; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class PanelDelegate extends MPanel { + private final GuiFeature guiFeature; + private boolean draggable = false; + private GuiGuiLocationConfig guiGuiLocationConfig; + + private Set markerSet = new HashSet<>(); + public PanelDelegate(GuiFeature guiFeature, boolean draggable, GuiGuiLocationConfig guiGuiLocationConfig) { + this.guiFeature = guiFeature; + this.draggable = draggable; + this.guiGuiLocationConfig = guiGuiLocationConfig; + } + + public void rebuildMarker() { + internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale(); + applyConstraint(); + } + + @Override + public Rectangle getBounds() { + Rectangle rectangle = guiFeature.getFeatureRect().getRectangle(); + return new Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height); + } + + @Override + public void render(int absMousex, int absMousey, int relMouseX, int relMouseY, float partialTicks, Rectangle scissor) { + if (!guiFeature.isEnabled()) return; + + GlStateManager.pushMatrix(); + guiFeature.drawDemo(partialTicks); + GlStateManager.popMatrix(); + if (!draggable) return; + Gui.drawRect(0,0, 4, 4, 0xFFBBBBBB); + Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0xFFBBBBBB); + Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0xFFBBBBBB); + Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0xFFBBBBBB); + if (lastAbsClip.contains(absMousex, absMousey)) { + if (relMouseX < 4 && relMouseY < 4) { + Gui.drawRect(0,0, 4, 4, 0x55FFFFFF); + } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { + Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0x55FFFFFF); + } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { + Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0x55FFFFFF); + } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { + Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0x55FFFFFF); + } else if (selectedPart == -2){ + Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55FFFFFF); + } + } + GlStateManager.enableBlend(); + } + + @Override + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { + GlStateManager.pushMatrix(); + super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); + GlStateManager.popMatrix(); + + if (snapped != null && selectedPart != -2) { + Tessellator tessellator = Tessellator.getInstance(); + GlStateManager.disableTexture2D(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); + GL11.glLineWidth(1); + for (Tuple markerAxisTuple : snapped) { + if (markerAxisTuple.getSecond() == EnumFacing.Axis.X) { + worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), 0, 0).color(0,255,0,255).endVertex(); + worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), Minecraft.getMinecraft().displayHeight, 0).color(0,255,0,255).endVertex(); + } else { + worldRenderer.pos(0, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex(); + worldRenderer.pos(Minecraft.getMinecraft().displayWidth, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex(); + } + } + tessellator.draw(); + for (Marker marker : guiGuiLocationConfig.getMarkerSet()) { + Gui.drawRect(marker.getX(),marker.getY(), marker.getX()+1, marker.getY()+1, 0xFFFF0000); + } + } + } + + private int selectedPart = -2; + + private int lastX = 0; + private int lastY = 0; + + private Rectangle internallyThinking; + private Rectangle constraintApplied; + + private Set> snapped = new HashSet<>(); + + public void applyConstraint() { + constraintApplied = internallyThinking.getBounds(); + + // SNAP Moving Point. + snapped.clear(); + int scailingThreshold = 5; + if (selectedPart == 0){ + Point snapPt = new Point(constraintApplied.x +constraintApplied.width, constraintApplied.y + constraintApplied.height); + Optional snapX, snapY; + SortedMap> markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(snapPt.x-scailingThreshold, snapPt.x +scailingThreshold); + snapX = markerSortedMap.values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(a -> a.getParent() != this) + .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY()))); + markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(snapPt.y-scailingThreshold, snapPt.y +scailingThreshold); + snapY = markerSortedMap.values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(a -> a.getParent() != this) + .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY()))); + snapX.ifPresent(a -> { + snapPt.x = a.getX(); + }); + snapY.ifPresent(a -> { + snapPt.y = a.getY(); + }); + + constraintApplied = new Rectangle(constraintApplied.x, constraintApplied.y, snapPt.x - constraintApplied.x, snapPt.y - constraintApplied.y); + + + + int minWidth; + int minHeight; + if (guiFeature.isKeepRatio()) { + if (guiFeature.getDefaultRatio() >= 1) { + minHeight = constraintApplied.height < 0 ? -8 : 8; + minWidth = (int) (guiFeature.getDefaultRatio() * minHeight); + } else { + minWidth = constraintApplied.width < 0 ? -8 : 8; + minHeight = (int) (minWidth / guiFeature.getDefaultRatio()); + } + } else { + minWidth = constraintApplied.width < 0 ? -8 : 8; + minHeight = constraintApplied.height < 0 ? -8 : 8; + } + + + constraintApplied.width = Math.abs(constraintApplied.width) > Math.abs(minWidth) ? constraintApplied.width : + Math.abs(internallyThinking.width) > Math.abs(minWidth) ? internallyThinking.width : minWidth; + constraintApplied.height = Math.abs(constraintApplied.height) > Math.abs(minHeight) ? constraintApplied.height : + Math.abs(internallyThinking.height) > Math.abs(minHeight) ? internallyThinking.height : minHeight; + + if (guiFeature.isKeepRatio()) { + double ratio = guiFeature.getDefaultRatio(); + + int heightWhenWidthFix = (int) Math.abs(constraintApplied.width / ratio); + int widthWhenHeightFix = (int) Math.abs(ratio * constraintApplied.height); + if (Math.abs(heightWhenWidthFix) <= Math.abs(constraintApplied.height)) { + constraintApplied.height = constraintApplied.height < 0 ? -heightWhenWidthFix : heightWhenWidthFix; + } else if (Math.abs(widthWhenHeightFix) <= Math.abs(constraintApplied.width)) { + constraintApplied.width =constraintApplied.width < 0 ? - widthWhenHeightFix : widthWhenHeightFix; + } + } + + + snapX.ifPresent(a -> { + if (snapPt.x - constraintApplied.x == constraintApplied.width) { + Marker m = new Marker((int) (GuiGuiLocationConfig.facing[3].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[3].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[3].zCoord, this); + snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.X)); + } + }); + snapY.ifPresent(a -> { + if (snapPt.y - constraintApplied.y == constraintApplied.height) { + Marker m = new Marker((int) (GuiGuiLocationConfig.facing[2].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[2].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[2].zCoord, this); + snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.Y)); + } + }); + + if (constraintApplied.height < 0) { + constraintApplied.height = -constraintApplied.height; + constraintApplied.y -= constraintApplied.height; + } + + if (constraintApplied.width < 0) { + constraintApplied.width = -constraintApplied.width; + constraintApplied.x -= constraintApplied.width; + } + } else if (selectedPart == -1) { + for (int i : Arrays.asList(0,3,1,2)) { + Vec3 pt = GuiGuiLocationConfig.facing[i]; + Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); + Optional result = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(m.getX()-scailingThreshold, m.getX() +scailingThreshold).values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(a -> a.getParent() != this) + .filter(a -> Math.abs(a.getX() - m.getX()) < scailingThreshold) + .filter(a -> ((a.getX() - pt.xCoord * constraintApplied.width) >= 0 + && (a.getX() - pt.xCoord * constraintApplied.width + constraintApplied.width) <= Minecraft.getMinecraft().displayWidth)) + .min(Comparator.comparingInt(a -> a.distanceSQ(m))); + if (result.isPresent()) { + int x = result.get().getX(); + constraintApplied.x = (int) (x - pt.xCoord * constraintApplied.width); + + snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.X)); + break; + } + } + for (int i : Arrays.asList(1,2,0,3)) { + Vec3 pt = GuiGuiLocationConfig.facing[i]; + Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); + Optional result = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(m.getY()-scailingThreshold, m.getY() +scailingThreshold).values().stream() + .filter(Objects::nonNull) + .flatMap(Collection::stream) + .filter(a -> a.getParent() != this) + .filter(a -> Math.abs(a.getY() - m.getY()) < scailingThreshold) + .filter(a -> ((a.getY() - pt.yCoord * constraintApplied.height) >= 0 + && (a.getY() - pt.yCoord * constraintApplied.height+ constraintApplied.height) <= Minecraft.getMinecraft().displayHeight)) + .min(Comparator.comparingInt(a -> a.distanceSQ(m))); + if (result.isPresent()) { + int y = result.get().getY(); + constraintApplied.y = (int) (y - pt.yCoord * constraintApplied.height); + snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.Y)); + break; + } + } + } + + if (constraintApplied.x < 0) constraintApplied.x = 0; + if (constraintApplied.y < 0) constraintApplied.y = 0; + if (constraintApplied.x + constraintApplied.width + 1 >=Minecraft.getMinecraft().displayWidth) constraintApplied.x = Minecraft.getMinecraft().displayWidth - constraintApplied.width - 1; + if (constraintApplied.y + constraintApplied.height + 1>= Minecraft.getMinecraft().displayHeight) constraintApplied.y = Minecraft.getMinecraft().displayHeight - constraintApplied.height - 1; + + + setupMarkers(); + } + + Marker[] markers = new Marker[4]; + public void setupMarkers() { + for (int i1 = 0; i1 < markers.length; i1++) { + Marker orig = markers[i1]; + + Vec3 pt = GuiGuiLocationConfig.facing[i1]; + markers[i1] = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this); + + guiGuiLocationConfig.removeAndAddMarker(orig, markers[i1]); + } + } + + MTooltip mTooltip; + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!draggable) return; + if (!guiFeature.isEnabled()) return; + if (getTooltipsOpen() > 0) return; + if (!lastAbsClip.contains(absMouseX, absMouseY)) return; + if (mouseButton == 0) { + internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale(); + if (relMouseX < 4 && relMouseY < 4) { // TL + selectedPart = 0; + internallyThinking.y += internallyThinking.height; + internallyThinking.height = -internallyThinking.height; + internallyThinking.x += internallyThinking.width; + internallyThinking.width = -internallyThinking.width; + } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { // BL + selectedPart = 0; + internallyThinking.x += internallyThinking.width; + internallyThinking.width = -internallyThinking.width; + } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { // BR + selectedPart = 0; + } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { // TR + selectedPart = 0; + internallyThinking.y += internallyThinking.height; + internallyThinking.height = -internallyThinking.height; + } else { + selectedPart = -1; + } + lastX = absMouseX; + lastY = absMouseY; + applyConstraint(); + + } else if (getTooltipsOpen() == 0){ + if (mTooltip != null) mTooltip.close(); + mTooltip = new MPopupMenu(absMouseX, absMouseY, guiFeature.getTooltipForEditor(guiGuiLocationConfig)); + mTooltip.setScale(2.0f); + mTooltip.open(this); + } + throw new IllegalArgumentException("bruh, a hack to stop event progress"); + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + if (!draggable) return; + if (!guiFeature.isEnabled()) return; + if (selectedPart >= -1) { + guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); + } + + selectedPart = -2; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + if (!draggable) return; + if (!guiFeature.isEnabled()) return; + int dx = (absMouseX - lastX); + int dy = (absMouseY - lastY); + if (selectedPart >= 0) { + Rectangle rectangle = internallyThinking; + + int prevWidth = rectangle.width; + int prevHeight= rectangle.height; + + rectangle.width = prevWidth + dx; + rectangle.height = prevHeight + dy; + + if (rectangle.height * prevHeight <= 0 && prevHeight != rectangle.height) { + rectangle.height += prevHeight < 0 ? 4 : -4; + } + if (rectangle.width * prevWidth <= 0 && prevWidth != rectangle.width) { + rectangle.width += prevWidth < 0 ? 4 : -4; + } + + + applyConstraint(); + guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); + lastX = absMouseX; + lastY = absMouseY; + throw new IllegalArgumentException("bruh, a hack to stop event progress"); + } else if (selectedPart == -1){ + Rectangle rectangle = internallyThinking; + rectangle.translate(dx, dy); + applyConstraint(); + guiFeature.setFeatureRect(new GUIRectangle(constraintApplied)); + lastX = absMouseX; + lastY = absMouseY; + } + } + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX, int relMouseY) { + if (!draggable) return; + if (!guiFeature.isEnabled()) return; + if (getTooltipsOpen() > 0) return; + + if (selectedPart == -1) { + setCursor(EnumCursor.CLOSED_HAND); + } else if (selectedPart >= 0) { + if (internallyThinking.width < 0 && internallyThinking.height < 0) { + setCursor(EnumCursor.RESIZE_TL); + } else if (internallyThinking.width < 0 && internallyThinking.height >= 0) { + setCursor(EnumCursor.RESIZE_DL); + } else if (internallyThinking.width >= 0 && internallyThinking.height >= 0) { + setCursor(EnumCursor.RESIZE_DR); + } else if (internallyThinking.width >= 0 && internallyThinking.height < 0) { + setCursor(EnumCursor.RESIZE_TR); + } + } else if (lastAbsClip.contains(absMouseX, absMouseY)) { + if (relMouseX < 4 && relMouseY < 4) { + setCursor(EnumCursor.RESIZE_TL); + } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { + setCursor(EnumCursor.RESIZE_DL); + } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { + setCursor(EnumCursor.RESIZE_DR); + } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { + setCursor(EnumCursor.RESIZE_TR); + } else { + setCursor(EnumCursor.OPEN_HAND); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/AColor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/AColor.java new file mode 100644 index 00000000..3b5f3d36 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/AColor.java @@ -0,0 +1,63 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; + +@Getter +@Setter +public class AColor extends Color { + private boolean chroma; + private float chromaSpeed; + + public AColor(int r, int g, int b, int a) { + super(r, g, b, a); + } + + public AColor(int rgba, boolean hasalpha) { + super(rgba, hasalpha); + } + + public AColor(AColor clone) { + super(clone.getRGB(), true); + chroma = clone.isChroma(); + chromaSpeed = clone.getChromaSpeed(); + } + + public AColor multiplyAlpha(double multiplier) { + AColor aColor = new AColor(getRed(), getGreen(), getBlue(), (int) (getAlpha() * multiplier)); + aColor.chroma = this.chroma; + aColor.chromaSpeed = this.chromaSpeed; + return aColor; + } + + @Override + public String toString() { + return "AColor{" + + ", r="+getRed()+ + ", g="+getGreen()+ + ", b="+getBlue()+ + ", a="+getAlpha()+ + ", chromaSpeed=" + chromaSpeed + + '}'; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/GUIRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/GUIRectangle.java new file mode 100644 index 00000000..cf43fbfb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/GUIRectangle.java @@ -0,0 +1,81 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import net.minecraft.client.Minecraft; + +import java.awt.*; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GUIRectangle { + public GUIRectangle(Rectangle rectangle) { + if (rectangle.x < Minecraft.getMinecraft().displayWidth / 2) { + this.x = rectangle.x; + this.width = rectangle.width; + } else { + this.x = rectangle.x + rectangle.width - Minecraft.getMinecraft().displayWidth; + this.width = -rectangle.width; + } + + if (rectangle.y < Minecraft.getMinecraft().displayHeight / 2) { + this.y = rectangle.y; + this.height = rectangle.height; + } else { + this.y = rectangle.y +rectangle.height - Minecraft.getMinecraft().displayHeight; + this.height = -rectangle.height; + } + } + + private int x; + private int y; + private int width; + private int height; + + public Rectangle getRectangle() { + return getRectangleNoScale(); + } +// public Rectangle getRectangle(ScaledResolution scaledResolution) { +// double realX = (int) (x < 0 ? scaledResolution.getScaledWidth() + x : x); +// double realY = (int) (y < 0 ? scaledResolution.getScaledHeight() + y : y); +// +// return new Rectangle((int)Math.min(realX + width, realX), (int)Math.min(realY + height, realY), +// (int)Math.abs(width), (int)Math.abs(height)); +// } + public Rectangle getRectangleNoScale() { + int x = this.x, y = this.y; + if (Math.abs(x) > Minecraft.getMinecraft().displayWidth / 2) { + x = x < 0 ? -Minecraft.getMinecraft().displayWidth/2 : Minecraft.getMinecraft().displayWidth/2; + } + if (Math.abs(y) > Minecraft.getMinecraft().displayHeight / 2) { + y = y < 0 ? -Minecraft.getMinecraft().displayHeight/2 : Minecraft.getMinecraft().displayHeight/2; + } + + + double realX = (int) (x < 0 ? Minecraft.getMinecraft().displayWidth + x : x); + double realY = (int) (y < 0 ? Minecraft.getMinecraft().displayHeight + y : y); + + return new Rectangle((int)Math.min(realX + width, realX), (int)Math.min(realY + height, realY), + (int)Math.abs(width), (int)Math.abs(height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCAColor.java new file mode 100644 index 00000000..dfc2d461 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCAColor.java @@ -0,0 +1,51 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; + +public class TCAColor implements TypeConverter { + @Override + public String getTypeString() { + return "acolor"; + } + + @Override + public AColor deserialize(JsonElement element) { + if (element instanceof JsonPrimitive) + return new AColor(element.getAsInt(), true); + + JsonObject object = element.getAsJsonObject(); + AColor color = new AColor(object.get("color").getAsInt(), true); + color.setChroma(object.get("chroma").getAsBoolean()); + color.setChromaSpeed(object.get("chromaSpeed").getAsFloat()); + return color; + } + + @Override + public JsonElement serialize(AColor element) { + JsonObject object = new JsonObject(); + object.addProperty("color", element.getRGB()); + object.addProperty("chroma", element.isChroma()); + object.addProperty("chromaSpeed", element.getChromaSpeed()); + return object; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCBoolean.java new file mode 100644 index 00000000..f973f495 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCBoolean.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCBoolean implements TypeConverter { + @Override + public String getTypeString() { + return "boolean"; + } + + @Override + public Boolean deserialize(JsonElement element) { + return element.getAsBoolean(); + } + + @Override + public JsonElement serialize(Boolean element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCColor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCColor.java new file mode 100644 index 00000000..2544a4f3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCColor.java @@ -0,0 +1,41 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +import java.awt.*; + +public class TCColor implements TypeConverter { + @Override + public String getTypeString() { + return "color"; + } + + @Override + public Color deserialize(JsonElement element) { + return new Color(element.getAsInt()); + } + + @Override + public JsonElement serialize(Color element) { + return new JsonPrimitive(element.getRGB()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCFloat.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCFloat.java new file mode 100644 index 00000000..2f2aa72f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCFloat.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCFloat implements TypeConverter { + @Override + public String getTypeString() { + return "float"; + } + + @Override + public Float deserialize(JsonElement element) { + return element.getAsFloat(); + } + + @Override + public JsonElement serialize(Float element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCGUIRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCGUIRectangle.java new file mode 100644 index 00000000..8d34b013 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCGUIRectangle.java @@ -0,0 +1,50 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +public class TCGUIRectangle implements TypeConverter { + @Override + public String getTypeString() { + return "guirect"; + } + + @Override + public GUIRectangle deserialize(JsonElement element) { + if (element == null) return null; + GUIRectangle rectangle = new GUIRectangle(); + rectangle.setX(((JsonObject)element).get("x").getAsInt()); + rectangle.setY(((JsonObject)element).get("y").getAsInt()); + rectangle.setWidth(((JsonObject)element).get("width").getAsInt()); + rectangle.setHeight(((JsonObject)element).get("height").getAsInt()); + return rectangle; + } + + @Override + public JsonElement serialize(GUIRectangle element) { + JsonObject object = new JsonObject(); + object.addProperty("x", element.getX()); + object.addProperty("y", element.getY()); + object.addProperty("width", element.getWidth()); + object.addProperty("height", element.getHeight()); + return object; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCInteger.java new file mode 100644 index 00000000..e895345d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCInteger.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCInteger implements TypeConverter { + @Override + public String getTypeString() { + return "integer"; + } + + @Override + public Integer deserialize(JsonElement element) { + return element.getAsInt(); + } + + @Override + public JsonElement serialize(Integer element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCKeybind.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCKeybind.java new file mode 100644 index 00000000..5b3bb09b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCKeybind.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCKeybind implements TypeConverter { + @Override + public String getTypeString() { + return "keybind"; + } + + @Override + public Integer deserialize(JsonElement element) { + return element.getAsInt(); + } + + @Override + public JsonElement serialize(Integer element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRectangle.java new file mode 100644 index 00000000..37736d44 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCRectangle.java @@ -0,0 +1,51 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import java.awt.*; + +public class TCRectangle implements TypeConverter { + @Override + public String getTypeString() { + return "rect"; + } + + @Override + public Rectangle deserialize(JsonElement element) { + Rectangle rectangle = new Rectangle(); + rectangle.x = ((JsonObject)element).get("x").getAsInt(); + rectangle.y = ((JsonObject)element).get("y").getAsInt(); + rectangle.width = ((JsonObject)element).get("width").getAsInt(); + rectangle.height = ((JsonObject)element).get("height").getAsInt(); + return rectangle; + } + + @Override + public JsonElement serialize(Rectangle element) { + JsonObject object = new JsonObject(); + object.addProperty("x", element.x); + object.addProperty("y", element.y); + object.addProperty("width", element.width); + object.addProperty("height", element.height); + return object; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCString.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCString.java new file mode 100644 index 00000000..b2f9dab4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCString.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +public class TCString implements TypeConverter { + @Override + public String getTypeString() { + return "string"; + } + + @Override + public String deserialize(JsonElement element) { + return element.getAsString(); + } + + @Override + public JsonElement serialize(String element) { + return new JsonPrimitive(element); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCStringList.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCStringList.java new file mode 100644 index 00000000..90d78d2a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCStringList.java @@ -0,0 +1,51 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +import java.util.ArrayList; +import java.util.List; + +public class TCStringList implements TypeConverter> { + @Override + public String getTypeString() { + return "stringlist"; + } + + @Override + public List deserialize(JsonElement element) { + List strList = new ArrayList<>(); + for (JsonElement jsonElement : element.getAsJsonArray()) { + strList.add(jsonElement.getAsString()); + } + return strList; + } + + @Override + public JsonElement serialize(List element) { + JsonArray jsonElements = new JsonArray(); + for (String s : element) { + jsonElements.add(new JsonPrimitive(s)); + } + return jsonElements; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCTextStyle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCTextStyle.java new file mode 100644 index 00000000..78f03ae0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCTextStyle.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; + +public class TCTextStyle implements TypeConverter { + @Override + public String getTypeString() { + return "textstyle"; + } + + @Override + public TextStyle deserialize(JsonElement element) { + TextStyle textStyle = new TextStyle(); + textStyle.setColor(TypeConverterRegistry.getTypeConverter("acolor", AColor.class).deserialize(element.getAsJsonObject().get("color"))); + textStyle.setBackground(element.getAsJsonObject().has("background") ? TypeConverterRegistry.getTypeConverter("acolor", AColor.class).deserialize(element.getAsJsonObject().get("background")) + : new AColor(0x00777777, true)); + textStyle.setGroupName(element.getAsJsonObject().get("group").getAsString()); + if (element.getAsJsonObject().has("shadow")) + textStyle.setShadow(element.getAsJsonObject().get("shadow").getAsBoolean()); + return textStyle; + } + + @Override + public JsonElement serialize(TextStyle element) { + JsonObject jsonObject = new JsonObject(); + jsonObject.add("color", TypeConverterRegistry.getTypeConverter("acolor", AColor.class).serialize(element.getColor())); + jsonObject.add("background", TypeConverterRegistry.getTypeConverter("acolor", AColor.class).serialize(element.getBackground())); + jsonObject.addProperty("group", element.getGroupName()); + jsonObject.addProperty("shadow", element.isShadow()); + return jsonObject; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCTextStyleList.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCTextStyleList.java new file mode 100644 index 00000000..50455dd2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TCTextStyleList.java @@ -0,0 +1,54 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; + +import java.util.ArrayList; +import java.util.List; + +public class TCTextStyleList implements TypeConverter> { + @Override + public String getTypeString() { + return "list_textStyle"; + } + + @Override + public List deserialize(JsonElement element) { + JsonArray arr = element.getAsJsonArray(); + TypeConverter conv = TypeConverterRegistry.getTypeConverter("textstyle", TextStyle.class); + List texts = new ArrayList(); + for (JsonElement element2:arr) { + texts.add(conv.deserialize(element2)); + } + return texts; + } + + @Override + public JsonElement serialize(List element) { + JsonArray array = new JsonArray(); + TypeConverter conv = TypeConverterRegistry.getTypeConverter("textstyle", TextStyle.class); + for (TextStyle st:element) { + array.add(conv.serialize(st)); + } + return array; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TypeConverter.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TypeConverter.java new file mode 100644 index 00000000..eb4c7a27 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TypeConverter.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import com.google.gson.JsonElement; + +public interface TypeConverter { + String getTypeString(); + + T deserialize(JsonElement element); + + JsonElement serialize(T element); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TypeConverterRegistry.java new file mode 100644 index 00000000..f635d6ad --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/config/types/TypeConverterRegistry.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.config.types; + +import java.util.HashMap; +import java.util.Map; + +public class TypeConverterRegistry { + private static final Map typeConverterMap = new HashMap(); + + public static void register(TypeConverter typeConverter) { + typeConverterMap.put(typeConverter.getTypeString(), typeConverter); + } + + public static TypeConverter getTypeConverter(String type_string) { + return typeConverterMap.get(type_string); + } + public static TypeConverter getTypeConverter(String type_string, Class t) { + return (TypeConverter)typeConverterMap.get(type_string); + } + + static { + register(new TCBoolean()); + register(new TCInteger()); + register(new TCRectangle()); + register(new TCGUIRectangle()); + register(new TCString()); + register(new TCColor()); + register(new TCFloat()); + register(new TCAColor()); + register(new TCTextStyleList()); + register(new TCTextStyle()); + register(new TCStringList()); + register(new TCKeybind()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/ActiveCosmetic.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/ActiveCosmetic.java new file mode 100644 index 00000000..b71a003c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/ActiveCosmetic.java @@ -0,0 +1,12 @@ +package kr.syeyoung.dungeonsguide.mod.cosmetics; + +import lombok.Data; +import java.util.UUID; + +@Data +public class ActiveCosmetic { + private UUID activityUID; + private UUID playerUID; + private UUID cosmeticData; + private String username; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CosmeticData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CosmeticData.java new file mode 100644 index 00000000..7626b119 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CosmeticData.java @@ -0,0 +1,14 @@ +package kr.syeyoung.dungeonsguide.mod.cosmetics; + + +import lombok.Data; + +import java.util.UUID; + +@Data +public class CosmeticData { + private UUID id; + private String cosmeticType; + private String reqPerm; + private String data; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CosmeticsManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CosmeticsManager.java new file mode 100644 index 00000000..4a625574 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CosmeticsManager.java @@ -0,0 +1,288 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics; + +import kr.syeyoung.dungeonsguide.mod.cosmetics.chatreplacers.*; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerListItemPacketEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.StompConnectedEvent; +import kr.syeyoung.dungeonsguide.mod.stomp.*; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.play.server.S38PacketPlayerListItem; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.ReflectionHelper; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CopyOnWriteArraySet; + +public class CosmeticsManager { + @Getter + private Map cosmeticDataMap = new ConcurrentHashMap<>(); + @Getter + private Map activeCosmeticMap = new ConcurrentHashMap<>(); + @Getter + private Map> activeCosmeticByType = new ConcurrentHashMap<>(); + @Getter + private Map> activeCosmeticByPlayer = new ConcurrentHashMap<>(); + @Getter + private Map> activeCosmeticByPlayerNameLowerCase = new ConcurrentHashMap<>(); + @Getter + private Set perms = new CopyOnWriteArraySet<>(); + + public void requestActiveCosmetics() { + StompManager.getInstance().send(new StompPayload() + .method(StompHeader.SEND) + .destination("/app/cosmetic.activelist") + ); + } + public void requestCosmeticsList() { + StompManager.getInstance().send(new StompPayload() + .method(StompHeader.SEND) + .destination("/app/cosmetic.list") + ); + } + public void requestPerms() { + StompManager.getInstance().send(new StompPayload() + .method(StompHeader.SEND) + .destination("/app/user.perms") + ); + } + public void setCosmetic(CosmeticData cosmetic) { + if (!perms.contains(cosmetic.getReqPerm())) return; + StompManager.getInstance().send(new StompPayload() + .method(StompHeader.SEND) + .destination("/app/cosmetic.set") + .payload(cosmetic.getId().toString()) + ); + } + public void removeCosmetic(ActiveCosmetic activeCosmetic) { + StompManager.getInstance().send(new StompPayload() + .method(StompHeader.SEND) + .destination("/app/cosmetic.remove") + .payload(activeCosmetic.getActivityUID().toString()) + ); + } + + private void rebuildCaches() { + activeCosmeticByType = new HashMap<>(); + activeCosmeticByPlayer = new HashMap<>(); + Map> activeCosmeticByPlayerName = new HashMap<>(); + for (ActiveCosmetic value : activeCosmeticMap.values()) { + CosmeticData cosmeticData = cosmeticDataMap.get(value.getCosmeticData()); + if (cosmeticData != null) { + List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); + cosmeticsByTypeList.add(value); + } + List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(value.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); + activeCosmetics.add(value); + activeCosmetics = activeCosmeticByPlayerName.computeIfAbsent(value.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); + activeCosmetics.add(value); + } + + this.activeCosmeticByPlayerNameLowerCase = activeCosmeticByPlayerName; + } + + @SubscribeEvent + public void stompConnect(StompConnectedEvent e) { + + e.getStompInterface().subscribe("/topic/cosmetic.set", (stompClient, payload) -> { + JSONObject jsonObject = new JSONObject(payload); + ActiveCosmetic activeCosmetic = new ActiveCosmetic(); + activeCosmetic.setActivityUID(UUID.fromString(jsonObject.getString("activityUID"))); + activeCosmetic.setPlayerUID(UUID.fromString(jsonObject.getString("playerUID"))); + if (jsonObject.isNull("cosmeticUID")) { + ActiveCosmetic activeCosmetic1 = activeCosmeticMap.remove(activeCosmetic.getActivityUID()); + + List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(activeCosmetic.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); + activeCosmetics.remove(activeCosmetic1); + + activeCosmetics = activeCosmeticByPlayerNameLowerCase.computeIfAbsent(activeCosmetic1.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); + activeCosmetics.remove(activeCosmetic1); + + CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); + if (cosmeticData != null) { + List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); + cosmeticsByTypeList.remove(activeCosmetic1); + } + } else { + activeCosmetic.setCosmeticData(UUID.fromString(jsonObject.getString("cosmeticUID"))); + activeCosmetic.setUsername(jsonObject.getString("username")); + + ActiveCosmetic previousThing = activeCosmeticMap.get(activeCosmetic.getActivityUID()); + activeCosmeticMap.put(activeCosmetic.getActivityUID(), activeCosmetic); + + CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); + if (cosmeticData != null) { + List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); + cosmeticsByTypeList.add(activeCosmetic); + cosmeticsByTypeList.remove(previousThing); + } + List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(activeCosmetic.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); + activeCosmetics.add(activeCosmetic); + activeCosmetics.remove(previousThing); + + activeCosmetics = activeCosmeticByPlayerNameLowerCase.computeIfAbsent(activeCosmetic.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); + activeCosmetics.add(activeCosmetic); + activeCosmetics.remove(previousThing); + } + + try { + if (Minecraft.getMinecraft().theWorld != null) { + EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(activeCosmetic.getPlayerUID()); + if (entityPlayer != null) entityPlayer.refreshDisplayName(); + } + } catch (Exception exception) {exception.printStackTrace();} + }); + + + e.getStompInterface().subscribe("/user/queue/reply/user.perms", (stompClient ,payload) -> { + JSONArray object = new JSONArray(payload); + Set cache = new HashSet<>(); + for (Object o : object) { + cache.add((String) o); + } + this.perms = cache; + }); + + + + e.getStompInterface().subscribe("/user/queue/reply/cosmetic.activelist", (stompClient, payload) -> { + activeCosmeticMap = new HashMap<>(); + JSONArray object = new JSONArray(payload); + for (Object o : object) { + JSONObject jsonObject = (JSONObject) o; + ActiveCosmetic cosmeticData = new ActiveCosmetic(); + cosmeticData.setActivityUID(UUID.fromString(jsonObject.getString("activityUID"))); + cosmeticData.setPlayerUID(UUID.fromString(jsonObject.getString("playerUID"))); + cosmeticData.setCosmeticData(UUID.fromString(jsonObject.getString("cosmeticUID"))); + cosmeticData.setUsername(jsonObject.getString("username")); + + activeCosmeticMap.put(cosmeticData.getActivityUID(), cosmeticData); + try { + if (Minecraft.getMinecraft().theWorld != null) { + EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(cosmeticData.getPlayerUID()); + if (entityPlayer != null) entityPlayer.refreshDisplayName(); + } + } catch (Exception exception) {exception.printStackTrace();} + } + rebuildCaches(); + }); + + + + e.getStompInterface().subscribe("/user/queue/reply/cosmetic.list", (stompClient ,payload) -> { + JSONArray object = new JSONArray(payload); + Map newCosmeticList = new HashMap<>(); + for (Object o : object) { + JSONObject jsonObject = (JSONObject) o; + CosmeticData cosmeticData = new CosmeticData(); + cosmeticData.setCosmeticType(jsonObject.getString("cosmeticType")); + cosmeticData.setReqPerm(jsonObject.getString("reqPerm")); + cosmeticData.setData(jsonObject.getString("data")); + cosmeticData.setId(UUID.fromString(jsonObject.getString("id"))); + + newCosmeticList.put(cosmeticData.getId(), cosmeticData); + } + + cosmeticDataMap = newCosmeticList; + rebuildCaches(); + }); + + + requestCosmeticsList(); + requestActiveCosmetics(); + requestPerms(); + } + @Getter @Setter + private static List iChatReplacers = new ArrayList<>(); + static { + iChatReplacers.add(new ChatReplacerViewProfile()); + iChatReplacers.add(new ChatReplacerPV()); + iChatReplacers.add(new ChatReplacerSocialOptions()); + iChatReplacers.add(new ChatReplacerCoop()); + iChatReplacers.add(new ChatReplacerMessage()); + iChatReplacers.add(new ChatReplacerChatByMe()); + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + try { + if (clientChatReceivedEvent.type == 2) return; + for (IChatReplacer iChatReplacer : iChatReplacers) { + if (iChatReplacer.isAcceptable(clientChatReceivedEvent)) { + iChatReplacer.translate(clientChatReceivedEvent, this); + return; + } + } + } catch (Throwable t) { + System.out.println(clientChatReceivedEvent.message); + t.printStackTrace(); + } + } + + + @SubscribeEvent + public void onTabList(PlayerListItemPacketEvent packetPlayerListItem) { + S38PacketPlayerListItem asd = packetPlayerListItem.getPacketPlayerListItem(); + if (asd.getAction() == S38PacketPlayerListItem.Action.ADD_PLAYER) { + if (Minecraft.getMinecraft().getNetHandler() == null) return; + + Map playerInfoMap = ReflectionHelper.getPrivateValue(NetHandlerPlayClient.class, Minecraft.getMinecraft().getNetHandler(), "playerInfoMap", "field_147310_i","i"); + for (S38PacketPlayerListItem.AddPlayerData entry : asd.getEntries()) { + playerInfoMap.remove(entry.getProfile().getId()); + playerInfoMap.put(entry.getProfile().getId(), new CustomNetworkPlayerInfo(entry)); + } + } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void nameFormat(PlayerEvent.NameFormat nameFormat) { + List activeCosmetics = activeCosmeticByPlayer.get(nameFormat.entityPlayer.getGameProfile().getId()); + if (activeCosmetics == null) return; + CosmeticData color=null; + CosmeticData prefix=null; + for (ActiveCosmetic activeCosmetic : activeCosmetics) { + CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + + if (color != null) + nameFormat.displayname = color.getData().replace("&","ยง")+nameFormat.username; + + if (prefix != null) + nameFormat.displayname = prefix.getData().replace("&","ยง")+" "+nameFormat.displayname; + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java new file mode 100644 index 00000000..7be9a1ca --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java @@ -0,0 +1,108 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics; + +import com.mojang.authlib.GameProfile; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.network.play.server.S38PacketPlayerListItem; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; + +import java.util.List; + +public class CustomNetworkPlayerInfo extends NetworkPlayerInfo { + public CustomNetworkPlayerInfo(GameProfile gameProfile) { + super(gameProfile); + } + + public CustomNetworkPlayerInfo(S38PacketPlayerListItem.AddPlayerData playerData) { + super(playerData); + setDisplayName(super.getDisplayName()); + } + + + private IChatComponent displayName; + private String unformattedDisplayText; + private String playerNameWithoutColor; + + @Override + public void setDisplayName(IChatComponent displayNameIn) { + displayName = displayNameIn; + if (displayName == null) { + unformattedDisplayText = null; + return; + } + + unformattedDisplayText = displayName.getUnformattedTextForChat(); + + + playerNameWithoutColor = ""; + for (String s : unformattedDisplayText.split(" ")) { + String strippped = TextUtils.stripColor(s); + if (strippped.startsWith("[")) { + continue; + } + playerNameWithoutColor = strippped; + break; + } + } + + public IChatComponent getDisplayName() + { + + String rawPlayerString; + String actualName; + List activeCosmetics; + + // in case that the set player name is not called we do this + if (playerNameWithoutColor != null) { + activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(playerNameWithoutColor.toLowerCase()); + rawPlayerString = unformattedDisplayText; + actualName = this.playerNameWithoutColor; + } else { + rawPlayerString = ScorePlayerTeam.formatPlayerName(super.getPlayerTeam(), super.getGameProfile().getName()); + actualName = ""; + for (String s : rawPlayerString.split(" ")) { + String strippped = TextUtils.stripColor(s); + if (strippped.startsWith("[")) continue; + actualName = strippped; + break; + } + activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(actualName.toLowerCase()); + } + + + if (activeCosmetics == null) return displayName; + CosmeticData color=null; + for (ActiveCosmetic activeCosmetic : activeCosmetics) { + CosmeticData cosmeticData = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData.getCosmeticType().equals("color")) color = cosmeticData; + } + + if (color != null) { + String coloredName = color.getData() + actualName; + return new ChatComponentText(rawPlayerString.replace(actualName, coloredName)); + } else { + return new ChatComponentText(rawPlayerString); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomPacketPlayerListItem.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomPacketPlayerListItem.java new file mode 100644 index 00000000..3406288d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomPacketPlayerListItem.java @@ -0,0 +1,38 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics; + +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerListItemPacketEvent; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.network.play.server.S38PacketPlayerListItem; +import net.minecraftforge.common.MinecraftForge; + +public class CustomPacketPlayerListItem extends S38PacketPlayerListItem { + public CustomPacketPlayerListItem(S38PacketPlayerListItem packet) { + super(packet.getAction()); + getEntries().addAll(packet.getEntries()); + } + + @Override + public void processPacket(INetHandlerPlayClient handler) { + super.processPacket(handler); + + MinecraftForge.EVENT_BUS.post(new PlayerListItemPacketEvent(this)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/IChatReplacer.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/IChatReplacer.java new file mode 100644 index 00000000..483fadcf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/IChatReplacer.java @@ -0,0 +1,26 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics; + +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +public interface IChatReplacer { + boolean isAcceptable(ClientChatReceivedEvent event); + void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerChatByMe.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerChatByMe.java new file mode 100644 index 00000000..4e50b110 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerChatByMe.java @@ -0,0 +1,106 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; + +public class ChatReplacerChatByMe implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getUnformattedTextForChat().startsWith(": ")) return true; + } + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + List> replaceMents = new ArrayList<>(); + List iChatComponents = new ArrayList<>( event.message.getSiblings() ); + List hasMsg = new ArrayList<>(); + for (IChatComponent sibling : iChatComponents) { + if (sibling.getUnformattedTextForChat().startsWith(": ")) break; + hasMsg.add(sibling); + } + iChatComponents.removeAll(hasMsg); + + ChatComponentText chatComponents = new ChatComponentText(""); + chatComponents.getSiblings().addAll(hasMsg); + ChatStyle origStyle = hasMsg.get(0).getChatStyle(); + String name = chatComponents.getFormattedText(); + + String[] splited = name.split(" "); + String actualName = splited[splited.length-1]; + + List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(actualName).toLowerCase()); + if (cDatas == null) return; + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String building = ""; + if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; + for (int i = 0; i < splited.length-1; i++) { + building += splited[i] +" "; + } + + if (color != null) { + String nick = splited[splited.length-1]; + building += color.getData().replace("&","ยง"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == 'ยง' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + } else { + building += splited[splited.length-1] ; + } + + ChatComponentText chatComponents1 = new ChatComponentText(building); + chatComponents1.setChatStyle(origStyle); + event.message.getSiblings().clear(); + event.message.getSiblings().add(chatComponents1); + event.message.getSiblings().addAll(iChatComponents); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerCoop.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerCoop.java new file mode 100644 index 00000000..df003ec7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerCoop.java @@ -0,0 +1,119 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; + +public class ChatReplacerCoop implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getUnformattedTextForChat().startsWith("ยงbCo-op > ")) return true; + } + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + List> replaceMents = new ArrayList<>(); + List iChatComponents = new ArrayList<>( event.message.getSiblings() ); + IChatComponent sibling = iChatComponents.get(0); iChatComponents.remove(sibling); + + + String[] splitInto = sibling.getUnformattedTextForChat().split(" "); + int lastValidNickname = -1; + int lastprefix = -1; + for (int i = 0; i < splitInto.length; i++) { + String s = TextUtils.stripColor(splitInto[i]); + char c = s.charAt(0); + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { + lastValidNickname = i; + } + } + if (lastValidNickname == -1) return; + + if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; + else lastprefix = lastValidNickname; + + + List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(splitInto[lastValidNickname].substring(0, splitInto[lastValidNickname].length()-1)).toLowerCase()); + + if (cDatas == null) return; + + CosmeticData color = null, prefix = null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData != null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String building = ""; + for (int i = 0; i < lastprefix; i++) { + building += splitInto[i] +" "; + } + if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; + for (int i = lastprefix; i < lastValidNickname; i++) { + building += splitInto[i] +" "; + } + if (color != null) { + String nick = splitInto[lastValidNickname]; + building += color.getData().replace("&","ยง"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == 'ยง' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + building += " "; + } else { + building += splitInto[lastValidNickname] + " "; + } + for (int i = lastValidNickname+1; i. + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; + +public class ChatReplacerMessage implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/msg")) return true; + } + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + List> replaceMents = new ArrayList<>(); + List iChatComponents = new ArrayList<>( event.message.getSiblings() ); + List hasMsg = new ArrayList<>(); + for (IChatComponent sibling : iChatComponents) { + if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/msg")) { + hasMsg.add(sibling); + } + } + iChatComponents.removeAll(hasMsg); + + ChatComponentText chatComponents = new ChatComponentText(""); + chatComponents.getSiblings().addAll(hasMsg); + ChatStyle origStyle = hasMsg.get(0).getChatStyle(); + String name = chatComponents.getFormattedText(); + + + String[] splited = name.split(" "); + String actualName = splited[splited.length-1]; + + List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(actualName).toLowerCase()); + if (cDatas == null || splited.length > 2) return; + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String building = ""; + if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; + if (splited.length == 2) building += splited[0] +" "; + + if (color != null) { + String nick = splited[1]; + building += color.getData().replace("&","ยง"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == 'ยง' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + } else { + building += splited[1] ; + } + + ChatComponentText chatComponents1 = new ChatComponentText(building); + chatComponents1.setChatStyle(origStyle); + event.message.getSiblings().clear(); + event.message.getSiblings().add(chatComponents1); + event.message.getSiblings().addAll(iChatComponents); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerPV.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerPV.java new file mode 100644 index 00000000..b4e1b777 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/chatreplacers/ChatReplacerPV.java @@ -0,0 +1,119 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.List; + + +// Bug 289 - mod conflict with NEU (Replaces /socialoptions with /pv) +public class ChatReplacerPV implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/pv")) return true; + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/pv")) { + String username = event.message.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; + List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(username.toLowerCase()); + + if (cDatas != null) { + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String[] splitInto = event.message.getUnformattedTextForChat().split(" "); + int lastValidNickname = -1; + int lastprefix = -1; + for (int i = 0; i < splitInto.length; i++) { + String s = splitInto[i]; + if (s.startsWith("ยง7")) s = s.substring(2); + char c = s.charAt(0); + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { + lastValidNickname = i; + if (i >= 1) { + String str = TextUtils.stripColor(splitInto[i-1]); + if (str.startsWith("[") && str.endsWith("]"))break; + } + } + } + if (lastValidNickname == -1) return; + + if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; + else lastprefix = lastValidNickname; + + String building = ""; + for (int i = 0; i < lastprefix; i++) { + building += splitInto[i] +" "; + } + if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; + for (int i = lastprefix; i < lastValidNickname; i++) { + building += splitInto[i] +" "; + } + if (color != null) { + String nick = splitInto[lastValidNickname]; + building += color.getData().replace("&","ยง"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == 'ยง' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + building += " "; + } else { + building += splitInto[lastValidNickname] + " "; + } + for (int i = lastValidNickname+1; i. + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.List; + +public class ChatReplacerSocialOptions implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) return true; + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) { + String username = event.message.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; + List cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(username.toLowerCase()); + + if (cDatas != null) { + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String[] splitInto = event.message.getUnformattedTextForChat().split(" "); + int lastValidNickname = -1; + int lastprefix = -1; + for (int i = 0; i < splitInto.length; i++) { + String s = splitInto[i]; + if (s.startsWith("ยง7")) s = s.substring(2); + char c = s.charAt(0); + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { + lastValidNickname = i; + if (i >= 1) { + String str = TextUtils.stripColor(splitInto[i-1]); + if (str.startsWith("[") && str.endsWith("]"))break; + } + } + } + if (lastValidNickname == -1) return; + + if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; + else lastprefix = lastValidNickname; + + String building = ""; + for (int i = 0; i < lastprefix; i++) { + building += splitInto[i] +" "; + } + if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; + for (int i = lastprefix; i < lastValidNickname; i++) { + building += splitInto[i] +" "; + } + if (color != null) { + String nick = splitInto[lastValidNickname]; + building += color.getData().replace("&","ยง"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == 'ยง' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + building += " "; + } else { + building += splitInto[lastValidNickname] + " "; + } + for (int i = lastValidNickname+1; i. + */ + +package kr.syeyoung.dungeonsguide.mod.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; + +public class ChatReplacerViewProfile implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/viewprofile ")) return true; + } + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + List> replaceMents = new ArrayList<>(); + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/viewprofile ")) { + String uid = sibling.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; + // TODO: make cosmeticsManager handle usernames instead of uuids + // apperantly now hypixels /viewprofile command gives the nickname +// List cDatas = cosmeticsManager.getActiveCosmeticByPlayer().get(UUID.fromString(uid)); + List cDatas = null; + + if (cDatas != null) { + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String[] splitInto = sibling.getUnformattedTextForChat().split(" "); + int lastValidNickname = -1; + int lastprefix = -1; + for (int i = 0; i < splitInto.length; i++) { + String s = TextUtils.stripColor(splitInto[i]); + char c = s.charAt(0); + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { + lastValidNickname = i; + if (i >= 1) { + String str = TextUtils.stripColor(splitInto[i-1]); + if (str.startsWith("[") && str.endsWith("]"))break; + } + } + } + if (lastValidNickname == -1) continue; + + if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; + else lastprefix = lastValidNickname; + + String building = ""; + for (int i = 0; i < lastprefix; i++) { + building += splitInto[i] +" "; + } + if (prefix != null) building += prefix.getData().replace("&", "ยง") + " "; + for (int i = lastprefix; i < lastValidNickname; i++) { + building += splitInto[i] +" "; + } + if (color != null) { + String nick = splitInto[lastValidNickname]; + building += color.getData().replace("&","ยง"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == 'ยง' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + building += " "; + } else { + building += splitInto[lastValidNickname] + " "; + } + for (int i = lastValidNickname+1; i(sibling, newChatCompText)); + break; + } + } + } + + for (Tuple replaceMent : replaceMents) { + int index = event.message.getSiblings().indexOf(replaceMent.getFirst()); + event.message.getSiblings().set(index, replaceMent.getSecond()); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/GameSDK.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/GameSDK.java new file mode 100644 index 00000000..f66043b5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/GameSDK.java @@ -0,0 +1,87 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk; + +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Platform; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.GameSDKTypeMapper; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import lombok.Getter; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.util.Collections; + +public class GameSDK { + @Getter + private static NativeGameSDK nativeGameSDK; + + static { + try { + if (System.getProperty("dg.safe") == null) extractLibrary(); + } catch (IOException e) { + e.printStackTrace(); + } + } + public static void extractLibrary() throws IOException { + String libName = System.mapLibraryName("discord_game_sdk"); + String dir = ""; + switch(Platform.getOSType()) { + case Platform.MAC: + dir = "darwin"; + break; + case Platform.LINUX: + dir = "linux"; + break; + case Platform.WINDOWS: + if (Platform.is64Bit()) dir = "win-x64"; + else dir = "win-x86"; + break; + default: + throw new IllegalStateException("Unsupported OS Type"); + } + + String resourceLoc = "/gamesdk/"+dir+"/"+libName; + File targetExtractionPath = new File("native/"+libName); + targetExtractionPath.getParentFile().mkdirs(); + try (InputStream is = GameSDK.class.getResourceAsStream(resourceLoc)) { + Files.copy(is, targetExtractionPath.toPath(), StandardCopyOption.REPLACE_EXISTING); + targetExtractionPath.deleteOnExit(); + } + + nativeGameSDK = (NativeGameSDK) Native.loadLibrary(targetExtractionPath.getAbsolutePath(), NativeGameSDK.class, + Collections.singletonMap(Library.OPTION_TYPE_MAPPER, GameSDKTypeMapper.INSTANCE)); + } + + public static void writeString(byte[] bts, String str) { + System.arraycopy(str.getBytes(), 0, bts, 0, str.getBytes().length); + bts[str.getBytes().length] = 0; + } + public static String readString(byte[] bts) { + int i; + for (i = 0; i < bts.length && bts[i] != 0; i++); + byte[] asdasd = new byte[i]; + System.arraycopy(bts, 0, asdasd, 0, i); + return new String(asdasd); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/GameSDKTypeMapper.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/GameSDKTypeMapper.java new file mode 100644 index 00000000..e895935a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/GameSDKTypeMapper.java @@ -0,0 +1,46 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna; + +import com.sun.jna.DefaultTypeMapper; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.*; + +public class GameSDKTypeMapper extends DefaultTypeMapper { + public static final GameSDKTypeMapper INSTANCE = new GameSDKTypeMapper(); + private GameSDKTypeMapper() { + addTypeConverter(EDiscordResult.class, new EDiscordResult.EDiscordResultTypeConverter()); + addTypeConverter(EDiscordCreateFlags.class, new EDiscordCreateFlags.EDiscordCreateFlagsTypeConverter()); + addTypeConverter(EDiscordLogLevel.class, new EDiscordLogLevel.EDiscordLogLevelTypeConverter()); + addTypeConverter(EDiscordUserFlag.class, new EDiscordUserFlag.EDiscordUserFlagTypeConverter()); + addTypeConverter(EDiscordPremiumType.class, new EDiscordPremiumType.EDiscordPremiumTypeTypeConverter()); + addTypeConverter(EDiscordImageType.class, new EDiscordImageType.EDiscordImageTypeTypeConverter()); + addTypeConverter(EDiscordActivityType.class, new EDiscordActivityType.EDiscordActivityTypeTypeConverter()); + addTypeConverter(EDiscordActivityActionType.class, new EDiscordActivityActionType.EDiscordActivityActionTypeTypeConverter()); + addTypeConverter(EDiscordActivityJoinRequestReply.class, new EDiscordActivityJoinRequestReply.EDiscordActivityJoinRequestReplyTypeConverter()); + addTypeConverter(EDiscordStatus.class, new EDiscordStatus.EDiscordStatusTypeConverter()); + addTypeConverter(EDiscordRelationshipType.class, new EDiscordRelationshipType.EDiscordRelationshipTypeTypeConverter()); + addTypeConverter(EDiscordLobbyType.class, new EDiscordLobbyType.EDiscordLobbyTypeTypeConverter()); + addTypeConverter(EDiscordLobbySearchComparison.class, new EDiscordLobbySearchComparison.EDiscordLobbySearchComparisonTypeConverter()); + addTypeConverter(EDiscordLobbySearchCast.class, new EDiscordLobbySearchCast.EDiscordLobbySearchCastTypeConverter()); + addTypeConverter(EDiscordLobbySearchDistance.class, new EDiscordLobbySearchDistance.EDiscordLobbySearchDistanceTypeConverter()); + addTypeConverter(EDiscordEntitlementType.class, new EDiscordEntitlementType.EDiscordEntitlementTypeTypeConverter()); + addTypeConverter(EDiscordSkuType.class, new EDiscordSkuType.EDiscordSkuTypeTypeConverter()); + addTypeConverter(EDiscordInputModeType.class, new EDiscordInputModeType.EDiscordInputModeTypeTypeConverter()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/NativeGameSDK.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/NativeGameSDK.java new file mode 100644 index 00000000..b11f141c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/NativeGameSDK.java @@ -0,0 +1,50 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna; + +import com.sun.jna.Callback; +import com.sun.jna.Library; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.PointerByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordCreateParams; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordVersion; + +public interface NativeGameSDK extends Library { + + public static final int DISCORD_VERSION = 2; + public static final int DISCORD_APPLICATION_MANAGER_VERSION = 1; + public static final int DISCORD_USER_MANAGER_VERSION = 1; + public static final int DISCORD_IMAGE_MANAGER_VERSION = 1; + public static final int DISCORD_ACTIVITY_MANAGER_VERSION = 1; + public static final int DISCORD_RELATIONSHIP_MANAGER_VERSION = 1; + public static final int DISCORD_LOBBY_MANAGER_VERSION = 1; + public static final int DISCORD_NETWORK_MANAGER_VERSION = 1; + public static final int DISCORD_OVERLAY_MANAGER_VERSION = 1; + public static final int DISCORD_STORAGE_MANAGER_VERSION = 1; + public static final int DISCORD_STORE_MANAGER_VERSION = 1; + public static final int DISCORD_VOICE_MANAGER_VERSION = 1; + public static final int DISCORD_ACHIEVEMENT_MANAGER_VERSION = 1; + + EDiscordResult DiscordCreate(DiscordVersion version, DiscordCreateParams params, PointerByReference result); // result is double pointer of IDiscordCore + + interface DiscordCallback extends Callback { + void callback(Pointer callbackData, EDiscordResult result); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivity.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivity.java new file mode 100644 index 00000000..3bd0c612 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivity.java @@ -0,0 +1,50 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordActivityType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.Int64; + +import java.util.Arrays; +import java.util.List; + + +public class DiscordActivity extends DiscordStruct { + public EDiscordActivityType activityType = EDiscordActivityType.DiscordActivityType_Playing; + public Int64 applicationId = new Int64(); + public byte[] name = new byte[128]; + public byte[] state = new byte[128]; + public byte[] details = new byte[128]; + public DiscordActivityTimestamps timestamps; + public DiscordActivityAssets assets; + public DiscordActivityParty party; + public DiscordActivitySecrets secrets; + public boolean instance; + public DiscordActivity() {super();} public DiscordActivity(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordActivity implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordActivity implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("activityType", "applicationId", "name", "state", "details", "timestamps", "assets", "party", "secrets", "instance"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityAssets.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityAssets.java new file mode 100644 index 00000000..fe9bf1ca --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityAssets.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; + +import java.util.Arrays; +import java.util.List; + + +public class DiscordActivityAssets extends DiscordStruct{ + public byte[] large_image = new byte[128]; + public byte[] large_text = new byte[128]; + public byte[] small_image = new byte[128]; + public byte[] small_text = new byte[128]; + public DiscordActivityAssets() {super();}public DiscordActivityAssets(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordActivityAssets implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordActivityAssets implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("large_image", "large_text", "small_image", "small_text"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityParty.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityParty.java new file mode 100644 index 00000000..ee0730af --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityParty.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; + +import java.util.Arrays; +import java.util.List; + + +public class DiscordActivityParty extends DiscordStruct { + public byte[] id = new byte[128]; + public DiscordPartySize discordActivityParty; + public DiscordActivityParty() {super();} public DiscordActivityParty(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordActivityParty implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordActivityParty implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("id", "discordActivityParty"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivitySecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivitySecrets.java new file mode 100644 index 00000000..6a43412c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivitySecrets.java @@ -0,0 +1,41 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; + +import java.util.Arrays; +import java.util.List; + + +public class DiscordActivitySecrets extends DiscordStruct { + public byte[] match = new byte[128]; + public byte[] join = new byte[128]; + public byte[] spectate = new byte[128]; + public DiscordActivitySecrets() {super();} public DiscordActivitySecrets(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordActivitySecrets implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordActivitySecrets implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("match", "join", "spectate"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityTimestamps.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityTimestamps.java new file mode 100644 index 00000000..8a8d06b8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordActivityTimestamps.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordTimestamp; + +import java.util.Arrays; +import java.util.List; + +public class DiscordActivityTimestamps extends DiscordStruct { + public DiscordTimestamp start = new DiscordTimestamp(); + public DiscordTimestamp end = new DiscordTimestamp(); + public DiscordActivityTimestamps() {super();} public DiscordActivityTimestamps(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordActivityTimestamps implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordActivityTimestamps implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("start", "end"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordCreateParams.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordCreateParams.java new file mode 100644 index 00000000..9c7e15a9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordCreateParams.java @@ -0,0 +1,72 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct.*; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordClientID; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordVersion; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt64; + +import java.util.Arrays; +import java.util.List; + +public class DiscordCreateParams extends DiscordStruct { public DiscordCreateParams() {super();} public DiscordCreateParams(Pointer pointer) {super(pointer);} + public DiscordClientID client_id = new DiscordClientID(); + public UInt64 flags = new UInt64(); + public Pointer events; // void* + public Pointer event_data; // void* + public Pointer application_events; + public DiscordVersion application_version = new DiscordVersion(NativeGameSDK.DISCORD_APPLICATION_MANAGER_VERSION); + public IDiscordUserEvents.ByReference user_events; + public DiscordVersion user_version= new DiscordVersion(NativeGameSDK.DISCORD_USER_MANAGER_VERSION); + public Pointer image_events;// void* + public DiscordVersion image_version= new DiscordVersion(NativeGameSDK.DISCORD_IMAGE_MANAGER_VERSION); + public IDiscordActivityEvents.ByReference activity_events; + public DiscordVersion activity_version= new DiscordVersion(NativeGameSDK.DISCORD_ACTIVITY_MANAGER_VERSION); + public IDiscordRelationshipEvents.ByReference relationship_events; + public DiscordVersion relationship_version= new DiscordVersion(NativeGameSDK.DISCORD_RELATIONSHIP_MANAGER_VERSION); + public IDiscordLobbyEvents.ByReference lobby_events; + public DiscordVersion lobby_version= new DiscordVersion(NativeGameSDK.DISCORD_LOBBY_MANAGER_VERSION); + public IDiscordNetworkEvents.ByReference network_events; + public DiscordVersion network_version= new DiscordVersion(NativeGameSDK.DISCORD_NETWORK_MANAGER_VERSION); + public IDiscordOverlayEvents.ByReference overlay_events; + public DiscordVersion overlay_version= new DiscordVersion(NativeGameSDK.DISCORD_OVERLAY_MANAGER_VERSION); + public Pointer storage_events;// void* + public DiscordVersion storage_version= new DiscordVersion(NativeGameSDK.DISCORD_STORAGE_MANAGER_VERSION); + public IDiscordStoreEvents.ByReference store_events; + public DiscordVersion store_version= new DiscordVersion(NativeGameSDK.DISCORD_STORE_MANAGER_VERSION); + public IDiscordVoiceEvents.ByReference voice_events; + public DiscordVersion voice_version= new DiscordVersion(NativeGameSDK.DISCORD_VOICE_MANAGER_VERSION); + public IDiscordAchievementEvents.ByReference achievement_events; + public DiscordVersion achievement_version= new DiscordVersion(NativeGameSDK.DISCORD_ACHIEVEMENT_MANAGER_VERSION); + + public static class ByReference extends DiscordCreateParams implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordCreateParams implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("client_id", "flags", "events", "event_data", "application_events", "application_version", "user_events", + "user_version", "image_events", "image_version", "activity_events", "activity_version", "lobby_events", "lobby_version", + "network_events", "network_version", "overlay_events", "overlay_version", "storage_events", "storage_version", "store_events", + "store_version", "voice_events", "voice_version", "achievement_events", "achievement_version"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordEntitlement.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordEntitlement.java new file mode 100644 index 00000000..85ef593b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordEntitlement.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordEntitlementType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import java.util.Arrays; +import java.util.List; + +public class DiscordEntitlement extends DiscordStruct { + public DiscordSnowflake id = new DiscordSnowflake(); + public EDiscordEntitlementType type = EDiscordEntitlementType.DiscordEntitlementType_Purchase; + public DiscordSnowflake sku_id = new DiscordSnowflake(); + public DiscordEntitlement() {super();} public DiscordEntitlement(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordEntitlement implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordEntitlement implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("id", "type", "sku_id"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordFileStat.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordFileStat.java new file mode 100644 index 00000000..40f72b6c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordFileStat.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt64; + +import java.util.Arrays; +import java.util.List; + +public class DiscordFileStat extends DiscordStruct { + public byte[] filename = new byte[260]; + public UInt64 size = new UInt64(); + public UInt64 last_modified = new UInt64(); + public DiscordFileStat() {super();} public DiscordFileStat(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordFileStat implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordFileStat implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("filename", "size", "last_modified"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordImageDimensions.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordImageDimensions.java new file mode 100644 index 00000000..c6a55c42 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordImageDimensions.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; + +import java.util.Arrays; +import java.util.List; + +public class DiscordImageDimensions extends DiscordStruct { + public UInt32 width = new UInt32(); + public UInt32 height = new UInt32(); + public DiscordImageDimensions() {super();} public DiscordImageDimensions(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordImageDimensions implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) { super(pointer);}} + public static class ByValue extends DiscordImageDimensions implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) { super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("width", "height"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordImageHandle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordImageHandle.java new file mode 100644 index 00000000..c52dfebc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordImageHandle.java @@ -0,0 +1,43 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordImageType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.Int64; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; + +import java.util.Arrays; +import java.util.List; + +public class DiscordImageHandle extends DiscordStruct { + public EDiscordImageType type = EDiscordImageType.DiscordImageType_User; + public Int64 id = new Int64(); + public UInt32 size = new UInt32(); + public DiscordImageHandle() {super();} public DiscordImageHandle(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordImageHandle implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordImageHandle implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("type", "id", "size"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordInputMode.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordInputMode.java new file mode 100644 index 00000000..d0b8589b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordInputMode.java @@ -0,0 +1,41 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordInputModeType; + +import java.util.Arrays; +import java.util.List; + + +public class DiscordInputMode extends DiscordStruct { + public EDiscordInputModeType type = EDiscordInputModeType.DiscordInputModeType_PushToTalk; + public byte[] shortcut = new byte[256]; + public DiscordInputMode() {super();} public DiscordInputMode(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordInputMode implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordInputMode implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("type", "shortcut"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordLobby.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordLobby.java new file mode 100644 index 00000000..c89dc1cf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordLobby.java @@ -0,0 +1,47 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordLobbyType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; + +import java.util.Arrays; +import java.util.List; + +public class DiscordLobby extends DiscordStruct { + public DiscordSnowflake id = new DiscordSnowflake(); + public EDiscordLobbyType type = EDiscordLobbyType.DiscordLobbyType_Private; + public DiscordSnowflake owner_id = new DiscordSnowflake(); + public byte[] secret = new byte[128]; + public UInt32 capacity = new UInt32(); + public boolean locked; + public DiscordLobby() {super();} public DiscordLobby(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordLobby implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordLobby implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("id", "type", "owner_id", "secret", "capacity", "locked"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordOAuth2Token.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordOAuth2Token.java new file mode 100644 index 00000000..937b23de --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordOAuth2Token.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordTimestamp; + +import java.util.Arrays; +import java.util.List; + + +public class DiscordOAuth2Token extends DiscordStruct { + public byte[] access_token = new byte[128]; + public byte[] scopes = new byte[1024]; + public DiscordTimestamp expires = new DiscordTimestamp(); + public DiscordOAuth2Token() {super();} public DiscordOAuth2Token(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordOAuth2Token implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordOAuth2Token implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("access_token", "scopes", "expires"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordPartySize.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordPartySize.java new file mode 100644 index 00000000..522efeaa --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordPartySize.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.Int32; + +import java.util.Arrays; +import java.util.List; + +public class DiscordPartySize extends DiscordStruct{ + public Int32 current_size = new Int32(); + public Int32 max_size = new Int32(); + public DiscordPartySize() {super();} public DiscordPartySize(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordPartySize implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordPartySize implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("current_size", "max_size"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordPresence.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordPresence.java new file mode 100644 index 00000000..b5fc0f0e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordPresence.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordStatus; + +import java.util.Arrays; +import java.util.List; + +public class DiscordPresence extends DiscordStruct { + public EDiscordStatus status = EDiscordStatus.DiscordStatus_Offline; + public DiscordActivity activity; + public DiscordPresence() {super();} public DiscordPresence(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordPresence implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordPresence implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("status", "activity"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordRelationship.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordRelationship.java new file mode 100644 index 00000000..4115e684 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordRelationship.java @@ -0,0 +1,41 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordRelationshipType; + +import java.util.Arrays; +import java.util.List; + +public class DiscordRelationship extends DiscordStruct { + public EDiscordRelationshipType type = EDiscordRelationshipType.DiscordRelationshipType_None; + public DiscordUser user; + public DiscordPresence presence; + public DiscordRelationship() {super();} public DiscordRelationship(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordRelationship implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordRelationship implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("type", "user", "presence"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordSku.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordSku.java new file mode 100644 index 00000000..bfd90e22 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordSku.java @@ -0,0 +1,44 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordSkuType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import java.util.Arrays; +import java.util.List; + + +public class DiscordSku extends DiscordStruct { + public DiscordSnowflake id = new DiscordSnowflake(); + public EDiscordSkuType type = EDiscordSkuType.DiscordSkuType_Application; + public byte[] name = new byte[256]; + public DiscordSkuPrice discordSkuPrice; + public DiscordSku() {super();} public DiscordSku(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordSku implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordSku implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("id", "type", "name", "discordSkuPrice"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordSkuPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordSkuPrice.java new file mode 100644 index 00000000..c69ca97a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordSkuPrice.java @@ -0,0 +1,41 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; + +import java.util.Arrays; +import java.util.List; + +public class DiscordSkuPrice extends DiscordStruct { + public UInt32 amount = new UInt32(); + public byte[] currency = new byte[16]; + public DiscordSkuPrice() {super();} public DiscordSkuPrice(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordSkuPrice implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordSkuPrice implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("amount", "currency"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordStruct.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordStruct.java new file mode 100644 index 00000000..12292692 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordStruct.java @@ -0,0 +1,35 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Library; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.GameSDKTypeMapper; + +import java.util.Collections; +import java.util.Map; + +public abstract class DiscordStruct extends Structure { + public static final Map OPTIONS = Collections.singletonMap(Library.OPTION_TYPE_MAPPER, GameSDKTypeMapper.INSTANCE); + protected DiscordStruct() { + super(GameSDKTypeMapper.INSTANCE); + } + protected DiscordStruct(Pointer p) {super(p); read();} +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordUser.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordUser.java new file mode 100644 index 00000000..3db714dc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordUser.java @@ -0,0 +1,43 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import java.util.Arrays; +import java.util.List; + +public class DiscordUser extends DiscordStruct { + public DiscordSnowflake id = new DiscordSnowflake(); + public byte[] username = new byte[256]; + public byte[] discriminator = new byte[8]; + public byte[] avatar = new byte[128]; + public boolean bot; + public DiscordUser() {super();} public DiscordUser(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordUser implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordUser implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("id", "username", "discriminator", "avatar", "bot"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordUserAchievement.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordUserAchievement.java new file mode 100644 index 00000000..db13ab77 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/datastruct/DiscordUserAchievement.java @@ -0,0 +1,44 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; + +import java.util.Arrays; +import java.util.List; + +public class DiscordUserAchievement extends DiscordStruct { + public DiscordSnowflake user_id = new DiscordSnowflake(); + public DiscordSnowflake achievement_id = new DiscordSnowflake(); + public UInt32 percent_complete = new UInt32(); + public byte[] unlocked_at = new byte[64]; + public DiscordUserAchievement() {super();} public DiscordUserAchievement(Pointer pointer) {super(pointer);} + + public static class ByReference extends DiscordUserAchievement implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends DiscordUserAchievement implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override + protected List getFieldOrder() { + return Arrays.asList("user_id", "achievement_id", "percent_complete", "unlocked_at"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityActionType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityActionType.java new file mode 100644 index 00000000..9004c339 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityActionType.java @@ -0,0 +1,67 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordActivityActionType { + DiscordActivityActionType_Join(1), + DiscordActivityActionType_Spectate(2); + + @Getter + private final int value; + private EDiscordActivityActionType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordActivityActionType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordActivityActionType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordActivityActionTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordActivityActionType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordActivityActionType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityJoinRequestReply.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityJoinRequestReply.java new file mode 100644 index 00000000..43f0c0ef --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityJoinRequestReply.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordActivityJoinRequestReply { + DiscordActivityJoinRequestReply_No(0), + DiscordActivityJoinRequestReply_Yes(1), + DiscordActivityJoinRequestReply_Ignore(2); + + @Getter + private final int value; + private EDiscordActivityJoinRequestReply(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordActivityJoinRequestReply value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordActivityJoinRequestReply fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordActivityJoinRequestReplyTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordActivityJoinRequestReply.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordActivityJoinRequestReply)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityType.java new file mode 100644 index 00000000..7ed2ec54 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordActivityType.java @@ -0,0 +1,69 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordActivityType { + DiscordActivityType_Playing(0), + DiscordActivityType_Streaming(1), + DiscordActivityType_Listening(2), + DiscordActivityType_Watching(3); + + @Getter + private final int value; + private EDiscordActivityType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordActivityType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordActivityType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordActivityTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordActivityType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordActivityType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordCreateFlags.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordCreateFlags.java new file mode 100644 index 00000000..60606213 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordCreateFlags.java @@ -0,0 +1,67 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordCreateFlags { + DiscordCreateFlags_Default(0), + DiscordCreateFlags_NoRequireDiscord(1); + + @Getter + private final int value; + private EDiscordCreateFlags(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordCreateFlags value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordCreateFlags fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordCreateFlagsTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordCreateFlags.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordCreateFlags)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordEntitlementType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordEntitlementType.java new file mode 100644 index 00000000..85150f0a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordEntitlementType.java @@ -0,0 +1,72 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordEntitlementType { + DiscordEntitlementType_Purchase(1), + DiscordEntitlementType_PremiumSubscription(2), + DiscordEntitlementType_DeveloperGift(3), + DiscordEntitlementType_TestModePurchase(4), + DiscordEntitlementType_FreePurchase(5), + DiscordEntitlementType_UserGift(6), + DiscordEntitlementType_PremiumPurchase(7); + + @Getter + private final int value; + private EDiscordEntitlementType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordEntitlementType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordEntitlementType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordEntitlementTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordEntitlementType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordEntitlementType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordImageType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordImageType.java new file mode 100644 index 00000000..f516e1a9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordImageType.java @@ -0,0 +1,66 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordImageType { + DiscordImageType_User(0); + + @Getter + private final int value; + private EDiscordImageType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordImageType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordImageType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordImageTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordImageType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + + if (value == null) return 0;return ((EDiscordImageType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordInputModeType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordInputModeType.java new file mode 100644 index 00000000..aeba1c22 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordInputModeType.java @@ -0,0 +1,67 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordInputModeType { + DiscordInputModeType_VoiceActivity(0), + DiscordInputModeType_PushToTalk(1); + + @Getter + private final int value; + private EDiscordInputModeType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordInputModeType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordInputModeType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordInputModeTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordInputModeType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordInputModeType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchCast.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchCast.java new file mode 100644 index 00000000..d2c78f39 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchCast.java @@ -0,0 +1,67 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordLobbySearchCast { + DiscordLobbySearchCast_String(1), + DiscordLobbySearchCast_Number(2); + + @Getter + private final int value; + private EDiscordLobbySearchCast(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordLobbySearchCast value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordLobbySearchCast fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordLobbySearchCastTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordLobbySearchCast.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordLobbySearchCast)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchComparison.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchComparison.java new file mode 100644 index 00000000..9a8819d4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchComparison.java @@ -0,0 +1,71 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordLobbySearchComparison { + DiscordLobbySearchComparison_LessThanOrEqual(-2), + DiscordLobbySearchComparison_LessThan(-1), + DiscordLobbySearchComparison_Equal(0), + DiscordLobbySearchComparison_GreaterThan(1), + DiscordLobbySearchComparison_GreaterThanOrEqual(2), + DiscordLobbySearchComparison_NotEqual(3); + + @Getter + private final int value; + private EDiscordLobbySearchComparison(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordLobbySearchComparison value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordLobbySearchComparison fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordLobbySearchComparisonTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordLobbySearchComparison.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordLobbySearchComparison)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchDistance.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchDistance.java new file mode 100644 index 00000000..5e4927ee --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbySearchDistance.java @@ -0,0 +1,69 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordLobbySearchDistance { + DiscordLobbySearchDistance_Local(0), + DiscordLobbySearchDistance_Default(1), + DiscordLobbySearchDistance_Extended(2), + DiscordLobbySearchDistance_Global(3); + + @Getter + private final int value; + private EDiscordLobbySearchDistance(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordLobbySearchDistance value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordLobbySearchDistance fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordLobbySearchDistanceTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordLobbySearchDistance.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordLobbySearchDistance)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbyType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbyType.java new file mode 100644 index 00000000..62b7c154 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLobbyType.java @@ -0,0 +1,67 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordLobbyType { + DiscordLobbyType_Private(1), + DiscordLobbyType_Public(2); + + @Getter + private final int value; + private EDiscordLobbyType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordLobbyType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordLobbyType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordLobbyTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordLobbyType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + + if (value == null) return 0;return ((EDiscordLobbyType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLogLevel.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLogLevel.java new file mode 100644 index 00000000..8487a0e6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordLogLevel.java @@ -0,0 +1,69 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordLogLevel { + DiscordLogLevel_Error(1), + DiscordLogLevel_Warn(2), + DiscordLogLevel_Info(3), + DiscordLogLevel_Debug(4); + + @Getter + private final int value; + private EDiscordLogLevel(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordLogLevel value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordLogLevel fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordLogLevelTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordLogLevel.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + + if (value == null) return 0;return ((EDiscordLogLevel)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordPremiumType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordPremiumType.java new file mode 100644 index 00000000..139264b1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordPremiumType.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordPremiumType { + DiscordPremiumType_None(0), + DiscordPremiumType_Tier1(1), + DiscordPremiumType_Tier2(2); + + @Getter + private final int value; + private EDiscordPremiumType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordPremiumType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordPremiumType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordPremiumTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordPremiumType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordPremiumType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordRelationshipType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordRelationshipType.java new file mode 100644 index 00000000..ddc5cadb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordRelationshipType.java @@ -0,0 +1,71 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordRelationshipType { + DiscordRelationshipType_None(0), + DiscordRelationshipType_Friend(1), + DiscordRelationshipType_Blocked(2), + DiscordRelationshipType_PendingIncoming(3), + DiscordRelationshipType_PendingOutgoing(4), + DiscordRelationshipType_Implicit(5); + + @Getter + private final int value; + private EDiscordRelationshipType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordRelationshipType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordRelationshipType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordRelationshipTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordRelationshipType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordRelationshipType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordResult.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordResult.java new file mode 100644 index 00000000..9447fc58 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordResult.java @@ -0,0 +1,109 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordResult { + DiscordResult_Ok(0), + DiscordResult_ServiceUnavailable(1), + DiscordResult_InvalidVersion(2), + DiscordResult_LockFailed(3), + DiscordResult_InternalError(4), + DiscordResult_InvalidPayload(5), + DiscordResult_InvalidCommand(6), + DiscordResult_InvalidPermissions(7), + DiscordResult_NotFetched(8), + DiscordResult_NotFound(9), + DiscordResult_Conflict(10), + DiscordResult_InvalidSecret(11), + DiscordResult_InvalidJoinSecret(12), + DiscordResult_NoEligibleActivity(13), + DiscordResult_InvalidInvite(14), + DiscordResult_NotAuthenticated(15), + DiscordResult_InvalidAccessToken(16), + DiscordResult_ApplicationMismatch(17), + DiscordResult_InvalidDataUrl(18), + DiscordResult_InvalidBase64(19), + DiscordResult_NotFiltered(20), + DiscordResult_LobbyFull(21), + DiscordResult_InvalidLobbySecret(22), + DiscordResult_InvalidFilename(23), + DiscordResult_InvalidFileSize(24), + DiscordResult_InvalidEntitlement(25), + DiscordResult_NotInstalled(26), + DiscordResult_NotRunning(27), + DiscordResult_InsufficientBuffer(28), + DiscordResult_PurchaseCanceled(29), + DiscordResult_InvalidGuild(30), + DiscordResult_InvalidEvent(31), + DiscordResult_InvalidChannel(32), + DiscordResult_InvalidOrigin(33), + DiscordResult_RateLimited(34), + DiscordResult_OAuth2Error(35), + DiscordResult_SelectChannelTimeout(36), + DiscordResult_GetGuildTimeout(37), + DiscordResult_SelectVoiceForceRequired(38), + DiscordResult_CaptureShortcutAlreadyListening(39), + DiscordResult_UnauthorizedForAchievement(40), + DiscordResult_InvalidGiftCode(41), + DiscordResult_PurchaseError(42), + DiscordResult_TransactionAborted(43); + + @Getter + private final int value; + private EDiscordResult(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordResult value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordResult fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordResultTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordResult.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordResult)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordSkuType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordSkuType.java new file mode 100644 index 00000000..69442f2d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordSkuType.java @@ -0,0 +1,69 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordSkuType { + DiscordSkuType_Application(1), + DiscordSkuType_DLC(2), + DiscordSkuType_Consumable(3), + DiscordSkuType_Bundle(4); + + @Getter + private final int value; + private EDiscordSkuType(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordSkuType value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordSkuType fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordSkuTypeTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordSkuType.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + + if (value == null) return 0;return ((EDiscordSkuType)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordStatus.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordStatus.java new file mode 100644 index 00000000..0ef1892e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordStatus.java @@ -0,0 +1,69 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordStatus { + DiscordStatus_Offline(0), + DiscordStatus_Online(1), + DiscordStatus_Idle(2), + DiscordStatus_DoNotDisturb(3); + + @Getter + private final int value; + private EDiscordStatus(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordStatus value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordStatus fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordStatusTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordStatus.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + + if (value == null) return 0;return ((EDiscordStatus)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordUserFlag.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordUserFlag.java new file mode 100644 index 00000000..1ba8f40f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/enumuration/EDiscordUserFlag.java @@ -0,0 +1,70 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.ToNativeContext; +import com.sun.jna.TypeConverter; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +public enum EDiscordUserFlag { + DiscordUserFlag_Partner(2), + DiscordUserFlag_HypeSquadEvents(4), + DiscordUserFlag_HypeSquadHouse1(64), + DiscordUserFlag_HypeSquadHouse2(128), + DiscordUserFlag_HypeSquadHouse3(256); + + @Getter + private final int value; + private EDiscordUserFlag(int value) { + this.value = value; + } + + private static final Map valueMap = new HashMap<>(); + static { + for (EDiscordUserFlag value : values()) { + valueMap.put(value.value, value); + } + } + + public static EDiscordUserFlag fromValue(int value) { + return valueMap.get(value); + } + + public static class EDiscordUserFlagTypeConverter implements TypeConverter { + @Override + public Object fromNative(Object nativeValue, FromNativeContext context) { + return EDiscordUserFlag.fromValue((Integer)nativeValue); + } + + @Override + public Object toNative(Object value, ToNativeContext context) { + if (value == null) return 0; + return ((EDiscordUserFlag)value).getValue(); + } + + @Override + public Class nativeType() { + return Integer.class; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/GameSDKCallback.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/GameSDKCallback.java new file mode 100644 index 00000000..e997e699 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/GameSDKCallback.java @@ -0,0 +1,30 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Callback; +import com.sun.jna.Library; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.GameSDKTypeMapper; + +import java.util.Collections; +import java.util.Map; + +public interface GameSDKCallback extends Callback { + public static final Map OPTIONS = Collections.singletonMap(Library.OPTION_TYPE_MAPPER, GameSDKTypeMapper.INSTANCE); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordAchievementEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordAchievementEvents.java new file mode 100644 index 00000000..a75e0186 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordAchievementEvents.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordUserAchievement; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordAchievementEvents extends DiscordStruct { public IDiscordAchievementEvents() {super();} public IDiscordAchievementEvents(Pointer pointer) {super(pointer);} + public interface OnUserAchievementUpdateCallback extends GameSDKCallback { void onUserAchievementUpdate(Pointer eventData, DiscordUserAchievement userAchievement); } + public OnUserAchievementUpdateCallback OnUserAchievementUpdate; + + + + public static class ByReference extends IDiscordAchievementEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordAchievementEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("OnUserAchievementUpdate"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordAchievementManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordAchievementManager.java new file mode 100644 index 00000000..40d37327 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordAchievementManager.java @@ -0,0 +1,57 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.Int32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt8; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordUserAchievement; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordAchievementManager extends DiscordStruct { public IDiscordAchievementManager() {super();} public IDiscordAchievementManager(Pointer pointer) {super(pointer);} + public interface SetUserAchievementCallback extends GameSDKCallback { void setUserAchievement(IDiscordAchievementManager manager, DiscordSnowflake achievementId, UInt8 percentComplete, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public SetUserAchievementCallback SetUserAchievement; + + public interface FetchUserAchievementsCallback extends GameSDKCallback { void fetchUserAchievements(IDiscordAchievementManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public FetchUserAchievementsCallback FetchUserAchievements; + + public interface CountUserAchievementsCallback extends GameSDKCallback { void countUserAchievements(IDiscordAchievementManager manager, IntByReference count); } + public CountUserAchievementsCallback CountUserAchievements; + + public interface GetUserAchievementCallback extends GameSDKCallback { EDiscordResult getUserAchievement(IDiscordAchievementManager manager, DiscordSnowflake userAchievementId, DiscordUserAchievement userAchievement); } + public GetUserAchievementCallback GetUserAchievement; + + public interface GetUserAchievementAtCallback extends GameSDKCallback { EDiscordResult getUserAchievementAt(IDiscordAchievementManager manager, Int32 index, DiscordUserAchievement userAchievement); } + public GetUserAchievementAtCallback GetUserAchievementAt; + + + + public static class ByReference extends IDiscordAchievementManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordAchievementManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("SetUserAchievement", "FetchUserAchievements", "CountUserAchievements", "GetUserAchievement", "GetUserAchievementAt"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordActivityEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordActivityEvents.java new file mode 100644 index 00000000..d340e544 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordActivityEvents.java @@ -0,0 +1,50 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordActivityActionType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordActivity; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordUser; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordActivityEvents extends DiscordStruct { public IDiscordActivityEvents() {super();} public IDiscordActivityEvents(Pointer pointer) {super(pointer);} + public interface OnActivityJoinCallback extends GameSDKCallback { void onActivityJoin(Pointer eventData, String secret); } + public OnActivityJoinCallback OnActivityJoin; + + public interface OnActivitySpectateCallback extends GameSDKCallback { void onActivitySpectate(Pointer eventData, String secret); } + public OnActivitySpectateCallback OnActivitySpectate; + + public interface OnActivityJoinRequestCallback extends GameSDKCallback { void onActivityJoinRequest(Pointer eventData, DiscordUser user); } + public OnActivityJoinRequestCallback OnActivityJoinRequest; + + public interface OnActivityInviteCallback extends GameSDKCallback { void onActivityInvite(Pointer eventData, EDiscordActivityActionType type, DiscordUser user, DiscordActivity activity); } + public OnActivityInviteCallback OnActivityInvite; + + + + public static class ByReference extends IDiscordActivityEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordActivityEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("OnActivityJoin", "OnActivitySpectate", "OnActivityJoinRequest", "OnActivityInvite"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordActivityManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordActivityManager.java new file mode 100644 index 00000000..2cab2538 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordActivityManager.java @@ -0,0 +1,63 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordActivityActionType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordActivity; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordActivityJoinRequestReply; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordActivityManager extends DiscordStruct { public IDiscordActivityManager() {super();} public IDiscordActivityManager(Pointer pointer) {super(pointer);} + public interface RegisterCommandCallback extends GameSDKCallback { EDiscordResult registerCommand(IDiscordActivityManager manager, String command); } + public RegisterCommandCallback RegisterCommand; + + public interface RegisterSteamCallback extends GameSDKCallback { EDiscordResult registerSteam(IDiscordActivityManager manager, UInt32 steamId); } + public RegisterSteamCallback RegisterSteam; + + public interface UpdateActivityCallback extends GameSDKCallback { void updateActivity(IDiscordActivityManager manager, DiscordActivity activity, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public UpdateActivityCallback UpdateActivity; + + public interface ClearActivityCallback extends GameSDKCallback { void clearActivity(IDiscordActivityManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public ClearActivityCallback ClearActivity; + + public interface SendRequestReplyCallback extends GameSDKCallback { void sendRequestReply(IDiscordActivityManager manager, DiscordSnowflake userId, EDiscordActivityJoinRequestReply reply, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public SendRequestReplyCallback SendRequestReply; + + public interface SendInviteCallback extends GameSDKCallback { void sendInvite(IDiscordActivityManager manager, DiscordSnowflake userId, EDiscordActivityActionType type, String content, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public SendInviteCallback SendInvite; + + public interface AcceptInviteCallback extends GameSDKCallback { void acceptInvite(IDiscordActivityManager manager, DiscordSnowflake userId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public AcceptInviteCallback AcceptInvite; + + + + public static class ByReference extends IDiscordActivityManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordActivityManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("RegisterCommand", "RegisterSteam", "UpdateActivity", "ClearActivity", "SendRequestReply", "SendInvite", "AcceptInvite"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordApplicationManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordApplicationManager.java new file mode 100644 index 00000000..ff07aec8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordApplicationManager.java @@ -0,0 +1,60 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordOAuth2Token; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordApplicationManager extends DiscordStruct { public IDiscordApplicationManager() {super();} public IDiscordApplicationManager(Pointer pointer) {super(pointer);} + public interface ValidateOrExitCallback extends GameSDKCallback { void validateOrExit(IDiscordApplicationManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public ValidateOrExitCallback ValidateOrExit; + + public interface GetCurrentLocaleCallback extends GameSDKCallback { void getCurrentLocale(IDiscordApplicationManager manager, Pointer locale); } // len 128 memory + public GetCurrentLocaleCallback GetCurrentLocale; + + public interface GetCurrentBranchCallback extends GameSDKCallback { void getCurrentBranch(IDiscordApplicationManager manager, Pointer branch); } // len 4096 mem + public GetCurrentBranchCallback GetCurrentBranch; + + public interface GetOauth2TokenCallback extends GameSDKCallback { void getOauth2Token(IDiscordApplicationManager manager, Pointer callbackData, GetOauth2TokenCallback_Callback callback); } + public interface GetOauth2TokenCallback_Callback extends GameSDKCallback { + void callback(Pointer callbackData, EDiscordResult result, DiscordOAuth2Token oauthToken); + } + + public GetOauth2TokenCallback GetOauth2Token; + + public interface GetTicketCallback extends GameSDKCallback { void getTicket(IDiscordApplicationManager manager, Pointer callbackData, GetTicketCallback_Callback callback); } + public interface GetTicketCallback_Callback extends GameSDKCallback { + void callback(Pointer callbackData, EDiscordResult result, String data); + } + public GetTicketCallback GetTicket; + + + + public static class ByReference extends IDiscordApplicationManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordApplicationManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("ValidateOrExit", "GetCurrentLocale", "GetCurrentBranch", "GetOauth2Token", "GetTicket"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordCore.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordCore.java new file mode 100644 index 00000000..95e4ad16 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordCore.java @@ -0,0 +1,91 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.TypeMapper; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.GameSDKTypeMapper; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordLogLevel; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordCore extends DiscordStruct { public IDiscordCore() {super();} public IDiscordCore(Pointer pointer) {super(pointer);} + + public static final TypeMapper TYPE_MAPPER = GameSDKTypeMapper.INSTANCE; + public interface DestroyCallback extends GameSDKCallback { void destroy(IDiscordCore core); } + public DestroyCallback Destroy; + + public interface RunCallbacksCallback extends GameSDKCallback { EDiscordResult runCallbacks(IDiscordCore core); } + public RunCallbacksCallback RunCallbacks; + + public interface SetLogHookCallback extends GameSDKCallback { void setLogHook(IDiscordCore core, EDiscordLogLevel minLevel, Pointer hookData, LogHook hook); } + public interface LogHook extends GameSDKCallback { + void hook(Pointer hookData, EDiscordLogLevel level, String message); + } + public SetLogHookCallback SetLogHook; + + public interface GetApplicationManagerCallback extends GameSDKCallback { IDiscordApplicationManager getApplicationManager(IDiscordCore core); } + public GetApplicationManagerCallback GetApplicationManager; + + public interface GetUserManagerCallback extends GameSDKCallback { IDiscordUserManager getUserManager(IDiscordCore core); } + public GetUserManagerCallback GetUserManager; + + public interface GetImageManagerCallback extends GameSDKCallback { IDiscordImageManager getImageManager(IDiscordCore core); } + public GetImageManagerCallback GetImageManager; + + public interface GetActivityManagerCallback extends GameSDKCallback { IDiscordActivityManager getActivityManager(IDiscordCore core); } + public GetActivityManagerCallback GetActivityManager; + + public interface GetRelationshipManagerCallback extends GameSDKCallback { IDiscordRelationshipManager getRelationshipManager(IDiscordCore core); } + public GetRelationshipManagerCallback GetRelationshipManager; + + public interface GetLobbyManagerCallback extends GameSDKCallback { IDiscordLobbyManager getLobbyManager(IDiscordCore core); } + public GetLobbyManagerCallback GetLobbyManager; + + public interface GetNetworkManagerCallback extends GameSDKCallback { IDiscordNetworkManager getNetworkManager(IDiscordCore core); } + public GetNetworkManagerCallback GetNetworkManager; + + public interface GetOverlayManagerCallback extends GameSDKCallback { IDiscordOverlayManager getOverlayManager(IDiscordCore core); } + public GetOverlayManagerCallback GetOverlayManager; + + public interface GetStorageManagerCallback extends GameSDKCallback { IDiscordStorageManager getStorageManager(IDiscordCore core); } + public GetStorageManagerCallback GetStorageManager; + + public interface GetStoreManagerCallback extends GameSDKCallback { IDiscordStoreManager getStoreManager(IDiscordCore core); } + public GetStoreManagerCallback GetStoreManager; + + public interface GetVoiceManagerCallback extends GameSDKCallback { IDiscordVoiceManager getVoiceManager(IDiscordCore core); } + public GetVoiceManagerCallback GetVoiceManager; + + public interface GetAchievementManagerCallback extends GameSDKCallback { IDiscordAchievementManager getAchievementManager(IDiscordCore core); } + public GetAchievementManagerCallback GetAchievementManager; + + + + public static class ByReference extends IDiscordCore implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);} + } + public static class ByValue extends IDiscordCore implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);} + } + + @Override protected List getFieldOrder() { return Arrays.asList("Destroy", "RunCallbacks", "SetLogHook", "GetApplicationManager", "GetUserManager", "GetImageManager", "GetActivityManager", "GetRelationshipManager", "GetLobbyManager", "GetNetworkManager", "GetOverlayManager", "GetStorageManager", "GetStoreManager", "GetVoiceManager", "GetAchievementManager"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordImageManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordImageManager.java new file mode 100644 index 00000000..208f6cec --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordImageManager.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordImageDimensions; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordImageHandle; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.List; + +public class IDiscordImageManager extends DiscordStruct { public IDiscordImageManager() {super();} public IDiscordImageManager(Pointer pointer) {super(pointer);} + public interface FetchCallback_Callback extends GameSDKCallback { + void callback(Pointer callbackData, EDiscordResult result, DiscordImageHandle.ByValue handleResult); + } + public interface FetchCallback extends GameSDKCallback { void fetch(IDiscordImageManager manager, DiscordImageHandle.ByValue handle, boolean refresh, Pointer callbackData, FetchCallback_Callback callback); } + public FetchCallback Fetch; + + public interface GetDimensionsCallback extends GameSDKCallback { EDiscordResult getDimensions(IDiscordImageManager manager, DiscordImageHandle.ByValue handle, DiscordImageDimensions dimensions); } + public GetDimensionsCallback GetDimensions; + + public interface GetDataCallback extends GameSDKCallback { EDiscordResult getData(IDiscordImageManager manager, DiscordImageHandle.ByValue handle, ByteBuffer data, UInt32 dataLength); } + public GetDataCallback GetData; + + + + public static class ByReference extends IDiscordImageManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordImageManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("Fetch", "GetDimensions", "GetData"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyEvents.java new file mode 100644 index 00000000..72ee2293 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyEvents.java @@ -0,0 +1,64 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt8; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.Int64; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordLobbyEvents extends DiscordStruct { public IDiscordLobbyEvents() {super();} public IDiscordLobbyEvents(Pointer pointer) {super(pointer);} + public interface OnLobbyUpdateCallback extends GameSDKCallback { void onLobbyUpdate(Pointer eventData, Int64 lobbyId); } + public OnLobbyUpdateCallback OnLobbyUpdate; + + public interface OnLobbyDeleteCallback extends GameSDKCallback { void onLobbyDelete(Pointer eventData, Int64 lobbyId, UInt32 reason); } + public OnLobbyDeleteCallback OnLobbyDelete; + + public interface OnMemberConnectCallback extends GameSDKCallback { void onMemberConnect(Pointer eventData, Int64 lobbyId, Int64 userId); } + public OnMemberConnectCallback OnMemberConnect; + + public interface OnMemberUpdateCallback extends GameSDKCallback { void onMemberUpdate(Pointer eventData, Int64 lobbyId, Int64 userId); } + public OnMemberUpdateCallback OnMemberUpdate; + + public interface OnMemberDisconnectCallback extends GameSDKCallback { void onMemberDisconnect(Pointer eventData, Int64 lobbyId, Int64 userId); } + public OnMemberDisconnectCallback OnMemberDisconnect; + + public interface OnLobbyMessageCallback extends GameSDKCallback { void onLobbyMessage(Pointer eventData, Int64 lobbyId, Int64 userId, ByteByReference data, UInt32 dataLength); } + public OnLobbyMessageCallback OnLobbyMessage; + + public interface OnSpeakingCallback extends GameSDKCallback { void onSpeaking(Pointer eventData, Int64 lobbyId, Int64 userId, boolean speaking); } + public OnSpeakingCallback OnSpeaking; + + public interface OnNetworkMessageCallback extends GameSDKCallback { void onNetworkMessage(Pointer eventData, Int64 lobbyId, Int64 userId, UInt8 channelId, ByteByReference data, UInt32 dataLength); } + public OnNetworkMessageCallback OnNetworkMessage; + + + + public static class ByReference extends IDiscordLobbyEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordLobbyEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + + @Override protected List getFieldOrder() { return Arrays.asList("OnLobbyUpdate", "OnLobbyDelete", "OnMemberConnect", "OnMemberUpdate", "OnMemberDisconnect", "OnLobbyMessage", "OnSpeaking", "OnNetworkMessage"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyManager.java new file mode 100644 index 00000000..08bfba44 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyManager.java @@ -0,0 +1,148 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.IntByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordLobby; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.Int32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt8; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordUser; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordLobbyManager extends DiscordStruct { public IDiscordLobbyManager() {super();} public IDiscordLobbyManager(Pointer pointer) {super(pointer);} + public interface GetLobbyCreateTransactionCallback extends GameSDKCallback { EDiscordResult getLobbyCreateTransaction(IDiscordLobbyManager manager, IDiscordLobbyTransaction transaction); } + public GetLobbyCreateTransactionCallback GetLobbyCreateTransaction; + + public interface GetLobbyUpdateTransactionCallback extends GameSDKCallback { EDiscordResult getLobbyUpdateTransaction(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, IDiscordLobbyTransaction transaction); } + public GetLobbyUpdateTransactionCallback GetLobbyUpdateTransaction; + + public interface GetMemberUpdateTransactionCallback extends GameSDKCallback { EDiscordResult getMemberUpdateTransaction(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, IDiscordLobbyMemberTransaction transaction); } + public GetMemberUpdateTransactionCallback GetMemberUpdateTransaction; + + public interface DiscordLobbyManagerCallback extends GameSDKCallback { + void callback(Pointer callbackData, EDiscordResult result, DiscordLobby lobby); + } + + public interface CreateLobbyCallback extends GameSDKCallback { void createLobby(IDiscordLobbyManager manager, IDiscordLobbyTransaction transaction, Pointer callbackData,DiscordLobbyManagerCallback callback); } + public CreateLobbyCallback CreateLobby; + + public interface UpdateLobbyCallback extends GameSDKCallback { void updateLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, IDiscordLobbyTransaction transaction, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public UpdateLobbyCallback UpdateLobby; + + public interface DeleteLobbyCallback extends GameSDKCallback { void deleteLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public DeleteLobbyCallback DeleteLobby; + + public interface ConnectLobbyCallback extends GameSDKCallback { void connectLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer secret, Pointer callbackData, DiscordLobbyManagerCallback callback); }// secret 128 byte long str + public ConnectLobbyCallback ConnectLobby; + + public interface ConnectLobbyWithActivitySecretCallback extends GameSDKCallback { void connectLobbyWithActivitySecret(IDiscordLobbyManager manager, Pointer activitySecret, Pointer callbackData, DiscordLobbyManagerCallback callback); } // secret 128 byte long str + public ConnectLobbyWithActivitySecretCallback ConnectLobbyWithActivitySecret; + + public interface DisconnectLobbyCallback extends GameSDKCallback { void disconnectLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public DisconnectLobbyCallback DisconnectLobby; + + public interface GetLobbyCallback extends GameSDKCallback { EDiscordResult getLobby(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordLobby lobby); } + public GetLobbyCallback GetLobby; + + public interface GetLobbyActivitySecretCallback extends GameSDKCallback { EDiscordResult getLobbyActivitySecret(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer secret); } // pointer to char[128] + public GetLobbyActivitySecretCallback GetLobbyActivitySecret; + + public interface GetLobbyMetadataValueCallback extends GameSDKCallback { EDiscordResult getLobbyMetadataValue(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer key, Pointer value); } // key: char[256] value: pointer to char[4096] + public GetLobbyMetadataValueCallback GetLobbyMetadataValue; + + public interface GetLobbyMetadataKeyCallback extends GameSDKCallback { EDiscordResult getLobbyMetadataKey(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Int32 index, Pointer key); }// key: pointer to char[256] + public GetLobbyMetadataKeyCallback GetLobbyMetadataKey; + + public interface LobbyMetadataCountCallback extends GameSDKCallback { EDiscordResult lobbyMetadataCount(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, IntByReference count); } + public LobbyMetadataCountCallback LobbyMetadataCount; + + public interface MemberCountCallback extends GameSDKCallback { EDiscordResult memberCount(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, IntByReference count); } + public MemberCountCallback MemberCount; + + public interface GetMemberUserIdCallback extends GameSDKCallback { EDiscordResult getMemberUserId(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Int32 index, Pointer userId); } // userID: pointer to DiscordUserID + public GetMemberUserIdCallback GetMemberUserId; + + public interface GetMemberUserCallback extends GameSDKCallback { EDiscordResult getMemberUser(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, DiscordUser user); } + public GetMemberUserCallback GetMemberUser; + + public interface GetMemberMetadataValueCallback extends GameSDKCallback { EDiscordResult getMemberMetadataValue(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, Pointer key, Pointer value); }// key: char[256] value: pointer to char[4096] + public GetMemberMetadataValueCallback GetMemberMetadataValue; + + public interface GetMemberMetadataKeyCallback extends GameSDKCallback { EDiscordResult getMemberMetadataKey(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, Int32 index, Pointer key); }// key: pointer to char[256] + public GetMemberMetadataKeyCallback GetMemberMetadataKey; + + public interface MemberMetadataCountCallback extends GameSDKCallback { EDiscordResult memberMetadataCount(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, IntByReference count); } + public MemberMetadataCountCallback MemberMetadataCount; + + public interface UpdateMemberCallback extends GameSDKCallback { void updateMember(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, IDiscordLobbyMemberTransaction transaction, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public UpdateMemberCallback UpdateMember; + + public interface SendLobbyMessageCallback extends GameSDKCallback { void sendLobbyMessage(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, ByteByReference data, UInt32 dataLength, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public SendLobbyMessageCallback SendLobbyMessage; + + public interface GetSearchQueryCallback extends GameSDKCallback { EDiscordResult getSearchQuery(IDiscordLobbyManager manager, IDiscordLobbySearchQuery query); } + public GetSearchQueryCallback GetSearchQuery; + + public interface SearchCallback extends GameSDKCallback { void search(IDiscordLobbyManager manager, IDiscordLobbySearchQuery query, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public SearchCallback Search; + + public interface LobbyCountCallback extends GameSDKCallback { void lobbyCount(IDiscordLobbyManager manager, IntByReference count); } + public LobbyCountCallback LobbyCount; + + public interface GetLobbyIdCallback extends GameSDKCallback { EDiscordResult getLobbyId(IDiscordLobbyManager manager, Int32 index, Pointer lobbyId); } // lobbyID: Pointer to DiscordSnowflake + public GetLobbyIdCallback GetLobbyId; + + public interface ConnectVoiceCallback extends GameSDKCallback { void connectVoice(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public ConnectVoiceCallback ConnectVoice; + + public interface DisconnectVoiceCallback extends GameSDKCallback { void disconnectVoice(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public DisconnectVoiceCallback DisconnectVoice; + + public interface ConnectNetworkCallback extends GameSDKCallback { EDiscordResult connectNetwork(IDiscordLobbyManager manager, DiscordSnowflake lobbyId); } + public ConnectNetworkCallback ConnectNetwork; + + public interface DisconnectNetworkCallback extends GameSDKCallback { EDiscordResult disconnectNetwork(IDiscordLobbyManager manager, DiscordSnowflake lobbyId); } + public DisconnectNetworkCallback DisconnectNetwork; + + public interface FlushNetworkCallback extends GameSDKCallback { EDiscordResult flushNetwork(IDiscordLobbyManager manager); } + public FlushNetworkCallback FlushNetwork; + + public interface OpenNetworkChannelCallback extends GameSDKCallback { EDiscordResult openNetworkChannel(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, UInt8 channelId, boolean reliable); } + public OpenNetworkChannelCallback OpenNetworkChannel; + + public interface SendNetworkMessageCallback extends GameSDKCallback { EDiscordResult sendNetworkMessage(IDiscordLobbyManager manager, DiscordSnowflake lobbyId, DiscordSnowflake userId, UInt8 channelId, ByteByReference data, UInt32 dataLength); } + public SendNetworkMessageCallback SendNetworkMessage; + + + + public static class ByReference extends IDiscordLobbyManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordLobbyManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("GetLobbyCreateTransaction", "GetLobbyUpdateTransaction", "GetMemberUpdateTransaction", "CreateLobby", "UpdateLobby", "DeleteLobby", "ConnectLobby", "ConnectLobbyWithActivitySecret", "DisconnectLobby", "GetLobby", "GetLobbyActivitySecret", "GetLobbyMetadataValue", "GetLobbyMetadataKey", "LobbyMetadataCount", "MemberCount", "GetMemberUserId", "GetMemberUser", "GetMemberMetadataValue", "GetMemberMetadataKey", "MemberMetadataCount", "UpdateMember", "SendLobbyMessage", "GetSearchQuery", "Search", "LobbyCount", "GetLobbyId", "ConnectVoice", "DisconnectVoice", "ConnectNetwork", "DisconnectNetwork", "FlushNetwork", "OpenNetworkChannel", "SendNetworkMessage"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyMemberTransaction.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyMemberTransaction.java new file mode 100644 index 00000000..43834182 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyMemberTransaction.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordLobbyMemberTransaction extends DiscordStruct { public IDiscordLobbyMemberTransaction() {super();} public IDiscordLobbyMemberTransaction(Pointer pointer) {super(pointer);} + public interface SetMetadataCallback extends GameSDKCallback { EDiscordResult setMetadata(IDiscordLobbyMemberTransaction lobbyMemberTransaction, Pointer key, Pointer value); } // key is 256 bytes, value is 4096 + public SetMetadataCallback SetMetadata; + + public interface DeleteMetadataCallback extends GameSDKCallback { EDiscordResult deleteMetadata(IDiscordLobbyMemberTransaction lobbyMemberTransaction, Pointer key); } // key is 256 bytes, passed by reference + public DeleteMetadataCallback DeleteMetadata; + + + + public static class ByReference extends IDiscordLobbyMemberTransaction implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordLobbyMemberTransaction implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("SetMetadata", "DeleteMetadata"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbySearchQuery.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbySearchQuery.java new file mode 100644 index 00000000..83019eb6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbySearchQuery.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordLobbySearchComparison; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordLobbySearchDistance; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordLobbySearchCast; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordLobbySearchQuery extends DiscordStruct { public IDiscordLobbySearchQuery() {super();} public IDiscordLobbySearchQuery(Pointer pointer) {super(pointer);} + public interface FilterCallback extends GameSDKCallback { EDiscordResult filter(IDiscordLobbySearchQuery lobbySearchQuery, Pointer key, EDiscordLobbySearchComparison comparison, EDiscordLobbySearchCast cast, Pointer value); } + public FilterCallback Filter; + + public interface SortCallback extends GameSDKCallback { EDiscordResult sort(IDiscordLobbySearchQuery lobbySearchQuery, Pointer key, EDiscordLobbySearchCast cast, Pointer value); } + public SortCallback Sort; + + public interface LimitCallback extends GameSDKCallback { EDiscordResult limit(IDiscordLobbySearchQuery lobbySearchQuery, UInt32 limit); } + public LimitCallback Limit; + + public interface DistanceCallback extends GameSDKCallback { EDiscordResult distance(IDiscordLobbySearchQuery lobbySearchQuery, EDiscordLobbySearchDistance distance); } + public DistanceCallback Distance; + + + + public static class ByReference extends IDiscordLobbySearchQuery implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordLobbySearchQuery implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("Filter", "Sort", "Limit", "Distance"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyTransaction.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyTransaction.java new file mode 100644 index 00000000..0005c2bf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordLobbyTransaction.java @@ -0,0 +1,57 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordLobbyType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordLobbyTransaction extends DiscordStruct { public IDiscordLobbyTransaction() {super();} public IDiscordLobbyTransaction(Pointer pointer) {super(pointer);} + public interface SetTypeCallback extends GameSDKCallback { EDiscordResult setType(IDiscordLobbyTransaction lobbyTransaction, EDiscordLobbyType type); } + public SetTypeCallback SetType; + + public interface SetOwnerCallback extends GameSDKCallback { EDiscordResult setOwner(IDiscordLobbyTransaction lobbyTransaction, DiscordSnowflake ownerId); } + public SetOwnerCallback SetOwner; + + public interface SetCapacityCallback extends GameSDKCallback { EDiscordResult setCapacity(IDiscordLobbyTransaction lobbyTransaction, UInt32 capacity); } + public SetCapacityCallback SetCapacity; + + public interface SetMetadataCallback extends GameSDKCallback { EDiscordResult setMetadata(IDiscordLobbyTransaction lobbyTransaction, Pointer key, Pointer value); } + public SetMetadataCallback SetMetadata; + + public interface DeleteMetadataCallback extends GameSDKCallback { EDiscordResult deleteMetadata(IDiscordLobbyTransaction lobbyTransaction, Pointer key); } + public DeleteMetadataCallback DeleteMetadata; + + public interface SetLockedCallback extends GameSDKCallback { EDiscordResult setLocked(IDiscordLobbyTransaction lobbyTransaction, boolean locked); } + public SetLockedCallback SetLocked; + + + + public static class ByReference extends IDiscordLobbyTransaction implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordLobbyTransaction implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("SetType", "SetOwner", "SetCapacity", "SetMetadata", "DeleteMetadata", "SetLocked"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordNetworkEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordNetworkEvents.java new file mode 100644 index 00000000..2f08f975 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordNetworkEvents.java @@ -0,0 +1,45 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordNetworkChannelId; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordNetworkPeerId; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordNetworkEvents extends DiscordStruct { public IDiscordNetworkEvents() {super();} public IDiscordNetworkEvents(Pointer pointer) {super(pointer);} + public interface OnMessageCallback extends GameSDKCallback { void onMessage(Pointer eventData, DiscordNetworkPeerId peerId, DiscordNetworkChannelId channelId, ByteByReference data, UInt32 dataLength); } + public OnMessageCallback OnMessage; + + public interface OnRouteUpdateCallback extends GameSDKCallback { void onRouteUpdate(Pointer eventData, String route_data); } + public OnRouteUpdateCallback OnRouteUpdate; + + + + public static class ByReference extends IDiscordNetworkEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordNetworkEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("OnMessage", "OnRouteUpdate"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordNetworkManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordNetworkManager.java new file mode 100644 index 00000000..7ec25896 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordNetworkManager.java @@ -0,0 +1,65 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.LongByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordNetworkChannelId; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordNetworkPeerId; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordNetworkManager extends DiscordStruct { public IDiscordNetworkManager() {super();} public IDiscordNetworkManager(Pointer pointer) {super(pointer);} + public interface GetPeerIdCallback extends GameSDKCallback { void getPeerId(IDiscordNetworkManager manager, LongByReference peerId); } + public GetPeerIdCallback GetPeerId; + + public interface FlushCallback extends GameSDKCallback { EDiscordResult flush(IDiscordNetworkManager manager); } + public FlushCallback Flush; + + public interface OpenPeerCallback extends GameSDKCallback { EDiscordResult openPeer(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, String routeData); } + public OpenPeerCallback OpenPeer; + + public interface UpdatePeerCallback extends GameSDKCallback { EDiscordResult updatePeer(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, String routeData); } + public UpdatePeerCallback UpdatePeer; + + public interface ClosePeerCallback extends GameSDKCallback { EDiscordResult closePeer(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId); } + public ClosePeerCallback ClosePeer; + + public interface OpenChannelCallback extends GameSDKCallback { EDiscordResult openChannel(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, DiscordNetworkChannelId channelId, boolean reliable); } + public OpenChannelCallback OpenChannel; + + public interface CloseChannelCallback extends GameSDKCallback { EDiscordResult closeChannel(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, DiscordNetworkChannelId channelId); } + public CloseChannelCallback CloseChannel; + + public interface SendMessageCallback extends GameSDKCallback { EDiscordResult sendMessage(IDiscordNetworkManager manager, DiscordNetworkPeerId peerId, DiscordNetworkChannelId channelId, ByteByReference data, UInt32 dataLength); } + public SendMessageCallback SendMessage; + + + + public static class ByReference extends IDiscordNetworkManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordNetworkManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("GetPeerId", "Flush", "OpenPeer", "UpdatePeer", "ClosePeer", "OpenChannel", "CloseChannel", "SendMessage"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordOverlayEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordOverlayEvents.java new file mode 100644 index 00000000..f4a1d544 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordOverlayEvents.java @@ -0,0 +1,38 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordOverlayEvents extends DiscordStruct { public IDiscordOverlayEvents() {super();} public IDiscordOverlayEvents(Pointer pointer) {super(pointer);} + public interface OnToggleCallback extends GameSDKCallback { void onToggle(Pointer eventData, boolean locked); } + public OnToggleCallback OnToggle; + + + + public static class ByReference extends IDiscordOverlayEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordOverlayEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("OnToggle"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordOverlayManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordOverlayManager.java new file mode 100644 index 00000000..3283d21e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordOverlayManager.java @@ -0,0 +1,56 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordActivityActionType; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordOverlayManager extends DiscordStruct { public IDiscordOverlayManager() {super();} public IDiscordOverlayManager(Pointer pointer) {super(pointer);} + public interface IsEnabledCallback extends GameSDKCallback { void isEnabled(IDiscordOverlayManager manager, ByteByReference enabled); } + public IsEnabledCallback IsEnabled; + + public interface IsLockedCallback extends GameSDKCallback { void isLocked(IDiscordOverlayManager manager, ByteByReference locked); } + public IsLockedCallback IsLocked; + + public interface SetLockedCallback extends GameSDKCallback { void setLocked(IDiscordOverlayManager manager, boolean locked, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public SetLockedCallback SetLocked; + + public interface OpenActivityInviteCallback extends GameSDKCallback { void openActivityInvite(IDiscordOverlayManager manager, EDiscordActivityActionType type, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public OpenActivityInviteCallback OpenActivityInvite; + + public interface OpenGuildInviteCallback extends GameSDKCallback { void openGuildInvite(IDiscordOverlayManager manager, String code, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public OpenGuildInviteCallback OpenGuildInvite; + + public interface OpenVoiceSettingsCallback extends GameSDKCallback { void openVoiceSettings(IDiscordOverlayManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public OpenVoiceSettingsCallback OpenVoiceSettings; + + + + public static class ByReference extends IDiscordOverlayManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordOverlayManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("IsEnabled", "IsLocked", "SetLocked", "OpenActivityInvite", "OpenGuildInvite", "OpenVoiceSettings"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordRelationshipEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordRelationshipEvents.java new file mode 100644 index 00000000..97da94ee --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordRelationshipEvents.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordRelationship; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordRelationshipEvents extends DiscordStruct { public IDiscordRelationshipEvents() {super();} public IDiscordRelationshipEvents(Pointer pointer) {super(pointer);} + public interface OnRefreshCallback extends GameSDKCallback { void onRefresh(Pointer eventData); } + public OnRefreshCallback OnRefresh; + + public interface OnRelationshipUpdateCallback extends GameSDKCallback { void onRelationshipUpdate(Pointer eventData, DiscordRelationship relationship); } + public OnRelationshipUpdateCallback OnRelationshipUpdate; + + + + public static class ByReference extends IDiscordRelationshipEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordRelationshipEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("OnRefresh", "OnRelationshipUpdate"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordRelationshipManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordRelationshipManager.java new file mode 100644 index 00000000..e0084c98 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordRelationshipManager.java @@ -0,0 +1,53 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.IntByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordRelationship; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordRelationshipManager extends DiscordStruct { public IDiscordRelationshipManager() {super();} public IDiscordRelationshipManager(Pointer pointer) {super(pointer);} + public interface FilterCallback extends GameSDKCallback { void filter(IDiscordRelationshipManager manager, Pointer filterData, FilterCallback_Callback filter); } + public interface FilterCallback_Callback extends GameSDKCallback { boolean filter(Pointer filterData, DiscordRelationship relationShip);} + public FilterCallback Filter; + + public interface CountCallback extends GameSDKCallback { EDiscordResult count(IDiscordRelationshipManager manager, IntByReference count); } + public CountCallback Count; + + public interface GetCallback extends GameSDKCallback { EDiscordResult get(IDiscordRelationshipManager manager, DiscordSnowflake userId, DiscordRelationship relationship); } + public GetCallback Get; + + public interface GetAtCallback extends GameSDKCallback { EDiscordResult getAt(IDiscordRelationshipManager manager, UInt32 index, DiscordRelationship relationship); } + public GetAtCallback GetAt; + + + + public static class ByReference extends IDiscordRelationshipManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordRelationshipManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("Filter", "Count", "Get", "GetAt"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStorageManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStorageManager.java new file mode 100644 index 00000000..035ee652 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStorageManager.java @@ -0,0 +1,81 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.IntByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.Int32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordFileStat; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt64; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordStorageManager extends DiscordStruct { public IDiscordStorageManager() {super();} public IDiscordStorageManager(Pointer pointer) {super(pointer);} + public interface ReadCallback extends GameSDKCallback { EDiscordResult read(IDiscordStorageManager manager, String name, ByteByReference data, UInt32 dataLength, IntByReference read); } + public ReadCallback Read; + + public interface DiscordStorageManagerCallback extends GameSDKCallback { + void callback(Pointer callbackData, EDiscordResult result, ByteByReference data, IntByReference data_length); + } + + public interface ReadAsyncCallback extends GameSDKCallback { void readAsync(IDiscordStorageManager manager, String name, Pointer callbackData, DiscordStorageManagerCallback callback); } + public ReadAsyncCallback ReadAsync; + + public interface ReadAsyncPartialCallback extends GameSDKCallback { void readAsyncPartial(IDiscordStorageManager manager, String name, UInt64 offset, UInt64 length, Pointer callbackData, DiscordStorageManagerCallback callback); } + public ReadAsyncPartialCallback ReadAsyncPartial; + + public interface WriteCallback extends GameSDKCallback { EDiscordResult write(IDiscordStorageManager manager, String name, ByteByReference data, UInt32 dataLength); } + public WriteCallback Write; + + public interface WriteAsyncCallback extends GameSDKCallback { void writeAsync(IDiscordStorageManager manager, String name, ByteByReference data, UInt32 dataLength, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public WriteAsyncCallback WriteAsync; + + public interface DeleteCallback extends GameSDKCallback { EDiscordResult delete(IDiscordStorageManager manager, String name); } + public DeleteCallback Delete; + + public interface ExistsCallback extends GameSDKCallback { EDiscordResult exists(IDiscordStorageManager manager, String name, ByteByReference exists); } // exists actually boolean + public ExistsCallback Exists; + + public interface CountCallback extends GameSDKCallback { void count(IDiscordStorageManager manager, IntByReference count); } + public CountCallback Count; + + public interface StatCallback extends GameSDKCallback { EDiscordResult stat(IDiscordStorageManager manager, String name, DiscordFileStat stat); } + public StatCallback Stat; + + public interface StatAtCallback extends GameSDKCallback { EDiscordResult statAt(IDiscordStorageManager manager, Int32 index, DiscordFileStat stat); } + public StatAtCallback StatAt; + + public interface GetPathCallback extends GameSDKCallback { EDiscordResult getPath(IDiscordStorageManager manager, Pointer path); } // path str len 4096 + public GetPathCallback GetPath; + + + + public static class ByReference extends IDiscordStorageManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordStorageManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + + @Override protected List getFieldOrder() { return Arrays.asList("Read", "ReadAsync", "ReadAsyncPartial", "Write", "WriteAsync", "Delete", "Exists", "Count", "Stat", "StatAt", "GetPath"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStoreEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStoreEvents.java new file mode 100644 index 00000000..e6df07d0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStoreEvents.java @@ -0,0 +1,43 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordEntitlement; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordStoreEvents extends DiscordStruct { public IDiscordStoreEvents() {super();} public IDiscordStoreEvents(Pointer pointer) {super(pointer);} + public interface OnEntitlementCreateCallback extends GameSDKCallback { void onEntitlementCreate(Pointer eventData, DiscordEntitlement entitlement); } + public OnEntitlementCreateCallback OnEntitlementCreate; + + public interface OnEntitlementDeleteCallback extends GameSDKCallback { void onEntitlementDelete(Pointer eventData, DiscordEntitlement entitlement); } + public OnEntitlementDeleteCallback OnEntitlementDelete; + + + + public static class ByReference extends IDiscordStoreEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordStoreEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + + @Override protected List getFieldOrder() { return Arrays.asList("OnEntitlementCreate", "OnEntitlementDelete"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStoreManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStoreManager.java new file mode 100644 index 00000000..3e387923 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordStoreManager.java @@ -0,0 +1,73 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.IntByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordSku; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordEntitlement; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.Int32; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordStoreManager extends DiscordStruct { public IDiscordStoreManager() {super();} public IDiscordStoreManager(Pointer pointer) {super(pointer);} + public interface FetchSkusCallback extends GameSDKCallback { void fetchSkus(IDiscordStoreManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public FetchSkusCallback FetchSkus; + + public interface CountSkusCallback extends GameSDKCallback { void countSkus(IDiscordStoreManager manager, IntByReference count); } + public CountSkusCallback CountSkus; + + public interface GetSkuCallback extends GameSDKCallback { EDiscordResult getSku(IDiscordStoreManager manager, DiscordSnowflake skuId, DiscordSku sku); } + public GetSkuCallback GetSku; + + public interface GetSkuAtCallback extends GameSDKCallback { EDiscordResult getSkuAt(IDiscordStoreManager manager, Int32 index, DiscordSku sku); } + public GetSkuAtCallback GetSkuAt; + + public interface FetchEntitlementsCallback extends GameSDKCallback { void fetchEntitlements(IDiscordStoreManager manager, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public FetchEntitlementsCallback FetchEntitlements; + + public interface CountEntitlementsCallback extends GameSDKCallback { void countEntitlements(IDiscordStoreManager manager, IntByReference count); } + public CountEntitlementsCallback CountEntitlements; + + public interface GetEntitlementCallback extends GameSDKCallback { EDiscordResult getEntitlement(IDiscordStoreManager manager, DiscordSnowflake entitlementId, DiscordEntitlement entitlement); } + public GetEntitlementCallback GetEntitlement; + + public interface GetEntitlementAtCallback extends GameSDKCallback { EDiscordResult getEntitlementAt(IDiscordStoreManager manager, Int32 index, DiscordEntitlement entitlement); } + public GetEntitlementAtCallback GetEntitlementAt; + + public interface HasSkuEntitlementCallback extends GameSDKCallback { EDiscordResult hasSkuEntitlement(IDiscordStoreManager manager, DiscordSnowflake skuId, ByteByReference hasEntitlement); } // hasEntitlement bool ptr + public HasSkuEntitlementCallback HasSkuEntitlement; + + public interface StartPurchaseCallback extends GameSDKCallback { void startPurchase(IDiscordStoreManager manager, DiscordSnowflake skuId, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public StartPurchaseCallback StartPurchase; + + + + public static class ByReference extends IDiscordStoreManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordStoreManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("FetchSkus", "CountSkus", "GetSku", "GetSkuAt", "FetchEntitlements", "CountEntitlements", "GetEntitlement", "GetEntitlementAt", "HasSkuEntitlement", "StartPurchase"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordUserEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordUserEvents.java new file mode 100644 index 00000000..0e80acb1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordUserEvents.java @@ -0,0 +1,38 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordUserEvents extends DiscordStruct { public IDiscordUserEvents() {super();} public IDiscordUserEvents(Pointer pointer) {super(pointer);} + public interface OnCurrentUserUpdateCallback extends GameSDKCallback { void onCurrentUserUpdate(Pointer eventData); } + public OnCurrentUserUpdateCallback OnCurrentUserUpdate; + + + + public static class ByReference extends IDiscordUserEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordUserEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + @Override protected List getFieldOrder() { return Arrays.asList("OnCurrentUserUpdate"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordUserManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordUserManager.java new file mode 100644 index 00000000..c4803a7d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordUserManager.java @@ -0,0 +1,53 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.IntByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordUserFlag; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordUser; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordUserManager extends DiscordStruct { public IDiscordUserManager() {super();} public IDiscordUserManager(Pointer pointer) {super(pointer);} + public interface GetCurrentUserCallback extends GameSDKCallback { EDiscordResult getCurrentUser(IDiscordUserManager manager, DiscordUser currentUser); } + public GetCurrentUserCallback GetCurrentUser; + + public interface GetUserCallback extends GameSDKCallback { void getUser(IDiscordUserManager manager, DiscordSnowflake userId, Pointer callbackData, GetUserCallback_Callback callback); } + public interface GetUserCallback_Callback extends GameSDKCallback { void callback(Pointer callbackData, EDiscordResult result, DiscordUser user);} + public GetUserCallback GetUser; + + public interface GetCurrentUserPremiumTypeCallback extends GameSDKCallback { EDiscordResult getCurrentUserPremiumType(IDiscordUserManager manager, IntByReference premiumType); } // EDiscordPremiumType ptr + public GetCurrentUserPremiumTypeCallback GetCurrentUserPremiumType; + + public interface CurrentUserHasFlagCallback extends GameSDKCallback { EDiscordResult currentUserHasFlag(IDiscordUserManager manager, EDiscordUserFlag flag, ByteByReference hasFlag); } // hasFlag bool ptr + public CurrentUserHasFlagCallback CurrentUserHasFlag; + + + + public static class ByReference extends IDiscordUserManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordUserManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + @Override protected List getFieldOrder() { return Arrays.asList("GetCurrentUser", "GetUser", "GetCurrentUserPremiumType", "CurrentUserHasFlag"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordVoiceEvents.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordVoiceEvents.java new file mode 100644 index 00000000..0e4b4731 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordVoiceEvents.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordVoiceEvents extends DiscordStruct { public IDiscordVoiceEvents() {super();} public IDiscordVoiceEvents(Pointer pointer) {super(pointer);} + public interface OnSettingsUpdateCallback extends GameSDKCallback { void onSettingsUpdate(Pointer eventData); } + public OnSettingsUpdateCallback OnSettingsUpdate; + + + + public static class ByReference extends IDiscordVoiceEvents implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordVoiceEvents implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + + @Override protected List getFieldOrder() { return Arrays.asList("OnSettingsUpdate"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordVoiceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordVoiceManager.java new file mode 100644 index 00000000..833a1ca4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/interfacestruct/IDiscordVoiceManager.java @@ -0,0 +1,72 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct; + +import com.sun.jna.Structure; +import com.sun.jna.ptr.ByteByReference; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordStruct; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordResult; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.UInt8; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordInputMode; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; + +import java.util.Arrays; +import java.util.List; + +public class IDiscordVoiceManager extends DiscordStruct { public IDiscordVoiceManager() {super();} public IDiscordVoiceManager(Pointer pointer) {super(pointer);} + public interface GetInputModeCallback extends GameSDKCallback { EDiscordResult getInputMode(IDiscordVoiceManager manager, DiscordInputMode inputMode); } + public GetInputModeCallback GetInputMode; + + public interface SetInputModeCallback extends GameSDKCallback { void setInputMode(IDiscordVoiceManager manager, DiscordInputMode.ByValue inputMode, Pointer callbackData, NativeGameSDK.DiscordCallback callback); } + public SetInputModeCallback SetInputMode; + + public interface IsSelfMuteCallback extends GameSDKCallback { EDiscordResult isSelfMute(IDiscordVoiceManager manager, ByteByReference mute); } + public IsSelfMuteCallback IsSelfMute; + + public interface SetSelfMuteCallback extends GameSDKCallback { EDiscordResult setSelfMute(IDiscordVoiceManager manager, boolean mute); } + public SetSelfMuteCallback SetSelfMute; + + public interface IsSelfDeafCallback extends GameSDKCallback { EDiscordResult isSelfDeaf(IDiscordVoiceManager manager, ByteByReference deaf); } + public IsSelfDeafCallback IsSelfDeaf; + + public interface SetSelfDeafCallback extends GameSDKCallback { EDiscordResult setSelfDeaf(IDiscordVoiceManager manager, boolean deaf); } + public SetSelfDeafCallback SetSelfDeaf; + + public interface IsLocalMuteCallback extends GameSDKCallback { EDiscordResult isLocalMute(IDiscordVoiceManager manager, DiscordSnowflake userId, ByteByReference mute); } + public IsLocalMuteCallback IsLocalMute; + + public interface SetLocalMuteCallback extends GameSDKCallback { EDiscordResult setLocalMute(IDiscordVoiceManager manager, DiscordSnowflake userId, boolean mute); } + public SetLocalMuteCallback SetLocalMute; + + public interface GetLocalVolumeCallback extends GameSDKCallback { EDiscordResult getLocalVolume(IDiscordVoiceManager manager, DiscordSnowflake userId, ByteByReference volume); } + public GetLocalVolumeCallback GetLocalVolume; + + public interface SetLocalVolumeCallback extends GameSDKCallback { EDiscordResult setLocalVolume(IDiscordVoiceManager manager, DiscordSnowflake userId, UInt8 volume); } + public SetLocalVolumeCallback SetLocalVolume; + + + + public static class ByReference extends IDiscordVoiceManager implements Structure.ByReference { public ByReference() {super();} public ByReference(Pointer pointer) {super(pointer);}} + public static class ByValue extends IDiscordVoiceManager implements Structure.ByValue { public ByValue() {super();} public ByValue(Pointer pointer) {super(pointer);}} + + + @Override protected List getFieldOrder() { return Arrays.asList("GetInputMode", "SetInputMode", "IsSelfMute", "SetSelfMute", "IsSelfDeaf", "SetSelfDeaf", "IsLocalMute", "SetLocalMute", "GetLocalVolume", "SetLocalVolume"); } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordClientID.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordClientID.java new file mode 100644 index 00000000..56e8f64c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordClientID.java @@ -0,0 +1,28 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +public class DiscordClientID extends Int64 { + public DiscordClientID() { + this(0); + } + public DiscordClientID(long value) { + super(value); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordNetworkChannelId.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordNetworkChannelId.java new file mode 100644 index 00000000..54dcbece --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordNetworkChannelId.java @@ -0,0 +1,28 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +public class DiscordNetworkChannelId extends UInt8 { + public DiscordNetworkChannelId() { + this(0); + } + public DiscordNetworkChannelId(long value) { + super(value); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordNetworkPeerId.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordNetworkPeerId.java new file mode 100644 index 00000000..c7493ffb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordNetworkPeerId.java @@ -0,0 +1,28 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +public class DiscordNetworkPeerId extends UInt64 { + public DiscordNetworkPeerId() { + this(0); + } + public DiscordNetworkPeerId(long value) { + super(value); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordSnowflake.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordSnowflake.java new file mode 100644 index 00000000..15681202 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordSnowflake.java @@ -0,0 +1,28 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +public class DiscordSnowflake extends Int64 { + public DiscordSnowflake() { + this(0); + } + public DiscordSnowflake(long value) { + super(value); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordTimestamp.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordTimestamp.java new file mode 100644 index 00000000..6b5fce90 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordTimestamp.java @@ -0,0 +1,28 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +public class DiscordTimestamp extends Int64 { + public DiscordTimestamp() { + this(0); + } + public DiscordTimestamp(long value) { + super(value); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordVersion.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordVersion.java new file mode 100644 index 00000000..eda4dcdf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/DiscordVersion.java @@ -0,0 +1,28 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +public class DiscordVersion extends Int32 { + public DiscordVersion() { + this(0); + } + public DiscordVersion(long value) { + super(value); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/Int32.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/Int32.java new file mode 100644 index 00000000..84210e6b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/Int32.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +import com.sun.jna.IntegerType; + +public class Int32 extends IntegerType { + public static final int SIZE = 4; + public Int32() { + this(0); + } + public Int32(long value) { + super(SIZE, value, false); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/Int64.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/Int64.java new file mode 100644 index 00000000..7ee7e61a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/Int64.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +import com.sun.jna.IntegerType; + +public class Int64 extends IntegerType { + public static final int SIZE = 8; + public Int64() { + this(0); + } + public Int64(long value) { + super(SIZE, value, false); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt32.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt32.java new file mode 100644 index 00000000..ff7db8a8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt32.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +import com.sun.jna.IntegerType; + +public class UInt32 extends IntegerType { + public static final int SIZE = 4; + public UInt32() { + this(0); + } + public UInt32(long value) { + super(SIZE, value, true); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt64.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt64.java new file mode 100644 index 00000000..360a80ee --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt64.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +import com.sun.jna.IntegerType; + +public class UInt64 extends IntegerType { + public static final int SIZE = 8; + public UInt64() { + this(0); + } + public UInt64(long value) { + super(SIZE, value, true); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt8.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt8.java new file mode 100644 index 00000000..f48ebd06 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/jna/typedef/UInt8.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef; + +import com.sun.jna.IntegerType; + +public class UInt8 extends IntegerType { + public static final int SIZE = 1; + public UInt8() { + this(0); + } + public UInt8(long value) { + super(SIZE, value, true); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordActivity.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordActivity.java new file mode 100644 index 00000000..76b11178 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordActivity.java @@ -0,0 +1,72 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.rpc; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.GameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordActivity; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordActivityType; +import lombok.Data; + +@Data +public class JDiscordActivity { + private EDiscordActivityType activityType; + private long applicationId; + private String name, state, details; + private long start, end; + private String largeImage, largeText, smallImage, smallText; + private String partyId; + private int partyCurr, partyMax; + private String matchSecret, joinSecret, spectateSecret; + private boolean instance; + + public static JDiscordActivity fromJNA(DiscordActivity discordActivity) { + if (discordActivity == null) return null; + JDiscordActivity jDiscordActivity = new JDiscordActivity(); + jDiscordActivity.activityType = discordActivity.activityType; + jDiscordActivity.applicationId = discordActivity.applicationId.longValue(); + jDiscordActivity.name = GameSDK.readString(discordActivity.name); + jDiscordActivity.state = GameSDK.readString(discordActivity.state); + jDiscordActivity.details = GameSDK.readString(discordActivity.details); + if (discordActivity.assets != null) { + jDiscordActivity.largeImage = GameSDK.readString(discordActivity.assets.large_image); + jDiscordActivity.largeText = GameSDK.readString(discordActivity.assets.large_text); + jDiscordActivity.smallImage = GameSDK.readString(discordActivity.assets.small_image); + jDiscordActivity.smallText = GameSDK.readString(discordActivity.assets.small_text); + } + if (discordActivity.timestamps != null) { + jDiscordActivity.start = discordActivity.timestamps.start.longValue(); + jDiscordActivity.end = discordActivity.timestamps.end.longValue(); + } + if (discordActivity.secrets != null) { + jDiscordActivity.matchSecret= GameSDK.readString(discordActivity.secrets.match); + jDiscordActivity.joinSecret = GameSDK.readString(discordActivity.secrets.join); + jDiscordActivity.spectateSecret = GameSDK.readString(discordActivity.secrets.spectate); + } + if (discordActivity.party != null) { + jDiscordActivity.partyId = GameSDK.readString(discordActivity.party.id); + if (discordActivity.party.discordActivityParty != null) { + jDiscordActivity.partyCurr = discordActivity.party.discordActivityParty.current_size.intValue(); + jDiscordActivity.partyMax = discordActivity.party.discordActivityParty.max_size.intValue(); + } + } + jDiscordActivity.instance = discordActivity.instance; + + return jDiscordActivity; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordRelation.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordRelation.java new file mode 100644 index 00000000..ae7ed1a6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordRelation.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.rpc; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordRelationship; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordRelationshipType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordStatus; +import lombok.Data; + +@Data +public class JDiscordRelation { + private EDiscordRelationshipType discordRelationshipType; + private EDiscordStatus status; + private JDiscordActivity discordActivity; + private JDiscordUser discordUser; + + public static JDiscordRelation fromJNA(DiscordRelationship relationship) { + JDiscordRelation jDiscordRelation = new JDiscordRelation(); + jDiscordRelation.discordUser = JDiscordUser.fromJNA(relationship.user); + jDiscordRelation.discordActivity = JDiscordActivity.fromJNA(relationship.presence.activity); + jDiscordRelation.status = relationship.presence.status; + jDiscordRelation.discordRelationshipType = relationship.type; + return jDiscordRelation; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordUser.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordUser.java new file mode 100644 index 00000000..a56cd884 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/JDiscordUser.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.rpc; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.GameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordUser; +import lombok.Data; + +@Data +public class JDiscordUser { + private long id; + private String username, discriminator, avatar; + private boolean bot; + + public static JDiscordUser fromJNA(DiscordUser discordUser) { + JDiscordUser jDiscordUser = new JDiscordUser(); + jDiscordUser.id = discordUser.id.longValue(); + jDiscordUser.username = GameSDK.readString(discordUser.username); + jDiscordUser.discriminator = GameSDK.readString(discordUser.discriminator); + jDiscordUser.avatar = GameSDK.readString(discordUser.avatar); + jDiscordUser.bot = discordUser.bot; + return jDiscordUser; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/RichPresenceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/RichPresenceManager.java new file mode 100644 index 00000000..9e2f249d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/RichPresenceManager.java @@ -0,0 +1,251 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.discord.rpc; + +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.party.PartyContext; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.events.impl.DiscordUserJoinRequestEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.DiscordUserUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.GameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.NativeGameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.*; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.*; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct.*; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.*; +import lombok.Getter; +import net.minecraftforge.common.MinecraftForge; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class RichPresenceManager implements Runnable { + public static RichPresenceManager INSTANCE = new RichPresenceManager(); + private Thread t = new Thread(this); + + public RichPresenceManager() { + t.start(); + } + @Getter + private NativeGameSDK nativeGameSDK; + @Getter + private IDiscordCore iDiscordCore; + private IDiscordActivityManager activityManager; + private IDiscordRelationshipManager relationshipManager; + private IDiscordActivityEvents.ByReference callbacks; + private IDiscordRelationshipEvents.ByReference relation_callbacks; + + @Getter + private Map relationMap = new HashMap<>(); + + private boolean ready = false; + + @Getter + private int lastSetupCode = -99999; + public int setup() { + ready = false; + if (iDiscordCore != null) { + iDiscordCore.Destroy.destroy(iDiscordCore); + iDiscordCore = null; + activityManager = null; callbacks = null; relation_callbacks = null; relationMap.clear(); + } + + nativeGameSDK = GameSDK.getNativeGameSDK(); + if (nativeGameSDK == null) return -9999; + DiscordCreateParams discordCreateParams = new DiscordCreateParams(); + discordCreateParams.flags = new UInt64(EDiscordCreateFlags.DiscordCreateFlags_NoRequireDiscord.getValue()); + discordCreateParams.client_id = new DiscordClientID(816298079732498473L); + + callbacks = new IDiscordActivityEvents.ByReference(); + callbacks.OnActivityInvite = (eventData, type, user, activity) -> { + try { + MinecraftForge.EVENT_BUS.post(new DiscordUserJoinRequestEvent(user, true)); + } catch (Throwable t) { + t.printStackTrace(); + } + System.out.println("Received Join Request from "+user.id.longValue()+" ("+GameSDK.readString(user.username)+")"); + }; + callbacks.OnActivityJoin = (eventData, secret) -> { + PartyManager.INSTANCE.joinWithToken(secret); + System.out.println("Trying to join with token "+secret); + }; + callbacks.OnActivityJoinRequest = (eventData, user) -> { + try { + MinecraftForge.EVENT_BUS.post(new DiscordUserJoinRequestEvent(user, false)); + } catch (Throwable t) { + t.printStackTrace(); + } + System.out.println("Received Join Request from "+user.id.longValue()+" - "+GameSDK.readString(user.username)); + }; + callbacks.OnActivitySpectate = (eventData, secret) -> { + }; + callbacks.write(); + + relation_callbacks = new IDiscordRelationshipEvents.ByReference(); + relation_callbacks.OnRefresh = (p) -> { + try { + ready = true; + IDiscordRelationshipManager iDiscordRelationshipManager = iDiscordCore.GetRelationshipManager.getRelationshipManager(iDiscordCore); + iDiscordRelationshipManager.Filter.filter(iDiscordRelationshipManager, Pointer.NULL, (d, relation) -> true); + IntByReference intByReference = new IntByReference(); + iDiscordRelationshipManager.Count.count(iDiscordRelationshipManager, intByReference); + int count = intByReference.getValue(); + relationMap.clear(); + for (int i = 0; i < count; i++) { + DiscordRelationship discordRelationship = new DiscordRelationship(); + iDiscordRelationshipManager.GetAt.getAt(iDiscordRelationshipManager, new UInt32(i), discordRelationship); + + JDiscordRelation jDiscordRelation = JDiscordRelation.fromJNA(discordRelationship); + relationMap.put(jDiscordRelation.getDiscordUser().getId(), jDiscordRelation); + } + } catch (Throwable e) {e.printStackTrace();} + }; + relation_callbacks.OnRelationshipUpdate = (p, rel) -> { + try { + JDiscordRelation jDiscordRelation = JDiscordRelation.fromJNA(rel); + JDiscordRelation prev = relationMap.put(jDiscordRelation.getDiscordUser().getId(), jDiscordRelation); + MinecraftForge.EVENT_BUS.post(new DiscordUserUpdateEvent(prev, jDiscordRelation)); + } catch (Throwable t) { + t.printStackTrace(); + } + }; + relation_callbacks.write(); + + discordCreateParams.activity_events = callbacks; + discordCreateParams.relationship_events = relation_callbacks; // 96 + + PointerByReference pointerByReference = new PointerByReference(); + discordCreateParams.write(); + + EDiscordResult eDiscordResult = nativeGameSDK.DiscordCreate(new DiscordVersion(NativeGameSDK.DISCORD_VERSION), discordCreateParams, pointerByReference); + if (eDiscordResult != EDiscordResult.DiscordResult_Ok) return eDiscordResult.getValue(); + if (pointerByReference.getValue() == Pointer.NULL) return -9998; + iDiscordCore = new IDiscordCore(pointerByReference.getValue()); + + iDiscordCore.SetLogHook.setLogHook(iDiscordCore, EDiscordLogLevel.DiscordLogLevel_Debug, Pointer.NULL, new IDiscordCore.LogHook() { + @Override + public void hook(Pointer hookData, EDiscordLogLevel level, String message) { + System.out.println(message+" - "+level+" - "+hookData); + } + }); + + activityManager = iDiscordCore.GetActivityManager.getActivityManager(iDiscordCore); + relationshipManager = iDiscordCore.GetRelationshipManager.getRelationshipManager(iDiscordCore); + + return eDiscordResult.getValue(); + } + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + public void respond(DiscordSnowflake userID, EDiscordActivityJoinRequestReply reply) { + if (activityManager == null) return; + activityManager.SendRequestReply.sendRequestReply(activityManager, userID, reply, Pointer.NULL, (callbackData, result) -> { + System.out.println("Discord Returned "+result+" For Replying "+reply+" To "+userID.longValue()+"L"); + }); + } + + public void accept(DiscordSnowflake userID) { + if (activityManager == null) return; + activityManager.AcceptInvite.acceptInvite(activityManager, userID, Pointer.NULL, (callbackData, result) -> { + System.out.println("Discord Returned "+result+" For Accepting invite from "+userID.longValue()+"L"); + }); + } + public void updatePresence() { + if (!skyblockStatus.isOnHypixel() || !FeatureRegistry.DISCORD_RICHPRESENCE.isEnabled() || (!skyblockStatus.isOnSkyblock() && FeatureRegistry.DISCORD_RICHPRESENCE.getParameter("disablenotskyblock").getValue())) { + activityManager.ClearActivity.clearActivity(activityManager, Pointer.NULL, (callbackData, result) -> { + }); + } else { + String name = DungeonContext.getDungeonName() == null ? "" : DungeonContext.getDungeonName(); + if (!skyblockStatus.isOnSkyblock()) name ="Somewhere on Hypixel"; + if (name.trim().equals("Your Island")) name = "Private Island"; + + DiscordActivity latestDiscordActivity = new DiscordActivity(); + latestDiscordActivity.assets = new DiscordActivityAssets(); + latestDiscordActivity.secrets = new DiscordActivitySecrets(); + latestDiscordActivity.party = new DiscordActivityParty(); + latestDiscordActivity.party.discordActivityParty = new DiscordPartySize(); + latestDiscordActivity.timestamps = new DiscordActivityTimestamps(); + GameSDK.writeString(latestDiscordActivity.assets.large_image, "mort"); + GameSDK.writeString(latestDiscordActivity.assets.large_text, "mort"); + GameSDK.writeString(latestDiscordActivity.state, name); + + GameSDK.writeString(latestDiscordActivity.party.id, Optional.ofNullable( PartyManager.INSTANCE.getPartyContext()).map(PartyContext::getPartyID).orElse("")); + latestDiscordActivity.party.discordActivityParty.current_size = new Int32(Optional.ofNullable(PartyManager.INSTANCE.getPartyContext()).map(PartyContext::getPartyRawMembers).map(Set::size).orElse(1)); + latestDiscordActivity.party.discordActivityParty.max_size = new Int32(PartyManager.INSTANCE.getMaxParty()); + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context != null) { + long init = context.getInit(); + latestDiscordActivity.timestamps.start = new DiscordTimestamp(init); + + if (context.getBossfightProcessor() != null) { + GameSDK.writeString(latestDiscordActivity.details, "Fighting "+context.getBossfightProcessor().getBossName()+": "+context.getBossfightProcessor().getCurrentPhase()); + } else { + GameSDK.writeString(latestDiscordActivity.details, "Clearing Rooms"); + } + } else { + latestDiscordActivity.timestamps.start = new DiscordTimestamp(0); + GameSDK.writeString(latestDiscordActivity.details, "Dungeons Guide"); + } + if (PartyManager.INSTANCE.getAskToJoinSecret() != null) { + GameSDK.writeString(latestDiscordActivity.secrets.join, PartyManager.INSTANCE.getAskToJoinSecret()); + } else { + GameSDK.writeString(latestDiscordActivity.secrets.join, ""); + } + activityManager.UpdateActivity.updateActivity(activityManager, latestDiscordActivity, Pointer.NULL, (callbackData, result) -> { + }); + } + } + + @Override + public void run() { + boolean setup = true; + int counter = 0; + while(!Thread.interrupted()) { + try { + if (iDiscordCore == null || setup) { + long lastSetup = lastSetupCode; + lastSetupCode = setup(); + if (lastSetup != lastSetupCode) + System.out.println("Discord returned "+lastSetupCode+" for setup "+EDiscordResult.fromValue(lastSetupCode)); + setup = lastSetupCode != EDiscordResult.DiscordResult_Ok.getValue(); + counter = 0; + } else { + EDiscordResult eDiscordResult = iDiscordCore.RunCallbacks.runCallbacks(iDiscordCore); + if (eDiscordResult != EDiscordResult.DiscordResult_Ok) { + setup = true; + } else if (ready){ + if (counter == 0) + updatePresence(); + if (++counter == 15) counter = 0; + } + } + Thread.sleep(16L); + } catch (Exception e) {e.printStackTrace();} + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonActionContext.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonActionContext.java new file mode 100644 index 00000000..f9541a3d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonActionContext.java @@ -0,0 +1,35 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon; + +import lombok.Getter; +import net.minecraft.util.Vec3; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DungeonActionContext { + @Getter + private static final Map spawnLocation = new HashMap<>(); + + @Getter + private static final List killeds = new ArrayList<>(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonContext.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonContext.java new file mode 100755 index 00000000..32a668c0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonContext.java @@ -0,0 +1,218 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonSpecificDataProvider; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonSpecificDataProviderRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEvent; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonCryptBrokenEvent; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonNodataEvent; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonPuzzleFailureEvent; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonSecretCountChangeEvent; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessor; +import kr.syeyoung.dungeonsguide.mod.events.impl.BossroomEnterEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.TabListUtil; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.common.MinecraftForge; + +import java.awt.*; +import java.util.List; +import java.util.*; + +public class DungeonContext { + /** + * This is static because its used in the constructor, + * it means we cannot set the name without having an object, + * and we cannot create an object without the name + * so its static :) + */ + @Getter @Setter + private static String dungeonName; + @Getter + @Setter + public int percentage; + @Getter + private final World world; + @Getter + private final MapProcessor mapProcessor; + + @Getter + @Setter + private BlockPos dungeonMin; + + @Getter + private final Map roomMapper = new HashMap<>(); + @Getter + private final List dungeonRoomList = new ArrayList<>(); + + @Getter + private final List globalRoomProcessors = new ArrayList<>(); + + @Getter + private final Map deaths = new HashMap<>(); + @Getter + private final List milestoneReached = new ArrayList<>(); + @Getter + @Setter + private long BossRoomEnterSeconds = -1; + @Getter + @Setter + private long init = -1; + @Getter + @Setter + private BlockPos bossroomSpawnPos = null; + + @Getter + @Setter + private boolean trapRoomGen = false; + + @Getter + private boolean gotMimic = false; + + private int latestSecretCnt = 0; + private int latestTotalSecret = 0; + private int latestCrypts = 0; + + @Getter + private int maxSpeed = 600; + @Getter + private double secretPercentage = 1.0; + + public void setGotMimic(boolean gotMimic) { + this.gotMimic = gotMimic; + createEvent(new DungeonNodataEvent("MIMIC_KILLED")); + } + + @Getter + @Setter + private BossfightProcessor bossfightProcessor; + + @Getter + private final Set players = new HashSet<>(); + + @Getter + private final List events = new ArrayList<>(); + + public DungeonContext(World world) { + this.world = world; + createEvent(new DungeonNodataEvent("DUNGEON_CONTEXT_CREATION")); + mapProcessor = new MapProcessor(this); + DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(getDungeonName()); + if (doorFinder != null) { + trapRoomGen = doorFinder.isTrapSpawn(getDungeonName()); + + secretPercentage = doorFinder.secretPercentage(getDungeonName()); + maxSpeed = doorFinder.speedSecond(getDungeonName()); + } else { + mapProcessor.setBugged(true); + } + init = System.currentTimeMillis(); + } + + public void createEvent(DungeonEventData eventData) { +// events.add(new DungeonEvent(eventData)); + } + + + private final Rectangle roomBoundary = new Rectangle(-10, -10, 138, 138); + + public void tick() { + + + if (mapProcessor.isInitialized() && BossRoomEnterSeconds == -1 && !roomBoundary.contains(mapProcessor.worldPointToMapPoint(Minecraft.getMinecraft().thePlayer.getPositionVector()))) { + BossRoomEnterSeconds = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000; + bossroomSpawnPos = Minecraft.getMinecraft().thePlayer.getPosition(); + MinecraftForge.EVENT_BUS.post(new BossroomEnterEvent()); + createEvent(new DungeonNodataEvent("BOSSROOM_ENTER")); + DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(getDungeonName()); + if (doorFinder != null) { + bossfightProcessor = doorFinder.createBossfightProcessor(world, getDungeonName()); + } else { + ChatTransmitter.sendDebugChat(new ChatComponentText("Error:: Null Data Providier")); + } + } + + players.clear(); + players.addAll(TabListUtil.getPlayersInDungeon()); + + + if (latestSecretCnt != FeatureRegistry.DUNGEON_SECRETS.getSecretsFound()) { + int newSecretCnt = FeatureRegistry.DUNGEON_SECRETS.getSecretsFound(); + createEvent(new DungeonSecretCountChangeEvent(latestSecretCnt, newSecretCnt, latestTotalSecret, FeatureRegistry.DUNGEON_SECRETS.sureOfTotalSecrets())); + latestSecretCnt = newSecretCnt; + } + if (latestTotalSecret != FeatureRegistry.DUNGEON_SECRETS.getTotalSecretsInt()) { + latestTotalSecret = FeatureRegistry.DUNGEON_SECRETS.getTotalSecretsInt(); + createEvent(new DungeonSecretCountChangeEvent(latestSecretCnt, latestSecretCnt, latestTotalSecret, FeatureRegistry.DUNGEON_SECRETS.sureOfTotalSecrets())); + } + if (latestCrypts != FeatureRegistry.DUNGEON_TOMBS.getTombsFound()) { + int newlatestCrypts = FeatureRegistry.DUNGEON_TOMBS.getTombsFound(); + createEvent(new DungeonCryptBrokenEvent(latestCrypts, newlatestCrypts)); + this.latestCrypts = newlatestCrypts; + } + } + + @Getter + private boolean ended = false; + @Getter + private boolean defeated = false; + + public void onChat(ClientChatReceivedEvent event) { + IChatComponent component = event.message; + String formatted = component.getFormattedText(); + if (formatted.contains("$DG-Comm")) { + event.setCanceled(true); + String data = component.getFormattedText().substring(component.getFormattedText().indexOf("$DG-Comm")); + String actual = TextUtils.stripColor(data); + String coords = actual.split(" ")[1]; + String secrets = actual.split(" ")[2]; + int x = Integer.parseInt(coords.split("/")[0]); + int z = Integer.parseInt(coords.split("/")[1]); + int secrets2 = Integer.parseInt(secrets); + Point roomPt = mapProcessor.worldPointToRoomPoint(new BlockPos(x, 70, z)); + ChatTransmitter.sendDebugChat(new ChatComponentText("Message from Other dungeons guide :: " + roomPt.x + " / " + roomPt.y + " total secrets " + secrets2)); + DungeonRoom dr = roomMapper.get(roomPt); + if (dr != null) { + dr.setTotalSecrets(secrets2); + } + } else if (formatted.contains("$DG-Mimic")) { + setGotMimic(true); + } else if (formatted.startsWith("ยงrยงcยงlPUZZLE FAIL! ") && formatted.endsWith(" ยงrยง4Yยงrยงciยงrยง6kยงrยงeeยงrยงasยงrยง2!ยงr")) { + createEvent(new DungeonPuzzleFailureEvent(TextUtils.stripColor(formatted.split(" ")[2]), formatted)); + } else if (formatted.contains("ยง6> ยงeยงlEXTRA STATS ยง6<")) { + createEvent(new DungeonNodataEvent("DUNGEON_END")); + ended = true; + } else if (formatted.contains("ยงrยงcโ˜  ยงrยงeDefeated ")) { + defeated = true; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonFacade.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonFacade.java new file mode 100644 index 00000000..96a951fd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/DungeonFacade.java @@ -0,0 +1,35 @@ +package kr.syeyoung.dungeonsguide.mod.dungeon; + +import kr.syeyoung.dungeonsguide.Main; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoomInfoRegistry; +import kr.syeyoung.dungeonsguide.mod.events.listener.DungeonListener; +import lombok.Getter; +import lombok.Setter; +import net.minecraftforge.common.MinecraftForge; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import java.io.IOException; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +public class DungeonFacade { + + @Getter + @Setter + private DungeonContext context; + + public void init() { + DungeonListener dgEventListener = new DungeonListener(); + MinecraftForge.EVENT_BUS.register(dgEventListener); + + try { + DungeonRoomInfoRegistry.loadAll(Main.getConfigDir()); + } catch (BadPaddingException | InvalidKeyException | NoSuchPaddingException | IllegalBlockSizeException | + IOException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/MapProcessor.java new file mode 100755 index 00000000..9c2462ea --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/MapProcessor.java @@ -0,0 +1,535 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.Sets; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.EDungeonDoorType; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.SerializableBlockPos; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonMapUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonRoomDiscoverEvent; +import kr.syeyoung.dungeonsguide.mod.dungeon.map.DungeonMapData; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.MapUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.*; +import net.minecraft.world.storage.MapData; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.vecmath.Vector2d; +import java.awt.*; +import java.util.List; +import java.util.Queue; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class MapProcessor { + + private static final Set directions = Sets.newHashSet(new Vector2d(0, 1), new Vector2d(0, -1), new Vector2d(1, 0), new Vector2d(-1, 0)); + private static final Set door_dirs = Sets.newHashSet(new Vector2d(0, 0.5), new Vector2d(0, -0.5), new Vector2d(0.5, 0), new Vector2d(-0.5, 0)); + private static final Minecraft mc = Minecraft.getMinecraft(); + private final DungeonContext context; + @Getter + private final BiMap mapIconToPlayerMap = HashBiMap.create(); + private final List roomsFound = new ArrayList<>(); + Logger logger = LogManager.getLogger("MapProcessor"); + /** + * If the player on the map is closer than value this it won't save it + * this should be done with render-distance but whateva + */ + int clossnessDistance = 50; + @Getter + @Setter + private Dimension unitRoomDimension; + @Getter @Setter + private Dimension doorDimensions; // width: width of door, height: gap between rooms + @Getter + @Setter + private Point topLeftMapPoint; + @Setter + private boolean bugged = false; + @Getter + private boolean initialized = false; + @Getter + private int undiscoveredRoom = 0; + private boolean processed = false; + @Getter + private MapData latestMapData; + private int waitDelay = 0; + private boolean processlock; + + public MapProcessor(DungeonContext context) { + this.context = context; + } + + private static void error(String prefix) { + ChatTransmitter.addToQueue(new ChatComponentText(ChatTransmitter.prefix + prefix)); + } + + + ExecutorService es = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("Dg-MapProcessor-%d").build()); + + + int processMapThroddle; + + public void tick() { + if (waitDelay < 5) { + waitDelay++; + return; + } + if (bugged) { + return; + } + ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(8); + + if (stack == null || !(stack.getItem() instanceof ItemMap)) { + return; + } + + MapData mapData = ((ItemMap) stack.getItem()).getMapData(stack, mc.theWorld); + + if (mapData != null) { + + if(processMapThroddle > 5 && !processlock){ + processMapData(mapData.colors); + processMapThroddle = 0; + } + processMapThroddle++; + + } + + latestMapData = mapData; + + if (latestMapData != null && mapIconToPlayerMap.size() < context.getPlayers().size() && initialized) { + getPlayersFromMap(latestMapData); + } + + } + + private void processMapData(byte[] mapColorData) { + + // i just cant get this to work sad + if (isThereDifference(latestMapData.colors, mapColorData)) { + context.createEvent(new DungeonMapUpdateEvent(mapColorData)); + + es.execute(() -> { + processlock = true; + if (doorDimensions == null || !initialized) { + assembleMap(mapColorData); + } else { + processMap(mapColorData); + } + + if (context.isEnded()) { + processFinishedMap(mapColorData); + } + processlock = false; + }); + + } + + } + + void assembleMap(final byte[] mapData){ + DungeonMapData data = new DungeonMapData(context, Minecraft.getMinecraft()); + + data.eat(mapData); + + bugged = data.bugged; + + unitRoomDimension = data.unitRoomDimension; + + topLeftMapPoint = data.topLeftMapPoint; + + initialized = data.initialized; + + doorDimensions = data.doorDimensions; + + } + + + public static Point mapPointToRoomPoint(Point mapPoint, Point topLeftMapPoint, Dimension unitRoomDimension, Dimension doorDimensions) { + int x = (int) ((mapPoint.x - topLeftMapPoint.x) / ((double) unitRoomDimension.width + doorDimensions.height)); + int y = (int) ((mapPoint.y - topLeftMapPoint.y) / ((double) unitRoomDimension.height + doorDimensions.height)); + return new Point(x, y); + } + + public BlockPos mapPointToWorldPoint(Point mapPoint) { + int x = (int) ((mapPoint.x - topLeftMapPoint.x) / ((double) unitRoomDimension.width + doorDimensions.height) * 32 + context.getDungeonMin().getX()); + int y = (int) ((mapPoint.y - topLeftMapPoint.y) / ((double) unitRoomDimension.height + doorDimensions.height) * 32 + context.getDungeonMin().getZ()); + return new BlockPos(x, 70, y); + } + + public Point roomPointToMapPoint(Point roomPoint) { + return new Point(roomPoint.x * (unitRoomDimension.width + doorDimensions.height) + topLeftMapPoint.x, roomPoint.y * (unitRoomDimension.height + doorDimensions.height) + topLeftMapPoint.y); + } + + public BlockPos roomPointToWorldPoint(Point roomPoint) { + return new BlockPos(context.getDungeonMin().getX() + (roomPoint.x * 32), context.getDungeonMin().getY(), context.getDungeonMin().getZ() + (roomPoint.y * 32)); + } + + public Point worldPointToRoomPoint(BlockPos worldPoint) { + if (context.getDungeonMin() == null) return null; + return new Point((worldPoint.getX() - context.getDungeonMin().getX()) / 32, (worldPoint.getZ() - context.getDungeonMin().getZ()) / 32); + } + + public Point worldPointToMapPoint(Vec3 worldPoint) { + if (context.getDungeonMin() == null) return null; + return new Point(topLeftMapPoint.x + (int) ((worldPoint.xCoord - context.getDungeonMin().getX()) / 32.0f * (unitRoomDimension.width + doorDimensions.height)), topLeftMapPoint.y + (int) ((worldPoint.zCoord - context.getDungeonMin().getZ()) / 32.0f * (unitRoomDimension.height + doorDimensions.height))); + } + + public Vector2d worldPointToMapPointFLOAT(Vec3 worldPoint) { + if (context.getDungeonMin() == null) return null; + double x = topLeftMapPoint.x + ((worldPoint.xCoord - context.getDungeonMin().getX()) / 32.0f * (unitRoomDimension.width + doorDimensions.height)); + double y = topLeftMapPoint.y + ((worldPoint.zCoord - context.getDungeonMin().getZ()) / 32.0f * (unitRoomDimension.height + doorDimensions.height)); + return new Vector2d(x, y); + } + + private void processMap(byte[] mapData) { + int roomHeight = (int) ((128.0 - topLeftMapPoint.y) / (unitRoomDimension.height + doorDimensions.height)); + int roomWidth = (int) ((128.0 - topLeftMapPoint.x) / (unitRoomDimension.width + doorDimensions.height)); + if (MapUtils.getMapColorAt(mapData, 0, 0) != 0) return; + undiscoveredRoom = 0; + for (int y = 0; y <= roomHeight; y++) { + for (int x = 0; x <= roomWidth; x++) { + Point mapPoint = roomPointToMapPoint(new Point(x, y)); + byte color = MapUtils.getMapColorAt(mapData, mapPoint.x, mapPoint.y); + MapUtils.record(mapData, mapPoint.x, mapPoint.y, new Color(255, 255, 0, 80)); + if (roomsFound.contains(new Point(x, y))) { + DungeonRoom dungeonRoom = context.getRoomMapper().get(new Point(x, y)); + if (color == 18 && dungeonRoom.getCurrentState() != DungeonRoom.RoomState.FINISHED) { + dungeonRoom.setCurrentState(DungeonRoom.RoomState.COMPLETE_WITHOUT_SECRETS); + dungeonRoom.setTotalSecrets(0); + } else if (color == 30) { + dungeonRoom.setCurrentState(DungeonRoom.RoomState.FINISHED); + dungeonRoom.setTotalSecrets(0); + } else if (dungeonRoom.getCurrentState() != DungeonRoom.RoomState.FINISHED) { + byte centerColor = MapUtils.getMapColorAt(mapData, mapPoint.x + unitRoomDimension.width / 2, mapPoint.y + unitRoomDimension.height / 2); + MapUtils.record(mapData, mapPoint.x + unitRoomDimension.width / 2, mapPoint.y + unitRoomDimension.height / 2, new Color(0, 255, 0, 80)); + if (centerColor == 34) { + dungeonRoom.setCurrentState(DungeonRoom.RoomState.COMPLETE_WITHOUT_SECRETS); + } else if (centerColor == 30) { + dungeonRoom.setCurrentState(DungeonRoom.RoomState.FINISHED); + } else if (centerColor == 18) { // red + dungeonRoom.setCurrentState(DungeonRoom.RoomState.FAILED); + } + } + if (dungeonRoom.getTotalSecrets() == -1) { + if (dungeonRoom.getColor() == 82 || dungeonRoom.getColor() == 74) { + dungeonRoom.setTotalSecrets(0); + } + MapUtils.record(mapData, mapPoint.x, mapPoint.y + 1, new Color(0, 255, 0, 80)); + } + continue; + } + + if (color != 0 && color != 85) { + MapUtils.record(mapData, mapPoint.x, mapPoint.y, new Color(0, 255, 255, 80)); + DungeonRoom room = buildRoom(mapData, new Point(x, y)); + + + // USELESS DEBUG CODE + context.createEvent(new DungeonRoomDiscoverEvent(room.getUnitPoints().get(0), room.getRoomMatcher().getRotation(), new SerializableBlockPos(room.getMin()), new SerializableBlockPos(room.getMax()), room.getShape(), room.getColor(), room.getDungeonRoomInfo().getUuid(), room.getDungeonRoomInfo().getName(), room.getDungeonRoomInfo().getProcessorId())); + ChatTransmitter.sendDebugChat(new ChatComponentText("New Map discovered! shape: " + room.getShape() + " color: " + room.getColor() + " unitPos: " + x + "," + y)); + ChatTransmitter.sendDebugChat(new ChatComponentText("New Map discovered! mapMin: " + room.getMin() + " mapMx: " + room.getMax())); + StringBuilder builder = new StringBuilder(); + for (int dy = 0; dy < 4; dy++) { + builder.append("\n"); + for (int dx = 0; dx < 4; dx++) { + boolean isSet = ((room.getShape() >> (dy * 4 + dx)) & 0x1) != 0; + builder.append(isSet ? "O" : "X"); + } + } + ChatTransmitter.sendDebugChat(new ChatComponentText("Shape visual: " + builder)); + // END + + + context.getDungeonRoomList().add(room); + for (Point p : room.getUnitPoints()) { + roomsFound.add(p); + context.getRoomMapper().put(p, room); + } + if (room.getRoomProcessor() != null && room.getRoomProcessor().readGlobalChat()) { + context.getGlobalRoomProcessors().add(room.getRoomProcessor()); + } + } else if (color == 85) { + undiscoveredRoom++; + } + + } + } + } + + private DungeonRoom buildRoom(byte[] mapData, Point unitPoint) { + Queue toCheck = new LinkedList<>(); + toCheck.add(new Point[]{unitPoint, unitPoint}); // requestor, target + Set checked = new HashSet<>(); + List ayConnected = new ArrayList<>(); + + int minX = Integer.MAX_VALUE; + int minY = Integer.MAX_VALUE; + int maxX = 0; + int maxY = 0; + while (toCheck.peek() != null) { + Point[] check = toCheck.poll(); + if (checked.contains(check[1])) { + continue; + } + checked.add(check[1]); + + if (checkIfConnected(mapData, check[0], check[1])) { + ayConnected.add(check[1]); + if (check[1].x < minX) minX = check[1].x; + if (check[1].y < minY) minY = check[1].y; + if (check[1].x > maxX) maxX = check[1].x; + if (check[1].y > maxY) maxY = check[1].y; + for (Vector2d dir : directions) { + Point newPt = new Point(check[1].x + (int) dir.x, check[1].y + (int) dir.y); + toCheck.add(new Point[]{check[1], newPt}); + } + } + } + + short shape = 0; + for (Point p : ayConnected) { + int localX = p.x - minX; + int localY = p.y - minY; + shape |= 1 << (localY * 4 + localX); + } + Set doors = new HashSet<>(); + for (Point p : ayConnected) { + for (Vector2d v : door_dirs) { + Vector2d v2 = new Vector2d(p.x + v.x, p.y + v.y); + if (doors.contains(v2)) doors.remove(v2); + else doors.add(v2); + } + } + Point pt2 = roomPointToMapPoint(ayConnected.get(0)); + byte unit1 = MapUtils.getMapColorAt(mapData, pt2.x, pt2.y); + + // 0: none 1: open door 2. unopen door 3: wither door 4. red door + Set> doorsAndStates = new HashSet<>(); + final int halfWidth = unitRoomDimension.width + 4; + for (Vector2d door : doors) { + int floorX = (int) Math.floor(door.x); + int floorY = (int) Math.floor(door.y); + Point mapPt = roomPointToMapPoint(new Point(floorX, floorY)); + Point target = new Point(mapPt.x + unitRoomDimension.width / 2 + (int) (halfWidth * (door.x - floorX)), mapPt.y + unitRoomDimension.height / 2 + (int) (halfWidth * (door.y - floorY))); + MapUtils.record(mapData, target.x, target.y, Color.green); + + byte color = MapUtils.getMapColorAt(mapData, target.x, target.y); + + Vector2d vector2d = new Vector2d(door.x - minX, door.y - minY); + + if (color == 0) { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.NONE)); + } else if (color == 85) { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.UNOPEN)); + } else if (color == 119) { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.WITHER)); + } else if (color == 18 && unit1 != 18) { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.BLOOD)); + } else { + doorsAndStates.add(new Tuple<>(vector2d, EDungeonDoorType.ENTRANCE)); + } + + } + + + return new DungeonRoom(ayConnected, shape, unit1, roomPointToWorldPoint(new Point(minX, minY)), roomPointToWorldPoint(new Point(maxX + 1, maxY + 1)).add(-1, 0, -1), context, doorsAndStates); + + } + + private boolean checkIfConnected(byte[] mapData, Point unitPoint1, Point unitPoint2) { + if (unitPoint1 == unitPoint2) return true; + if (unitPoint1.equals(unitPoint2)) return true; + + + Point high; + if (unitPoint2.y > unitPoint1.y) { + high = unitPoint2; + } else { + if (unitPoint2.x > unitPoint1.x) { + high = unitPoint2; + } else { + high = unitPoint1; + } + } + + Point low; + if (high == unitPoint2) { + low = unitPoint1; + } else { + low = unitPoint2; + } + + int xOff = low.x - high.x; + int yOff = low.y - high.y; + Point pt = roomPointToMapPoint(high); + Point pt2 = roomPointToMapPoint(low); + byte unit1 = MapUtils.getMapColorAt(mapData, pt.x, pt.y); + byte unit2 = MapUtils.getMapColorAt(mapData, pt2.x, pt2.y); + pt.translate(xOff, yOff); + byte unit3 = MapUtils.getMapColorAt(mapData, pt.x, pt.y); + + return unit1 == unit2 && unit2 == unit3 && unit1 != 0; + } + + public boolean isThereDifference(byte[] colorData, byte[] colorData1) { + + return true; +// boolean equals = Arrays.equals(colorData1, colorData); +// +// boolean foundDIffrentThen0 = false; +// +// +// for (byte colorDatum : colorData) { +// if(colorDatum != 0){ +// foundDIffrentThen0 = true; +// break; +// } +// } +// +// +// return !(equals && foundDIffrentThen0); + } + + private void processFinishedMap(byte[] mapData) { + if (MapUtils.getMapColorAt(mapData, 0, 0) == 0) { + return; + } + if (processed) { + return; + } + processed = true; + + MapUtils.clearMap(); + MapUtils.record(mapData, 0, 0, Color.GREEN); + + + FeatureRegistry.ETC_COLLECT_SCORE.collectDungeonRunData(mapData, context); + + } + + private void getPlayersFromMap(MapData mapdata) { + + if (DungeonsGuide.getDungeonsGuide().verbose) logger.info("Getting players from map"); + + for (Map.Entry stringVec4bEntry : mapdata.mapDecorations.entrySet()) { + String mapDecString = stringVec4bEntry.getKey(); + Vec4b vec4 = stringVec4bEntry.getValue(); + + if (!mapIconToPlayerMap.containsValue(mapDecString)) { + if (DungeonsGuide.getDungeonsGuide().verbose) logger.info("mapIconToPlayerMap dosent have Player"); + + int x = vec4.func_176112_b() / 2 + 64; + int y = vec4.func_176113_c() / 2 + 64; + BlockPos mapPos = mapPointToWorldPoint(new Point(x, y)); + String potentialPlayer = null; + + for (String player : context.getPlayers()) { + if (DungeonsGuide.getDungeonsGuide().verbose) + logger.info("Player: {} isNear: {} ", player, isPlayerNear(player, mapPos)); +// if (!mapIconToPlayerMap.containsKey(player) && isPlayerNear(player, mapPos)) { + if (!mapIconToPlayerMap.containsKey(player)) { + if (DungeonsGuide.getDungeonsGuide().verbose) logger.info("Potential profile is: " + player); + potentialPlayer = player; + break; + } + } + + + if (potentialPlayer != null) { + if (DungeonsGuide.getDungeonsGuide().verbose) logger.info("potentialPlayer is not null"); + boolean shouldSave = true; + + for (Map.Entry vec4bEntry : mapdata.mapDecorations.entrySet()) { +// String aaa = vec4bEntry.getKey(); + Vec4b bbb = vec4bEntry.getValue(); + +// if (mapIconToPlayerMap.containsValue(aaa) || mapDecString.equals(aaa)) { +// shouldSave = false; +// break; +// } +// else { + int x2 = bbb.func_176112_b() / 2 + 64; + int y2 = bbb.func_176113_c() / 2 + 64; + int dx = x2 - x; + int dy = y2 - y; + if (dx * dx + dy * dy < clossnessDistance) { + shouldSave = false; + break; + } +// } + } + + if (shouldSave) { + if (DungeonsGuide.getDungeonsGuide().verbose) + logger.info("added {} to mapIconPlayerMap with {}", potentialPlayer, stringVec4bEntry.getKey()); + if (mapIconToPlayerMap.containsKey(potentialPlayer)) { + mapIconToPlayerMap.replace(potentialPlayer, stringVec4bEntry.getKey()); + } else { + mapIconToPlayerMap.put(potentialPlayer, stringVec4bEntry.getKey()); + } + if (DungeonsGuide.getDungeonsGuide().verbose) logger.info("mapIconToPlayerMap:"); + if (DungeonsGuide.getDungeonsGuide().verbose) + mapIconToPlayerMap.forEach((key, value) -> logger.info(" {}: {}", key, value)); + } else { + if (DungeonsGuide.getDungeonsGuide().verbose) logger.info("shouldSave is false"); + } + + + } else { + if (DungeonsGuide.getDungeonsGuide().verbose) logger.info("potentialPlayer is null"); + } + + } else { + if (DungeonsGuide.getDungeonsGuide().verbose) logger.info("mapIconToPlayerMap has player "); + } + } + + + } + + private boolean isPlayerNear(String player, BlockPos mapPos) { + EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(player); + + if (entityPlayer != null && !entityPlayer.isInvisible()) { + BlockPos pos = entityPlayer.getPosition(); + int dx = mapPos.getX() - pos.getX(); + int dz = mapPos.getZ() - pos.getZ(); + return dx * dx + dz * dz < clossnessDistance; + + } + + return false; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/AbstractAction.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/AbstractAction.java new file mode 100644 index 00000000..d465fd47 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/AbstractAction.java @@ -0,0 +1,61 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.util.Set; + +public abstract class AbstractAction { + public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRouteProperties actionRouteProperties){ + + } + + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + + } + + public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRouteProperties actionRouteProperties) { + + } + + public void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties) { + + } + + public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRouteProperties actionRouteProperties) { + + } + + public void onTick(DungeonRoom dungeonRoom, ActionRouteProperties actionRouteProperties) { + + } + + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return null; + } + + public boolean isComplete(DungeonRoom dungeonRoom) { + return false; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionBreakWithSuperBoom.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionBreakWithSuperBoom.java new file mode 100755 index 00000000..baab261f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionBreakWithSuperBoom.java @@ -0,0 +1,103 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.HashSet; +import java.util.Set; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionBreakWithSuperBoom extends AbstractAction { + private Set preRequisite = new HashSet(); + private OffsetPoint target; + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return false; + } + + public ActionBreakWithSuperBoom(OffsetPoint target) { + this.target = target; + } + + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + + BlockPos blockpos = target.getBlockPos(dungeonRoom); + + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + GlStateManager.disableLighting(); + GlStateManager.enableAlpha(); + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + GlStateManager.enableBlend(); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer vertexbuffer = tessellator.getWorldRenderer(); + vertexbuffer.begin(7, DefaultVertexFormats.BLOCK); + + BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); + blockrendererdispatcher.getBlockModelRenderer().renderModel(Minecraft.getMinecraft().theWorld, + blockrendererdispatcher.getBlockModelShapes().getModelForState(Blocks.tnt.getDefaultState()), + Blocks.tnt.getDefaultState(), blockpos, vertexbuffer, false); + tessellator.draw(); + + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + RenderUtils.highlightBlock(blockpos, new Color(0, 255,255,50), partialTicks, true); + RenderUtils.drawTextAtWorld("Superboom", blockpos.getX() + 0.5f, blockpos.getY() + 0.5f, blockpos.getZ() + 0.5f, 0xFFFFFF00, 0.03f, false, false, partialTicks); + } + + @Override + public String toString() { + return "BreakWithSuperboom\n- target: "+target.toString(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionChangeState.java new file mode 100755 index 00000000..634129c6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionChangeState.java @@ -0,0 +1,75 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDummy; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.HashSet; +import java.util.Set; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionChangeState extends AbstractAction { + @EqualsAndHashCode.Exclude + private Set preRequisite2 = new HashSet(); + + private String mechanicName; + private String state; + + public ActionChangeState(String mechanicName, String state) { + this.mechanicName = mechanicName; + this.state = state; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + Set set = new HashSet<>(preRequisite2); + DungeonMechanic mechanic = dungeonRoom.getMechanics().get(mechanicName); + if (mechanic!= null) + set.addAll(mechanic.getAction(state, dungeonRoom)); + return set; + } + @Override + public String toString() { + return "ChangeState\n- target: "+mechanicName+"\n- state: "+state; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + DungeonMechanic mechanic = dungeonRoom.getMechanics().get(mechanicName); + if (state.equalsIgnoreCase("navigate")) { + return true; + } + if (mechanic == null) { + return false; + } + if (mechanic instanceof DungeonSecret && ((DungeonSecret) mechanic).getSecretType() != DungeonSecret.SecretType.CHEST) { + return true; + } + if (mechanic instanceof DungeonDummy) { + return true; + } + return mechanic.getCurrentState(dungeonRoom).equalsIgnoreCase(state); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionClick.java new file mode 100755 index 00000000..c9ffb81c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionClick.java @@ -0,0 +1,82 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.awt.*; +import java.util.HashSet; +import java.util.Set; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionClick extends AbstractAction { + private Set preRequisite = new HashSet(); + private OffsetPoint target; + private Predicate predicate = Predicates.alwaysTrue(); + + private boolean clicked = false; + + public ActionClick(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return clicked; + } + + @Override + public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRouteProperties actionRouteProperties) { + if (clicked) return; + if (target.getBlockPos(dungeonRoom).equals(event.pos) && + (predicate == null || predicate.apply(event.entityLiving.getHeldItem()))) { + clicked = true; + ChatTransmitter.sendDebugChat("ACTION FINISHED: CLICK"); + } + } + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); + RenderUtils.drawTextAtWorld("Click", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); + } + + + @Override + public String toString() { + return "Click\n- target: "+target.toString()+"\n- predicate: "+predicate.getClass().getSimpleName(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionClickSet.java new file mode 100755 index 00000000..01f5b9b2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionClickSet.java @@ -0,0 +1,90 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.awt.*; +import java.util.HashSet; +import java.util.Set; +import java.util.function.Predicate; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionClickSet extends AbstractAction { + private Set preRequisite = new HashSet<>(); + private OffsetPointSet target; + private Predicate predicate = stack -> true; + + public ActionClickSet(OffsetPointSet target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public String toString() { + return "ClickSet\n- targets size: "+target.getOffsetPointList().size()+"\n- predicate: "+predicate.getClass().getSimpleName(); + } + + private boolean clicked = false; + @Override + public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRouteProperties actionRouteProperties) { + if (clicked) return; + for (OffsetPoint pt2: target.getOffsetPointList()) { + if (pt2.getBlockPos(dungeonRoom).equals(event.pos) && predicate.test(event.entityLiving.getHeldItem())) { + clicked = true; + } + } + + } + + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + float xAcc = 0; + float yAcc = 0; + float zAcc = 0; + int size = target.getOffsetPointList().size(); + for (OffsetPoint offsetPoint : target.getOffsetPointList()) { + BlockPos pos = offsetPoint.getBlockPos(dungeonRoom); + xAcc += pos.getX() + 0.5f; + yAcc += pos.getY()+ 0.5f; + zAcc += pos.getZ()+ 0.5f; + RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), new Color(0, 255,255,50),partialTicks, true); + } + + RenderUtils.drawTextAtWorld("Click", xAcc / size, yAcc / size, zAcc / size, 0xFFFFFF00, 0.02f, false, false, partialTicks); + } + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return clicked; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionComplete.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionComplete.java new file mode 100644 index 00000000..32d6bfc3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionComplete.java @@ -0,0 +1,41 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; + +import java.util.Collections; +import java.util.Set; + +public class ActionComplete extends AbstractAction { + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return Collections.emptySet(); + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return false; + } + + @Override + public String toString() { + return "Completed"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionDropItem.java new file mode 100755 index 00000000..0c94e5ae --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionDropItem.java @@ -0,0 +1,82 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@Data +@EqualsAndHashCode(callSuper = false) +public class ActionDropItem extends AbstractAction { + private Set preRequisite = new HashSet<>(); + private OffsetPoint target; + private Predicate predicate = Predicates.alwaysTrue(); + + public ActionDropItem(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + BlockPos secretLocation = target.getBlockPos(dungeonRoom); + List item = dungeonRoom.getContext().getWorld().getEntitiesWithinAABB(EntityItem.class, + AxisAlignedBB.fromBounds( + secretLocation.getX(), + secretLocation.getY(), + secretLocation.getZ(), + secretLocation.getX() + 1, + secretLocation.getY() + 1, + secretLocation.getZ() + 1)); + if (item.isEmpty()) { + return false; + } + return (predicate == null || predicate.apply(item.get(0))); + } + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, new Color(0, 255, 255, 50), partialTicks, true); + RenderUtils.drawTextAtWorld("Drop Item", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); + } + + + @Override + public String toString() { + return "DropItem\n- target: " + target.toString() + "\n- predicate: " + predicate.getClass().getSimpleName(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionInteract.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionInteract.java new file mode 100755 index 00000000..b41e1b7a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionInteract.java @@ -0,0 +1,89 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonActionContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.entity.Entity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; + +import java.awt.*; +import java.util.HashSet; +import java.util.Set; +import java.util.function.Predicate; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionInteract extends AbstractAction { + private Set preRequisite = new HashSet<>(); + private OffsetPoint target; + private Predicate predicate = entity -> false; + private int radius; + + public ActionInteract(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return interacted; + } + + private boolean interacted = false; + @Override + public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRouteProperties actionRouteProperties) { + if (interacted) return; + + Vec3 spawnLoc = DungeonActionContext.getSpawnLocation().get(event.getEntity().getEntityId()); + if (spawnLoc == null) { + return; + } + if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) { + return; + } + if (!predicate.test(event.getEntity())) { + return; + } + interacted = true; + } + + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); + RenderUtils.drawTextAtWorld("Interact", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); + } + + @Override + public String toString() { + return "InteractEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate.test(null) ? "null" : predicate.getClass().getSimpleName()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionKill.java new file mode 100755 index 00000000..94569ad1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionKill.java @@ -0,0 +1,90 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonActionContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.entity.Entity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; +import net.minecraftforge.event.entity.living.LivingDeathEvent; + +import java.awt.*; +import java.util.HashSet; +import java.util.Set; +import java.util.function.Predicate; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionKill extends AbstractAction { + private Set preRequisite = new HashSet(); + private OffsetPoint target; + private Predicate predicate = entity -> false; + private int radius; + + public ActionKill(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + Vec3 spawn = new Vec3(target.getBlockPos(dungeonRoom)); + for (Integer killed : DungeonActionContext.getKilleds()) { + if (DungeonActionContext.getSpawnLocation().get(killed) == null) continue; + if (DungeonActionContext.getSpawnLocation().get(killed).squareDistanceTo(spawn) < 100) { + return true; + } + } + + return killed; + } + + private boolean killed = false; + @Override + public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRouteProperties actionRouteProperties) { + if (killed) return; + + Vec3 spawnLoc = DungeonActionContext.getSpawnLocation().get(event.entity.getEntityId()); + if (spawnLoc == null) return; + if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) return; + if (!predicate.test(event.entity)) return; + killed = true; + } + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); + RenderUtils.drawTextAtWorld("Spawn", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); + } + + @Override + public String toString() { + return "KillEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate.test(null) ? "null" : predicate.getClass().getSimpleName()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionMove.java new file mode 100755 index 00000000..f499032d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionMove.java @@ -0,0 +1,122 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.client.Minecraft; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionMove extends AbstractAction { + private Set preRequisite = new HashSet<>(); + private OffsetPoint target; + + public ActionMove(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 25; + } + + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + draw(dungeonRoom, partialTicks, actionRouteProperties, flag, target, poses); + } + + static void draw(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag, OffsetPoint target, List poses) { + BlockPos pos = target.getBlockPos(dungeonRoom); + + float distance = MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())); + float multiplier = distance / 120f; //mobs only render ~120 blocks away + if (flag) multiplier *= 2.0f; + float scale = 0.45f * multiplier; + scale *= 25.0 / 6.0; + if (actionRouteProperties.isBeacon()) { + if(!FeatureRegistry.RENDER_BREACONS.isEnabled()){ + RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), actionRouteProperties.getBeaconBeamColor(), partialTicks); + } + RenderUtils.highlightBlock(pos, actionRouteProperties.getBeaconColor(), partialTicks); + } + if(!FeatureRegistry.RENDER_DESTENATION_TEXT.isEnabled()){ + RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); + } + RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); + + if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !FeatureRegistry.SECRET_TOGGLE_KEY.togglePathfindStatus) { + if (poses != null){ + RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); + } + } + } + + private int tick = -1; + private List poses; + private Future> latestFuture; + + @Override + public void onTick(DungeonRoom dungeonRoom, ActionRouteProperties actionRouteProperties) { + tick = (tick+1) % Math.max(1, actionRouteProperties.getLineRefreshRate()); + if (latestFuture != null && latestFuture.isDone()) { + try { + poses = latestFuture.get(); + latestFuture = null; + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + + if (tick == 0 && actionRouteProperties.isPathfind() && latestFuture == null) { + if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() || poses == null) { + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); + } + } + } + + public void forceRefresh(DungeonRoom dungeonRoom) { + if (latestFuture == null) { + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); + } + } + @Override + public String toString() { + return "Move\n- target: "+target.toString(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionMoveNearestAir.java new file mode 100755 index 00000000..54e8b1a8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionMoveNearestAir.java @@ -0,0 +1,92 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.client.Minecraft; +import net.minecraft.util.Vec3; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionMoveNearestAir extends AbstractAction { + private Set preRequisite = new HashSet<>(); + private OffsetPoint target; + + public ActionMoveNearestAir(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return target.getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) < 25; + } + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRouteProperties actionRouteProperties, boolean flag) { + ActionMove.draw(dungeonRoom, partialTicks, actionRouteProperties, flag, target, poses); + } + + private int tick = -1; + private List poses; + private Future> latestFuture; + @Override + public void onTick(DungeonRoom dungeonRoom, ActionRouteProperties actionRouteProperties) { + tick = (tick+1) % Math.max(1, actionRouteProperties.getLineRefreshRate()); + if (latestFuture != null && latestFuture.isDone()) { + try { + poses = latestFuture.get(); + latestFuture = null; + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + + if (tick == 0 && actionRouteProperties.isPathfind() && latestFuture == null) { + if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() || poses == null) { + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); + } + } + } + + + public void forceRefresh(DungeonRoom dungeonRoom) { + if (latestFuture == null) { + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); + } + } + @Override + public String toString() { + return "MoveNearestAir\n- target: "+target.toString(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionRoot.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionRoot.java new file mode 100755 index 00000000..23b9fdce --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/ActionRoot.java @@ -0,0 +1,47 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.HashSet; +import java.util.Set; + +@Data +@EqualsAndHashCode(callSuper=false) +public class ActionRoot extends AbstractAction { + private Set preRequisite = new HashSet<>(); + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return true; + } + + @Override + public String toString() { + return "Action Root"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionRoute.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionRoute.java new file mode 100644 index 00000000..17cea18d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionRoute.java @@ -0,0 +1,136 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.util.List; + +public class ActionRoute { + @Getter + private final String mechanic; + @Getter + private final String state; + + @Getter + private int current; + @Getter + private final List actions; + + private final DungeonRoom dungeonRoom; + + @Getter + private final ActionRouteProperties actionRouteProperties; + + public ActionRoute(DungeonRoom dungeonRoom, String mechanic, String state, ActionRouteProperties actionRouteProperties) { + this.mechanic = mechanic; + this.state = state; + this.actionRouteProperties = actionRouteProperties; + + System.out.println("Creating Action Route with mechanic:" + mechanic + " State:" + state); + ActionChangeState actionChangeState = new ActionChangeState(mechanic, state); + ActionTree tree= ActionTree.buildActionTree(actionChangeState, dungeonRoom); + actions = ActionTreeUtil.linearifyActionTree(tree); + actions.add(new ActionComplete()); + ChatTransmitter.sendDebugChat("Created ActionRoute with " + actions.size() + " steps"); + ChatTransmitter.sendDebugChat("========== STEPS =========="); + for (AbstractAction action : actions) { + ChatTransmitter.sendDebugChat(action.toString()); + } + ChatTransmitter.sendDebugChat("=========== END ==========="); + + + current = 0; + this.dungeonRoom = dungeonRoom; + } + + public AbstractAction next() { + current ++; + if (current >= actions.size()) { + current = actions.size() - 1; + } + return getCurrentAction(); + } + + public AbstractAction prev() { + current --; + if (current < 0) { + current = 0; + } + return getCurrentAction(); + } + + public AbstractAction getCurrentAction() { + return actions.get(current); + } + + + + public void onPlayerInteract(PlayerInteractEvent event) { + getCurrentAction().onPlayerInteract(dungeonRoom, event, actionRouteProperties ); + } + public void onLivingDeath(LivingDeathEvent event) { + getCurrentAction().onLivingDeath(dungeonRoom, event, actionRouteProperties ); + } + public void onRenderWorld(float partialTicks, boolean flag) { + + if (current -1 >= 0) { + AbstractAction abstractAction = actions.get(current - 1); + if(((abstractAction instanceof ActionMove && ((ActionMove) abstractAction).getTarget().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) >= 25) + || (abstractAction instanceof ActionMoveNearestAir && ((ActionMoveNearestAir) abstractAction).getTarget().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) >= 25))){ + abstractAction.onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag ); + } + } + getCurrentAction().onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag); + + + getCurrentAction().onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag); + } + + public void onRenderScreen(float partialTicks) { + getCurrentAction().onRenderScreen(dungeonRoom, partialTicks, actionRouteProperties); + } + + public void onTick() { + AbstractAction currentAction = getCurrentAction(); + + currentAction.onTick(dungeonRoom, actionRouteProperties); + if (this.current -1 >= 0 && (actions.get(this.current-1) instanceof ActionMove || actions.get(this.current-1) instanceof ActionMoveNearestAir)) actions.get(this.current-1).onTick(dungeonRoom, actionRouteProperties ); + + if (dungeonRoom.getMechanics().get(mechanic).getCurrentState(dungeonRoom).equals(state)) { + this.current = actions.size() - 1; + } + + if (currentAction.isComplete(dungeonRoom)) { + next(); + } + } + + public void onLivingInteract(PlayerInteractEntityEvent event) { + getCurrentAction().onLivingInteract(dungeonRoom, event, actionRouteProperties ); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionRouteProperties.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionRouteProperties.java new file mode 100644 index 00000000..df32e718 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionRouteProperties.java @@ -0,0 +1,16 @@ +package kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import lombok.Data; + +@Data +public class ActionRouteProperties { + private boolean pathfind; + private int lineRefreshRate; + private AColor lineColor; + private float lineWidth; + + private boolean beacon; + private AColor beaconColor; + private AColor beaconBeamColor; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionTree.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionTree.java new file mode 100755 index 00000000..99846fc7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionTree.java @@ -0,0 +1,94 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionRoot; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +@Data +public class ActionTree implements Cloneable { + @EqualsAndHashCode.Exclude + private Set parent; + private AbstractAction current; + private Set children; + + @Override + public int hashCode() { return current == null ? 0 : current.hashCode(); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ActionTree that = (ActionTree) o; + return Objects.equals(parent, that.parent) && Objects.equals(current, that.current) && Objects.equals(children, that.children); + } + + public static ActionTree buildActionTree(Set actions, DungeonRoom dungeonRoom) { + ActionRoot root = new ActionRoot(); + root.setPreRequisite(actions); + ActionTree tree = new ActionTree(); + tree.setParent(new HashSet<>()); + tree.setCurrent(root); + HashSet set = new HashSet<>(); + for (AbstractAction action : actions) { + set.add(buildActionTree(tree, action, dungeonRoom, new HashMap<>())); + } + tree.setChildren(set); + return tree; + } + public static ActionTree buildActionTree(AbstractAction actions, DungeonRoom dungeonRoom) { + return buildActionTree(null, actions, dungeonRoom, new HashMap<>()); + } + + + + private static ActionTree buildActionTree(ActionTree parent, @NotNull AbstractAction action,@NotNull DungeonRoom dungeonRoom, @NotNull Map alreadyBuilt) { + if (alreadyBuilt.containsKey(action)) { + ActionTree tree = alreadyBuilt.get(action); + tree.getParent().add(parent); + return tree; + } + + ActionTree tree = new ActionTree(); + alreadyBuilt.put(action, tree); + tree.setParent(new HashSet<>()); + if (parent != null) { + tree.getParent().add(parent); + } + tree.setCurrent(action); + HashSet set = new HashSet<>(); + + Set preRequisites = action.getPreRequisites(dungeonRoom); + if(preRequisites != null){ + for (AbstractAction action2 : preRequisites) { + ActionTree e = buildActionTree(tree, action2, dungeonRoom, alreadyBuilt); + set.add(e); + } + } + + tree.setChildren(set); + return tree; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionTreeUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionTreeUtil.java new file mode 100644 index 00000000..18c17c17 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/actions/tree/ActionTreeUtil.java @@ -0,0 +1,83 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; + +import java.util.*; + +public class ActionTreeUtil { + public static List linearifyActionTree(ActionTree input) { + ActionTree tree = copyActionTree(input); + + List actions = new ArrayList(); + + int plsHalt = 0; + while (tree.getChildren().size() != 0) { + plsHalt ++; + if (plsHalt > 1000000) throw new IllegalStateException("Linearifying process ran for 1 million cycle"); + Set visited = new HashSet(); + ActionTree curr = tree; + + int plsHalt2 = 0; + while (curr.getChildren().size() != 0) { + plsHalt2 ++; + if (plsHalt2 > 1000000) throw new IllegalStateException("Finding the leaf of tree ran for 1 million cycles"); + if (visited.contains(curr)) throw new IllegalStateException("Circular Reference Detected"); + visited.add(curr); + curr = curr.getChildren().iterator().next(); + } + + plsHalt2 =0; + while(curr.getChildren().size() == 0) { + plsHalt2 ++; + if (plsHalt2 > 1000000) throw new IllegalStateException("Building of array ran for 1 million cycles"); + + actions.add(curr.getCurrent()); + if (curr.getParent().size() == 0) break; + for (ActionTree parentTree:curr.getParent()) + parentTree.getChildren().remove(curr); + curr = curr.getParent().iterator().next(); + } + } + return actions; + } + + public static ActionTree copyActionTree(ActionTree tree) { + Map built = new HashMap(); + if (tree.getParent().size() != 0) throw new IllegalArgumentException("that is not head of tree"); + return copyActionTree(tree, built); + } + private static ActionTree copyActionTree(ActionTree tree, Map preBuilts) { + if (preBuilts.containsKey(tree)) return preBuilts.get(tree); + + ActionTree clone = new ActionTree(); + preBuilts.put(tree, clone); + + clone.setCurrent(tree.getCurrent()); + clone.setParent(new HashSet()); + clone.setChildren(new HashSet()); + for (ActionTree tree3 : tree.getChildren()) { + ActionTree clone3 = copyActionTree(tree3, preBuilts); + clone3.getParent().add(clone); + clone.getChildren().add(clone3); + } + return clone; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonDoor.java new file mode 100755 index 00000000..15004dcc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonDoor.java @@ -0,0 +1,87 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder; + +import com.google.common.collect.Sets; +import lombok.Getter; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import java.util.Set; + +@Getter +public class DungeonDoor { + private final World w; + private final BlockPos position; + private final EDungeonDoorType type; + private boolean isZDir; + + private static final Set legalBlocks = Sets.newHashSet(Blocks.coal_block, Blocks.barrier, Blocks.monster_egg, Blocks.air, Blocks.stained_hardened_clay); + + public DungeonDoor(World world, BlockPos pos, EDungeonDoorType type) { + this.w = world; + this.position = pos; + Block itshouldbeall = world.getChunkFromBlockCoords(pos).getBlock(pos); + + if (type == EDungeonDoorType.WITHER && itshouldbeall == Blocks.air) type = EDungeonDoorType.WITHER_FAIRY; + this.type = type; + boolean exist = type.isExist(); + + for (int x = -1; x<=1; x++) { + for (int y = -1; y<=1; y++) { + for (int z = -1; z<=1; z++) { + BlockPos pos2 = pos.add(x,y,z); + Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); + if (itshouldbeall != block) exist = false; + } + } + } + if (exist) { + BlockPos ZCheck = pos.add(0,0,2); + isZDir = world.getChunkFromBlockCoords(ZCheck).getBlock(ZCheck) == Blocks.air; + + if (isZDir) { + for (int x = -1; x<=1; x++) { + for (int y = -1; y<=1; y++) { + for (int z = -2; z<=2; z+=4) { + BlockPos pos2 = pos.add(x,y,z); + Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); + if (block != Blocks.air) exist = false; + } + } + } + } else { + for (int x = -2; x<=2; x+=4) { + for (int y = -1; y<=1; y++) { + for (int z = -1; z<=1; z++) { + BlockPos pos2 = pos.add(x,y,z); + Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); + if (block != Blocks.air) exist = false; + } + } + } + } + } + if (!exist) { + isZDir = false; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonSpecificDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonSpecificDataProvider.java new file mode 100755 index 00000000..b34986eb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonSpecificDataProvider.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessor; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import javax.vecmath.Vector2d; + +public interface DungeonSpecificDataProvider { + + BlockPos findDoor(World w, String dungeonName); + + Vector2d findDoorOffset(World w, String dungeonName); + BossfightProcessor createBossfightProcessor(World w, String dungeonName); + + boolean isTrapSpawn(String dungeonName); + + double secretPercentage(String dungeonName); + + int speedSecond(String dungeonName); +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java new file mode 100755 index 00000000..48b24120 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/DungeonSpecificDataProviderRegistry.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder; + +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.catacombs.impl.NormalModeDataProvider; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.catacombs.impl.MasterModeDataProvider; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + +public class DungeonSpecificDataProviderRegistry { + public static final Map doorFinders = new HashMap<>(); + + static { + doorFinders.put(Pattern.compile("The Catacombs (?:F[0-9]|E)"), new NormalModeDataProvider()); + doorFinders.put(Pattern.compile("The Catacombs (?:M[0-9])"), new MasterModeDataProvider()); + } + + public static DungeonSpecificDataProvider getDoorFinder(String dungeonName) { + for (Map.Entry doorFinderEntry :doorFinders.entrySet()){ + if (doorFinderEntry.getKey().matcher(dungeonName).matches()) return doorFinderEntry.getValue(); + } + return null; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/EDungeonDoorType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/EDungeonDoorType.java new file mode 100644 index 00000000..05915a1a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/EDungeonDoorType.java @@ -0,0 +1,38 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum EDungeonDoorType { + NONE(false, false, false,"?"), ENTRANCE(true, false, false, "entrance"), + WITHER(true, true,true,"withergate"), + WITHER_FAIRY(true, false,true,"wither-fairy-gate"), + BLOOD(true, true,true, "bloodgate"), + UNOPEN(true, false, false,"gate"); + + + private final boolean exist; + private final boolean keyRequired; + private final boolean headToBlood; + private final String name; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/CatacombsDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/CatacombsDataProvider.java new file mode 100644 index 00000000..b9052353 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/CatacombsDataProvider.java @@ -0,0 +1,75 @@ +package kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.catacombs; + +import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonSpecificDataProvider; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +import javax.vecmath.Vector2d; +import java.util.Collection; +import java.util.Set; + +public abstract class CatacombsDataProvider implements DungeonSpecificDataProvider { + + private static final Set directions = Sets.newHashSet(new Vector2d(0,1), new Vector2d(0, -1), new Vector2d(1, 0), new Vector2d(-1 , 0)); + + @Nullable + static Vector2d getVector2d(World w, Collection armorStand, Set directions) { + EntityArmorStand mort = armorStand.iterator().next(); + BlockPos pos = mort.getPosition(); + pos = pos.add(0, 3, 0); + for (int i = 0; i < 5; i++) { + for (Vector2d vector2d: directions) { + BlockPos test = pos.add(vector2d.x * i, 0, vector2d.y * i); + if (w.getChunkFromBlockCoords(test).getBlock(test) == Blocks.iron_bars) { + return vector2d; + } + } + } + return null; + } + + public static Collection getMorts(World w){ + return w.getEntities(EntityArmorStand.class, input -> input.getName().equals("ยงbMort")); + } + + /** + * This gets all morts checks for iron bars near him + * and based on iron bars determine the door location + * + * @param w World that we are going to look for the door in + * world is explicitly specified instead of mc.theWorld bc we can use cached worlds + * @param dungeonName dungeon type eg master mode, currently unused + * @return Block pos of the dungeon entrance + */ + public BlockPos findDoor(World w, String dungeonName) { + Collection armorStand = getMorts(w); + + if (!armorStand.isEmpty()) { + EntityArmorStand mort = armorStand.iterator().next(); + BlockPos pos = mort.getPosition(); + pos = pos.add(0, 3, 0); + for (int i = 0; i < 5; i++) { + for (Vector2d vector2d:directions) { + BlockPos test = pos.add(vector2d.x * i, 0, vector2d.y * i); + if (w.getChunkFromBlockCoords(test).getBlock(test) == Blocks.iron_bars) { + return pos.add(vector2d.x * (i + 2), -2, vector2d.y * (i+2)); + } + } + } + } + return null; + } + + public Vector2d findDoorOffset(World w, String dungeonName) { + Collection armorStand = getMorts(w); + + if (!armorStand.isEmpty()) { + return getVector2d(w, armorStand, directions); + } + return null; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/impl/MasterModeDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/impl/MasterModeDataProvider.java new file mode 100755 index 00000000..ab3f5df3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/impl/MasterModeDataProvider.java @@ -0,0 +1,64 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.catacombs.impl; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.catacombs.CatacombsDataProvider; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorLivid; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.World; + +public class MasterModeDataProvider extends CatacombsDataProvider { + + + @Override + public BossfightProcessor createBossfightProcessor(World w, String dungeonName) { + String floor = dungeonName.substring(14).trim(); + ChatTransmitter.sendDebugChat(new ChatComponentText("Floor: Master mode "+floor+ " Building bossfight processor")); + if (floor.equals("M5")) { + return new BossfightProcessorLivid(true); + } + return null; + } + + @Override + public boolean isTrapSpawn(String dungeonName) { + String floor = dungeonName.substring(14).trim(); + switch (floor) { + case "M3": + case "M4": + case "M5": + case "M6": + return true; + default: + return floor.equals("M7"); + } + } + + @Override + public double secretPercentage(String dungeonName) { + return 1.0; + } + + @Override + public int speedSecond(String dungeonName) { + return 480; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/impl/NormalModeDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/impl/NormalModeDataProvider.java new file mode 100755 index 00000000..880cf473 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/doorfinder/catacombs/impl/NormalModeDataProvider.java @@ -0,0 +1,101 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.catacombs.impl; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.catacombs.CatacombsDataProvider; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.*; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.World; + +public class NormalModeDataProvider extends CatacombsDataProvider { + + + @Override + public BossfightProcessor createBossfightProcessor(World w, String dungeonName) { + String floor = dungeonName.substring(14).trim(); + ChatTransmitter.sendDebugChat(new ChatComponentText("Floor: "+floor+ " Building bossfight processor")); + switch (floor) { + case "F1": + return new BossfightProcessorBonzo(); + case "F2": + return new BossfightProcessorScarf(); + case "F3": + return new BossfightProcessorProf(); + case "F4": + return new BossfightProcessorThorn(); + case "F5": + return new BossfightProcessorLivid(false); + case "F6": + return new BossfightProcessorSadan(); + case "F7": + return new BossfightProcessorNecron(); + default: + return null; + } + } + + @Override + public boolean isTrapSpawn(String dungeonName) { + String floor = dungeonName.substring(14).trim(); + switch (floor) { + case "F3": + case "F4": + case "F5": + case "F6": + return true; + default: + return floor.equals("F7"); + } + } + + @Override + public double secretPercentage(String dungeonName) { + String floor = dungeonName.substring(14).trim(); + switch (floor) { + case "F1": + case "E": + return 0.3; + case "F2": + return 0.4; + case "F3": + return 0.5; + case "F4": + return 0.6; + case "F5": + return 0.7; + case "F6": + return 0.85; + default: + return 1.0; + } + } + + @Override + public int speedSecond(String dungeonName) { + String floor = dungeonName.substring(14).trim(); + switch (floor) { + case "F5": + case "F7": + return 720; + default: + return 600; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEvent.java new file mode 100644 index 00000000..0e71a65e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEvent.java @@ -0,0 +1,41 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class DungeonEvent implements Serializable { + private long UTCTime = System.currentTimeMillis(); + private long realTimeElapsed; + private long skyblockTimeElapsed; + + private String eventName; + private DungeonEventData data; + + public DungeonEvent(DungeonEventData eventData){ + this.data = eventData; + this.realTimeElapsed = FeatureRegistry.DUNGEON_REALTIME.getTimeElapsed(); + this.skyblockTimeElapsed = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed(); + this.eventName = eventData.getEventName(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEventData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEventData.java new file mode 100644 index 00000000..812e1488 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEventData.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events; + +import java.io.Serializable; + +public interface DungeonEventData extends Serializable { + String getEventName(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEventHolder.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEventHolder.java new file mode 100644 index 00000000..58799f80 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/DungeonEventHolder.java @@ -0,0 +1,32 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Set; + +@Data +public class DungeonEventHolder implements Serializable { + private long date; + private Set players; + private List eventDataList; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/SerializableBlockPos.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/SerializableBlockPos.java new file mode 100644 index 00000000..d70ba2c2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/SerializableBlockPos.java @@ -0,0 +1,38 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.util.BlockPos; + +import java.io.Serializable; + +@Data @AllArgsConstructor +public class SerializableBlockPos implements Serializable { + private int x; + private int y; + private int z; + + public SerializableBlockPos(BlockPos pos) { + this.x = pos.getX(); + this.y = pos.getY(); + this.z = pos.getZ(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonCryptBrokenEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonCryptBrokenEvent.java new file mode 100644 index 00000000..c2a4f71e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonCryptBrokenEvent.java @@ -0,0 +1,35 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events.impl; + +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class DungeonCryptBrokenEvent implements DungeonEventData { + private int prevCrypts; + private int newCrypts; + + @Override + public String getEventName() { + return "CRYPTS_CHANGE"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonDeathEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonDeathEvent.java new file mode 100644 index 00000000..09877b80 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonDeathEvent.java @@ -0,0 +1,36 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events.impl; + +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class DungeonDeathEvent implements DungeonEventData { + private String playerName; + private String message; + private int cnt; + + @Override + public String getEventName() { + return "PLAYER_DEATH"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonMapUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonMapUpdateEvent.java new file mode 100644 index 00000000..023902c8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonMapUpdateEvent.java @@ -0,0 +1,34 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events.impl; + +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class DungeonMapUpdateEvent implements DungeonEventData { + private byte[] map; + + @Override + public String getEventName() { + return "MAP_UPDATE"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonNodataEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonNodataEvent.java new file mode 100644 index 00000000..531f5990 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonNodataEvent.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events.impl; + +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class DungeonNodataEvent implements DungeonEventData { + private String eventName; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonPuzzleFailureEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonPuzzleFailureEvent.java new file mode 100644 index 00000000..64621339 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonPuzzleFailureEvent.java @@ -0,0 +1,34 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events.impl; + +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class DungeonPuzzleFailureEvent implements DungeonEventData { + private String playerName; + private String message; + @Override + public String getEventName() { + return "PUZZLE_FAILURE"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonRoomDiscoverEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonRoomDiscoverEvent.java new file mode 100644 index 00000000..09fd64a5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonRoomDiscoverEvent.java @@ -0,0 +1,46 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events.impl; + +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.SerializableBlockPos; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.awt.*; +import java.util.UUID; + +@Data +@AllArgsConstructor +public class DungeonRoomDiscoverEvent implements DungeonEventData { + private Point unitPt; + private int rotation; + private SerializableBlockPos min; + private SerializableBlockPos max; + private int shape; + private int color; + private UUID roomUID; + private String roomName; + private String roomProc; + + @Override + public String getEventName() { + return "ROOM_DISCOVER"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonSecretCountChangeEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonSecretCountChangeEvent.java new file mode 100644 index 00000000..21ea853c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonSecretCountChangeEvent.java @@ -0,0 +1,37 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events.impl; + +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class DungeonSecretCountChangeEvent implements DungeonEventData { + private int prevCount; + private int newCount; + private int totalSecret; + private boolean sureTotalSecret; + + @Override + public String getEventName() { + return "SECRET_CNT_CHANGE"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonStateChangeEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonStateChangeEvent.java new file mode 100644 index 00000000..f1cb1167 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/events/impl/DungeonStateChangeEvent.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.events.impl; + +import kr.syeyoung.dungeonsguide.mod.dungeon.events.DungeonEventData; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.awt.*; + +@Data +@AllArgsConstructor +public class DungeonStateChangeEvent implements DungeonEventData { + private Point unitPt; + private String roomName; + private DungeonRoom.RoomState from; + private DungeonRoom.RoomState to; + + @Override + public String getEventName() { + return "ROOM_STATE_CHANGE"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/map/DungeonMapData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/map/DungeonMapData.java new file mode 100644 index 00000000..9687d554 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/map/DungeonMapData.java @@ -0,0 +1,121 @@ +package kr.syeyoung.dungeonsguide.mod.dungeon.map; + +import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.MapProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonSpecificDataProvider; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonSpecificDataProviderRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonNodataEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.DungeonContextInitializationEvent; +import kr.syeyoung.dungeonsguide.mod.utils.MapUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.common.MinecraftForge; + +import javax.vecmath.Vector2d; +import java.awt.*; +import java.util.Set; + +public class DungeonMapData { + private static final Set directions = Sets.newHashSet(new Vector2d(0, 1), new Vector2d(0, -1), new Vector2d(1, 0), new Vector2d(-1, 0)); + private static final Set door_dirs = Sets.newHashSet(new Vector2d(0, 0.5), new Vector2d(0, -0.5), new Vector2d(0.5, 0), new Vector2d(-0.5, 0)); + public Dimension unitRoomDimension; + public boolean bugged; + public Dimension doorDimensions; + public Point topLeftMapPoint; + private final DungeonContext context; + private final Minecraft mc; + public boolean initialized; + + public DungeonMapData(DungeonContext context, Minecraft mc) { + this.context = context; + this.mc = mc; + } + + + public void eat(final byte[] mapData){ + final Point firstRoom = MapUtils.findFirstColorWithIn(mapData, (byte) 30, new Rectangle(0, 0, 128, 128)); + // Determine room dimension + int width = MapUtils.getWidthOfColorAt(mapData, (byte) 30, firstRoom); + int height = MapUtils.getHeightOfColorAt(mapData, (byte) 30, firstRoom); + unitRoomDimension = new Dimension(width, height); + Vector2d doorDir = null; + Point midfirstRoom = new Point(firstRoom.x + unitRoomDimension.width / 2, firstRoom.y + unitRoomDimension.height / 2); + final int halfWidth = unitRoomDimension.width / 2 + 2; + for (Vector2d v : directions) { + byte color = MapUtils.getMapColorAt(mapData, (int) (v.x * halfWidth + midfirstRoom.x), (int) (v.y * halfWidth + midfirstRoom.y)); + if (color != 0) { + doorDir = v; + break; + } + } + + if (doorDir == null) { + bugged = true; + return; + } + + Point basePoint = new Point(firstRoom.x, firstRoom.y); + if (doorDir.x > 0) basePoint.x += unitRoomDimension.width; + if (doorDir.x < 0) basePoint.x -= 1; + if (doorDir.y > 0) basePoint.y += unitRoomDimension.height; + if (doorDir.y < 0) basePoint.y -= 1; + int gap = MapUtils.getLengthOfColorExtending(mapData, (byte) 0, basePoint, doorDir); + Point pt = MapUtils.findFirstColorWithInNegate(mapData, (byte) 0, new Rectangle(basePoint.x, basePoint.y, (int) Math.abs(doorDir.y) * unitRoomDimension.width + 1, (int) Math.abs(doorDir.x) * unitRoomDimension.height + 1)); + if (pt == null) { + bugged = true; + return; + } + int doorWidth = MapUtils.getLengthOfColorExtending(mapData, MapUtils.getMapColorAt(mapData, pt.x, pt.y), pt, new Vector2d((int) Math.abs(doorDir.y), (int) Math.abs(doorDir.x))); + doorDimensions = new Dimension(doorWidth, gap); + + // Determine Top Left + int topLeftX = firstRoom.x; + int topLeftY = firstRoom.y; + while (topLeftX >= unitRoomDimension.width + doorDimensions.height) + topLeftX -= unitRoomDimension.width + doorDimensions.height; + while (topLeftY >= unitRoomDimension.height + doorDimensions.height) + topLeftY -= unitRoomDimension.height + doorDimensions.height; + topLeftMapPoint = new Point(topLeftX, topLeftY); + // determine door location based on npc, and determine map min from there + DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(DungeonContext.getDungeonName()); + if (doorFinder == null) { + bugged = true; + return; + } + BlockPos door = doorFinder.findDoor(mc.theWorld, DungeonContext.getDungeonName()); + if (door == null) { + bugged = true; + return; + } + + ChatTransmitter.sendDebugChat(new ChatComponentText("door Pos:" + door)); + + Point unitPoint = MapProcessor.mapPointToRoomPoint(firstRoom, topLeftMapPoint, unitRoomDimension, doorDimensions); + unitPoint.translate(unitPoint.x + 1, unitPoint.y + 1); + unitPoint.translate((int) doorDir.x, (int) doorDir.y); + + Vector2d offset = doorFinder.findDoorOffset(mc.theWorld, DungeonContext.getDungeonName()); + boolean axisMatch = doorDir.equals(offset); + + int worldX = unitPoint.x * 16; + int worldY = unitPoint.y * 16; + BlockPos worldMin = door.add(-worldX, 0, -worldY); + context.setDungeonMin(worldMin); + + ChatTransmitter.sendDebugChat(new ChatComponentText("Found Green room:" + firstRoom)); + ChatTransmitter.sendDebugChat(new ChatComponentText("Axis match:" + axisMatch)); + ChatTransmitter.sendDebugChat(new ChatComponentText("World Min:" + context.getDungeonMin())); + ChatTransmitter.sendDebugChat(new ChatComponentText("Dimension:" + unitRoomDimension)); + ChatTransmitter.sendDebugChat(new ChatComponentText("top Left:" + topLeftMapPoint)); + ChatTransmitter.sendDebugChat(new ChatComponentText("door dimension:" + doorDimensions)); + context.createEvent(new DungeonNodataEvent("MAP_PROCESSOR_INIT")); + initialized = true; + MinecraftForge.EVENT_BUS.post(new DungeonContextInitializationEvent()); + + + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/AStarCornerCut.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/AStarCornerCut.java new file mode 100644 index 00000000..f6ac1777 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/AStarCornerCut.java @@ -0,0 +1,189 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.minecraft.util.*; +import net.minecraft.world.World; + +import java.util.*; + +public class AStarCornerCut { + private final BlockPos min, max; + private final World world; + + int lastSx, lastSy, lastSz; + final int dx, dy, dz; + private DungeonRoom dungeonRoom; + + @Getter + private AxisAlignedBB destinationBB; + + public AStarCornerCut(DungeonRoom dungeonRoom, Vec3 destination) { + this.min = new BlockPos(dungeonRoom.getMinx(), 0, dungeonRoom.getMinz()); + this.max = new BlockPos(dungeonRoom.getMaxx(), 255, dungeonRoom.getMaxz()); + + this.world = dungeonRoom.getCachedWorld(); + this.dungeonRoom = dungeonRoom; + + this.dx = (int) (destination.xCoord * 2); + this.dy = (int) (destination.yCoord * 2); + this.dz = (int) (destination.zCoord * 2); + destinationBB = AxisAlignedBB.fromBounds(dx-2, dy-2, dz-2, dx+2, dy+2, dz+2); + } + + private Map nodeMap = new HashMap<>(); + + private Node openNode(int x, int y, int z) + { + Node.Coordinate coordinate = new Node.Coordinate(x,y,z); + Node node = this.nodeMap.get(coordinate); + + if (node == null) + { + node = new Node(coordinate); + this.nodeMap.put(coordinate, node); + } + + return node; + } + + @Getter + private LinkedList route = new LinkedList<>(); + + @Getter + private PriorityQueue open = new PriorityQueue<>(Comparator.comparing((Node a) -> a == null ? Float.MAX_VALUE : a.f).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.x).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.y).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.z)); + + private int pfindIdx = 0; + + public boolean pathfind(Vec3 from, long timeout) { + pfindIdx ++; + if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) + open.clear(); + + this.lastSx = (int) Math.round(from.xCoord * 2); + this.lastSy = (int) Math.round(from.yCoord * 2); + this.lastSz = (int) Math.round(from.zCoord * 2); + + Node startNode = openNode(dx, dy, dz); + Node goalNode = openNode(lastSx, lastSy, lastSz); + + if (goalNode.parent != null) { + LinkedList route = new LinkedList<>(); + Node curr =goalNode; + while(curr.parent != null) { + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + curr = curr.parent; + } + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + this.route = route; + return true; + } + + startNode.g = 0; + startNode.f = 0; + goalNode.g = Integer.MAX_VALUE; goalNode.f = Integer.MAX_VALUE; + + + open.add(startNode); + + long end = System.currentTimeMillis() + timeout; + + while (!open.isEmpty()) { + if (System.currentTimeMillis() > end) { + return false; + } + + Node n = open.poll(); + if (n.lastVisited == pfindIdx) continue; + n.lastVisited = pfindIdx; + + if (n == goalNode) { + // route = reconstructPath(startNode) + LinkedList route = new LinkedList<>(); + Node curr =goalNode; + while(curr.parent != null) { + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + curr = curr.parent; + } + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + this.route = route; + return true; + } + + for (int z = -1; z <= 1; z++) {for (int y = -1; y <= 1; y ++) { for(int x = -1; x <= 1; x++) { + if (x == 0 && y == 0 && z == 0) continue; + Node neighbor = openNode(n.coordinate.x +x, n.coordinate.y +y, n.coordinate.z + z); + + // check blocked. + if (!((destinationBB.minX <= neighbor.coordinate.x && neighbor.coordinate.x <= destinationBB.maxX && + destinationBB.minY <= neighbor.coordinate.y && neighbor.coordinate.y <= destinationBB.maxY && + destinationBB.minZ <= neighbor.coordinate.z && neighbor.coordinate.z <= destinationBB.maxZ) // near destination + || !dungeonRoom.isBlocked(neighbor.coordinate.x, neighbor.coordinate.y, neighbor.coordinate.z))) { // not blocked + continue; + } + if (neighbor.lastVisited == pfindIdx) continue; + + + float gScore = n.g + MathHelper.sqrt_float(x*x + y*y + z*z); // altho it's sq, it should be fine + if (gScore < neighbor.g ) { + neighbor.parent = n; + neighbor.g = gScore; + neighbor.f = gScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); + open.add(neighbor); + } else if (neighbor.lastVisited != pfindIdx) { + neighbor.f = gScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); + open.add(neighbor); + } + }}} + } + return true; + } + + private int manhatten(int x, int y, int z) {return Math.abs(x)+ Math.abs(y)+ Math.abs(z);} + private float distSq(float x, float y, float z) { + return MathHelper.sqrt_float(x * x + y * y + z * z); + } + + @RequiredArgsConstructor + @Data + public static final class Node { + @Data + @RequiredArgsConstructor + public static final class Coordinate { + private final int x, y, z; + } + private final Coordinate coordinate; + + private float f = Float.MAX_VALUE, g = Float.MAX_VALUE; + private int lastVisited; + + @EqualsAndHashCode.Exclude + private Node parent; + + public static long makeHash(int x, int y, int z) + { + return y & 32767L | ((short)x & 32767L) << 16 | ((short)z & 32767L) << 32; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/AStarFineGrid.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/AStarFineGrid.java new file mode 100644 index 00000000..8cb49a10 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/AStarFineGrid.java @@ -0,0 +1,182 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.minecraft.util.*; +import net.minecraft.world.World; + +import java.util.*; + +public class AStarFineGrid { + private final BlockPos min, max; + private final World world; + + int lastSx, lastSy, lastSz; + final int dx, dy, dz; + private DungeonRoom dungeonRoom; + + @Getter + private AxisAlignedBB destinationBB; + + public AStarFineGrid(DungeonRoom dungeonRoom, Vec3 destination) { + this.min = new BlockPos(dungeonRoom.getMinx(), 0, dungeonRoom.getMinz()); + this.max = new BlockPos(dungeonRoom.getMaxx(), 255, dungeonRoom.getMaxz()); + + this.world = dungeonRoom.getCachedWorld(); + this.dungeonRoom = dungeonRoom; + + this.dx = (int) (destination.xCoord * 2); + this.dy = (int) (destination.yCoord * 2); + this.dz = (int) (destination.zCoord * 2); + destinationBB = AxisAlignedBB.fromBounds(dx-2, dy-2, dz-2, dx+2, dy+2, dz+2); + } + + private Map nodeMap = new HashMap<>(); + + private Node openNode(int x, int y, int z) + { + Node.Coordinate coordinate = new Node.Coordinate(x,y,z); + Node node = this.nodeMap.get(coordinate); + + if (node == null) + { + node = new Node(coordinate); + this.nodeMap.put(coordinate, node); + } + + return node; + } + + @Getter + private LinkedList route = new LinkedList<>(); + + @Getter + private PriorityQueue open = new PriorityQueue<>(Comparator.comparing((Node a) -> a == null ? Float.MAX_VALUE : a.f).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.x).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.y).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.z)); + + private int pfindIdx = 0; + + public boolean pathfind(Vec3 from, long timeout) { + pfindIdx ++; + if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) + open.clear(); + + this.lastSx = (int) Math.round(from.xCoord * 2); + this.lastSy = (int) Math.round(from.yCoord * 2); + this.lastSz = (int) Math.round(from.zCoord * 2); + + Node startNode = openNode(dx, dy, dz); + Node goalNode = openNode(lastSx, lastSy, lastSz); + startNode.g = 0; + startNode.f = 0; + goalNode.g = Integer.MAX_VALUE; goalNode.f = Integer.MAX_VALUE; + if (goalNode.parent != null) { + LinkedList route = new LinkedList<>(); + Node curr =goalNode; + while(curr.parent != null) { + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + curr = curr.parent; + } + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + this.route = route; + return true; + } + open.add(startNode); + + long end = System.currentTimeMillis() + timeout; + + while (!open.isEmpty()) { + if (System.currentTimeMillis() > end) { + return false; + } + + Node n = open.poll(); + if (n.lastVisited == pfindIdx) continue; + n.lastVisited = pfindIdx; + + if (n == goalNode) { + // route = reconstructPath(startNode) + LinkedList route = new LinkedList<>(); + Node curr =goalNode; + while(curr.parent != null) { + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + curr = curr.parent; + } + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + this.route = route; + return true; + } + + for (EnumFacing value : EnumFacing.VALUES) { + Node neighbor = openNode(n.coordinate.x + value.getFrontOffsetX(), n.coordinate.y + value.getFrontOffsetY(), n.coordinate.z + value.getFrontOffsetZ()); + + // check blocked. + if (!((destinationBB.minX <= neighbor.coordinate.x && neighbor.coordinate.x <= destinationBB.maxX && + destinationBB.minY <= neighbor.coordinate.y && neighbor.coordinate.y <= destinationBB.maxY && + destinationBB.minZ <= neighbor.coordinate.z && neighbor.coordinate.z <= destinationBB.maxZ) // near destination + || !dungeonRoom.isBlocked(neighbor.coordinate.x, neighbor.coordinate.y, neighbor.coordinate.z))) { // not blocked + continue; + } + + float gScore = n.g + 1; // altho it's sq, it should be fine + if (gScore < neighbor.g) { + neighbor.parent = n; + neighbor.g = gScore; + neighbor.f = gScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); + open.add(neighbor); + } else if (neighbor.lastVisited != pfindIdx) { + neighbor.f = gScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); + open.add(neighbor); + } + } + } + return true; + } + + private int manhatten(int x, int y, int z) {return Math.abs(x)+ Math.abs(y)+ Math.abs(z);} + private float distSq(float x, float y, float z) { + return MathHelper.sqrt_float(x * x + y * y + z * z); + } + + @RequiredArgsConstructor + @Data + public static final class Node { + @Data + @RequiredArgsConstructor + public static final class Coordinate { + private final int x, y, z; + } + private final Coordinate coordinate; + + private float f = Float.MAX_VALUE, g = Float.MAX_VALUE; + private int lastVisited; + + @EqualsAndHashCode.Exclude + private Node parent; + + public static long makeHash(int x, int y, int z) + { + return y & 32767L | ((short)x & 32767L) << 16 | ((short)z & 32767L) << 32; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/CachedWorld.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/CachedWorld.java new file mode 100644 index 00000000..9d9644c6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/CachedWorld.java @@ -0,0 +1,85 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.*; +import net.minecraft.world.chunk.IChunkProvider; + +public class CachedWorld extends World { + private ChunkCache chunkCache; + + public CachedWorld(ChunkCache chunkCache) { + super(null, null, new WorldProviderSurface(), null, true); + this.chunkCache = chunkCache; + } + + @Override + protected IChunkProvider createChunkProvider() { + return null; + } + + @Override + protected int getRenderDistanceChunks() { + return 999; + } + + @Override + public boolean extendedLevelsInChunkCache() { + return chunkCache.extendedLevelsInChunkCache(); + } + + @Override + public TileEntity getTileEntity(BlockPos pos) { + return chunkCache.getTileEntity(pos); + } + + @Override + public int getCombinedLight(BlockPos pos, int lightValue) { + return chunkCache.getCombinedLight(pos, lightValue); + } + + @Override + public IBlockState getBlockState(BlockPos pos) { + return chunkCache.getBlockState(pos); + } + + @Override + public int getLightFor(EnumSkyBlock type, BlockPos pos) { + return chunkCache.getLightFor(type, pos); + } + + @Override + public boolean isAirBlock(BlockPos pos) { + return chunkCache.isAirBlock(pos); + } + + @Override + public int getStrongPower(BlockPos pos, EnumFacing direction) { + return chunkCache.getStrongPower(pos, direction); + } + + @Override + public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default) { + return chunkCache.isSideSolid(pos, side, _default); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/JPSPathfinder.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/JPSPathfinder.java new file mode 100644 index 00000000..0a4e1b7d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/JPSPathfinder.java @@ -0,0 +1,306 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import net.minecraft.util.*; +import net.minecraft.world.World; + +import java.util.*; + +public class JPSPathfinder { + private final BlockPos min, max; + private final World world; + + private Vec3 start; + private Vec3 destination; + private DungeonRoom dungeonRoom; + + @Getter + private AxisAlignedBB destinationBB; + + public JPSPathfinder(DungeonRoom dungeonRoom){ + this.min = new BlockPos(dungeonRoom.getMinx(), 0, dungeonRoom.getMinz()); + this.max = new BlockPos(dungeonRoom.getMaxx(), 255, dungeonRoom.getMaxz()); + + this.world = dungeonRoom.getCachedWorld(); + this.dungeonRoom = dungeonRoom; + } + + private IntHashMap nodeMap = new IntHashMap(); + + private Node openNode(int x, int y, int z) + { + int i = Node.makeHash(x, y, z); + Node node = this.nodeMap.lookup(i); + + if (node == null) + { + node = new Node(x, y, z); + this.nodeMap.addKey(i, node); + } + + return node; + } + + @Getter + private LinkedList route = new LinkedList<>(); + + @Getter + private PriorityQueue open = new PriorityQueue<>(Comparator.comparing((Node a) -> a == null ? Float.MAX_VALUE : a.f).thenComparing(a -> a == null ? Float.MAX_VALUE : a.x).thenComparing(a -> a == null ? Float.MAX_VALUE : a.y).thenComparing(a -> a == null ? Float.MAX_VALUE : a.z)); + + private int tx, ty, tz; + + private Node addNode(Node parent, Node jumpPt, boolean addToOpen) { + float ng = parent.g + distSq(jumpPt.x - parent.x, jumpPt.y - parent.y, jumpPt.z - parent.z); + + if (ng < jumpPt.g) { + if (addToOpen) + open.remove(jumpPt); + jumpPt.g = ng; + jumpPt.h = jumpPt.h == -1 ? distSq(tx - jumpPt.x, ty - jumpPt.y, tz - jumpPt.z) : jumpPt.h; + jumpPt.f = jumpPt.h + jumpPt.g; + jumpPt.parent = parent; + if (addToOpen) + open.add(jumpPt); + } + return jumpPt; + } + + + long arr[]; + + public boolean pathfind(Vec3 from, Vec3 to, float within, long timeout) { + route.clear(); nodeMap.clearMap(); + + { + from = new Vec3(((int)(from.xCoord * 2)) / 2.0, ((int)(from.yCoord * 2)) / 2.0, ((int)(from.zCoord* 2)) / 2.0); + to = new Vec3(((int)(to.xCoord * 2)) / 2.0, ((int)(to.yCoord * 2)) / 2.0, ((int)(to.zCoord* 2)) / 2.0); + } + + this.start = from; this.destination = to; + tx = (int)(to.xCoord * 2); + ty = (int)(to.yCoord * 2); + tz = (int)(to.zCoord * 2); + + destinationBB = AxisAlignedBB.fromBounds((to.xCoord - within)* 2, (to.yCoord - within) * 2, (to.zCoord - within) * 2, (to.xCoord + within) * 2, (to.yCoord + within)* 2, (to.zCoord + within) *2); + open.clear(); + Node start; + open.add(start = openNode((int)from.xCoord * 2 + 1, (int)from.yCoord * 2, (int)from.zCoord * 2+1)); + start.g = 0; start.f = 0; start.h = (float) from.squareDistanceTo(to); + + Node end = null; float minDist = Float.MAX_VALUE; + long forceEnd = System.currentTimeMillis() + timeout + 999999999L; + while(!open.isEmpty()) { + if (forceEnd < System.currentTimeMillis() && timeout != -1) break; + Node n = open.poll(); + n.closed= true; + if (minDist > n.h) { + minDist = n.h; + end = n; + } + if (n.x > destinationBB.minX && n.x < destinationBB.maxX && n.y > destinationBB.minY && n.y < destinationBB.maxY && n.z > destinationBB.minZ && n.z < destinationBB.maxZ) { + break; + } + + for (Node neighbor : getNeighbors(n.parent == null ? n : n.parent, n)) { + Node jumpPT = expand(n.x, n.y, n.z, neighbor.x - n.x, neighbor.y - n.y, neighbor.z - n.z); + if (jumpPT == null || jumpPT.closed) continue; + + addNode(n, jumpPT, true); + } + } + + if (end == null) return false; + Node p = end; + while (p != null) { + route.addLast(new Vec3(p.x / 2.0f, p.y / 2.0f + 0.1, p.z / 2.0f)); + p = p.parent; + } + + + return true; + } + + private float distSq(float x, float y, float z) { + return MathHelper.sqrt_float(x * x + y * y + z * z); + } + + public Set getNeighbors(Node prevN, Node n) { +// if (true) throw new RuntimeException("ah"); + int dx = MathHelper.clamp_int(n.x - prevN.x, -1, 1); + int dy = MathHelper.clamp_int(n.y - prevN.y, -1, 1); + int dz = MathHelper.clamp_int(n.z - prevN.z, -1, 1); + int x = n.x, y = n.y, z = n.z; + int nx = n.x + dx, ny = n.y + dy, nz = n.z + dz; + + Set nexts = new HashSet<>(); + int determinant = Math.abs(dx) + Math.abs(dy) + Math.abs(dz); + if (determinant == 0) { + for (int i = -1; i <= 1; i++) + for (int j = -1; j <= 1; j++) + for (int k = -1; k <= 1; k++) { + if (i == 0 && j == 0 && k == 0) continue; + nexts.add(openNode(x+i, y+j, z+k)); + } + } else if (determinant == 1) { + nexts.add(openNode(nx,ny,nz)); + for (int i = -1; i<=1; i++) { + for (int j = - 1; j<=1; j++) { + if (i == 0 && j == 0) continue; + if (dx != 0 && dungeonRoom.isBlocked(x, y + i, z + j)) nexts.add(openNode(nx,y+i,z+j)); + if (dy != 0 && dungeonRoom.isBlocked(x + i, y, z + j)) nexts.add(openNode(x+i,ny,z+j)); + if (dz != 0 && dungeonRoom.isBlocked(x + i, y + j, z)) nexts.add(openNode(x+i,y+j,nz)); + } + } + } else if (determinant == 2) { + if (dz != 0) nexts.add(openNode(x,y,nz)); + if (dy != 0) nexts.add(openNode(x,ny,z)); + if (dx != 0) nexts.add(openNode(nx,y,z)); + nexts.add(openNode(nx,ny,nz)); + if (dx == 0) { + if (dungeonRoom.isBlocked(x, y, z-dz)) { + nexts.add(openNode(x, ny, z-dz)); + if (dungeonRoom.isBlocked(x+1, y, z-dz)) nexts.add(openNode(x+1, ny, z-dz)); + if (dungeonRoom.isBlocked(x-1, y, z-dz)) nexts.add(openNode(x-1, ny, z-dz)); + } + if (dungeonRoom.isBlocked(x, y-dy, z)) { + nexts.add(openNode(x, y-dy, nz)); + if (dungeonRoom.isBlocked(x+1, y-dy, z)) nexts.add(openNode(x+1, y-dy, nz)); + if (dungeonRoom.isBlocked(x-1, y-dy, z)) nexts.add(openNode(x+1, y-dy, nz)); + } + } else if (dy == 0) { + if (dungeonRoom.isBlocked(x, y, z-dz)) { + nexts.add(openNode(nx, y, z-dz)); + if (dungeonRoom.isBlocked(x, y+1, z-dz)) nexts.add(openNode(nx, y+1, z-dz)); + if (dungeonRoom.isBlocked(x, y-1, z-dz)) nexts.add(openNode(nx, y-1, z-dz)); + } + if (dungeonRoom.isBlocked(x-dx, y, z)) { + nexts.add(openNode(x-dx, y, nz)); + if (dungeonRoom.isBlocked(x-dx, y+1, z)) nexts.add(openNode(x-dx, y+1, nz)); + if (dungeonRoom.isBlocked(x-dx, y-1, z)) nexts.add(openNode(x-dx, y-1, nz)); + } + } else if (dz == 0) { + if (dungeonRoom.isBlocked(x, y-dy, z)) { + nexts.add(openNode(nx, y-dy, z)); + if (dungeonRoom.isBlocked(x, y-dy, z+1)) nexts.add(openNode(nx, y-dy, z+1)); + if (dungeonRoom.isBlocked(x, y-dy, z-1)) nexts.add(openNode(nx, y-dy, z-1)); + } + if (dungeonRoom.isBlocked(x-dx, y, z)) { + nexts.add(openNode(x-dx, ny, z)); + if (dungeonRoom.isBlocked(x-dx, y, z+1)) nexts.add(openNode(x-dx, ny, z+1)); + if (dungeonRoom.isBlocked(x-dx, y, z-1)) nexts.add(openNode(x-dx, ny, z-1)); + } + } + } else if (determinant == 3) { + nexts.add(openNode(x,y,nz)); + nexts.add(openNode(x,ny,z)); + nexts.add(openNode(nx,y,z)); + nexts.add(openNode(nx,y,nz)); + nexts.add(openNode(x,ny,nz)); + nexts.add(openNode(nx,ny,z)); + nexts.add(openNode(nx,ny,nz)); + + if (dungeonRoom.isBlocked(x,y,z-dz)) { + nexts.add(openNode(x,ny,z-dz)); + nexts.add(openNode(nx,ny,z-dz)); + nexts.add(openNode(nx,y,z-dz)); + } + if (dungeonRoom.isBlocked(x-dx,y,z)) { + nexts.add(openNode(x-dx,ny,nz)); + nexts.add(openNode(x-dx,ny,z)); + nexts.add(openNode(x-dx,y,nz)); + } + if (dungeonRoom.isBlocked(x,y-dy,z)) { + nexts.add(openNode(x,y-dy,nz)); + nexts.add(openNode(nx,y-dy,z)); + nexts.add(openNode(nx,y-dy,nz)); + } + } + return nexts; + } + + public Node expand(int x, int y, int z, int dx, int dy, int dz) { + while(true) { + int nx = x + dx, ny = y + dy, nz = z + dz; + if (dungeonRoom.isBlocked(nx, ny, nz)) return null; + + if (nx > destinationBB.minX && nx < destinationBB.maxX && ny > destinationBB.minY && ny < destinationBB.maxY && nz > destinationBB.minZ && nz < destinationBB.maxZ) return openNode(nx,ny,nz); + + int determinant = Math.abs(dx) + Math.abs(dy) + Math.abs(dz); + if (determinant == 1) { + for (int i = -1; i<=1; i++) { + for (int j = - 1; j<=1; j++) { + if (i == 0 && j == 0) continue; + if (dx != 0 && dungeonRoom.isBlocked(nx, ny + i, nz + j) && !dungeonRoom.isBlocked(nx+dx, ny + i, nz + j)) return openNode(nx,ny,nz); + if (dy != 0 && dungeonRoom.isBlocked(nx + i, ny, nz + j) && !dungeonRoom.isBlocked(nx + i, ny+dy, nz + j)) return openNode(nx,ny,nz); + if (dz != 0 && dungeonRoom.isBlocked(nx + i, ny + j , nz) && !dungeonRoom.isBlocked(nx + i, ny + j , nz+dz)) return openNode(nx,ny,nz); + } + } + } else if (determinant == 2) { + for (EnumFacing value : EnumFacing.VALUES) { + if (value.getFrontOffsetX() == dx || value.getFrontOffsetY() == dy || value.getFrontOffsetZ() == dz) continue; + int tx = nx + value.getFrontOffsetX(); + int ty = ny + value.getFrontOffsetY(); + int tz = nz + value.getFrontOffsetZ(); + if (dungeonRoom.isBlocked(tx, ty, tz)) return openNode(nx, ny, nz); + } + if (dx != 0 && expand(nx, ny, nz, dx, 0,0) != null) return openNode(nx,ny,nz); + if (dy != 0 && expand(nx, ny, nz, 0, dy,0) != null) return openNode(nx,ny,nz); + if (dz != 0 && expand(nx, ny, nz, 0, 0,dz) != null) return openNode(nx,ny,nz); + } else if (determinant == 3) { + if (dungeonRoom.isBlocked(x, ny, nz ) || dungeonRoom.isBlocked(nx, y , nz) || dungeonRoom.isBlocked(nx, ny, z)) return openNode(nx,ny,nz); + if (expand(nx, ny, nz, dx, 0, 0) != null || + expand(nx, ny, nz, dx, dy, 0) != null || + expand(nx, ny, nz, dx, 0, dz) != null || + expand(nx, ny, nz, 0, dy, 0) != null || + expand(nx, ny, nz, 0, dy, dz) != null || + expand(nx, ny, nz, 0, 0, dz) != null) return openNode(nx,ny,nz); + } + x = nx; y = ny; z = nz; + } + } + + @RequiredArgsConstructor + @Data + public static final class Node { + private final int x, y, z; + + private float f, g = Float.MAX_VALUE, h = -1; + private boolean closed; + + @EqualsAndHashCode.Exclude + private Node parent; + + public static int makeHash(int x, int y, int z) + { + return y & 255 | (x & 32767) << 8 | (z & 32767) << 24 | (x < 0 ? Integer.MIN_VALUE : 0) | (z < 0 ? 32768 : 0); + } + + public Node close() { + this.closed = true; + return this; + } + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/NodeProcessorDungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/NodeProcessorDungeonRoom.java new file mode 100644 index 00000000..cdce6cf4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/NodeProcessorDungeonRoom.java @@ -0,0 +1,144 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding; + +import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.pathfinding.PathPoint; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Vec3i; +import net.minecraft.world.World; +import net.minecraft.world.pathfinder.NodeProcessor; + +import java.util.Set; + +public class NodeProcessorDungeonRoom extends NodeProcessor { + private final DungeonRoom dungeonRoom; + private final BlockPos sub; + + public NodeProcessorDungeonRoom(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + sub = dungeonRoom.getMax().subtract(dungeonRoom.getMin()); + } + + @Override + public PathPoint getPathPointTo(Entity entityIn) { + return openPoint((int) entityIn.posX - dungeonRoom.getMin().getX(), (int) entityIn.posY - dungeonRoom.getMin().getY(), + (int) entityIn.posZ - dungeonRoom.getMin().getZ()); + } + + @Override + public PathPoint getPathPointToCoords(Entity entityIn, double x, double y, double z) { + return openPoint((int) x - dungeonRoom.getMin().getX(), (int) y - dungeonRoom.getMin().getY(), + (int) z - dungeonRoom.getMin().getZ()); + } + + private static final EnumFacing[] values2 = new EnumFacing[] { + EnumFacing.DOWN, EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.UP + }; + + + + @Override + public int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance) { + + int i = 0; + for (EnumFacing ef : values2) { + Vec3i dir = ef.getDirectionVec(); + int newX = currentPoint.xCoord + dir.getX(); + int newY = currentPoint.yCoord + dir.getY(); + int newZ = currentPoint.zCoord + dir.getZ(); + + if (newX < 0 || newZ < 0) continue; + if (newX > sub.getX() || newZ > sub.getZ()) continue; + + BlockPos add1 = dungeonRoom.getMin().add(newX, newY, newZ); + World playerWorld = entityIn.getEntityWorld(); + + IBlockState curr = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(add1); + + + IBlockState up = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(dungeonRoom.getMin().add(newX, newY + 1, newZ)); + + if (isValidBlock(curr) && isValidBlock(up)) { + PathPoint pt = openPoint(newX, newY, newZ); + if (pt.visited) continue; + pathOptions[i++] = pt; + continue; + } + + if (curr.getBlock() == Blocks.air) { + if (up.getBlock() == Blocks.stone_slab + || up.getBlock() == Blocks.wooden_slab + || up.getBlock() == Blocks.stone_slab2) { + IBlockState up2 = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(dungeonRoom.getMin().add(newX, newY - 1, newZ)); + if (up2.getBlock() == Blocks.stone_slab + || up2.getBlock() == Blocks.wooden_slab + || up2.getBlock() == Blocks.stone_slab2) { + PathPoint pt = openPoint(newX, newY, newZ); + if (pt.visited) continue; + pathOptions[i++] = pt; + continue; + } + } + } + + if (dir.getY() == 0 + && curr.getBlock() == Blocks.iron_bars + && up.getBlock() == Blocks.air + && DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(new BlockPos(currentPoint.xCoord, currentPoint.yCoord, currentPoint.zCoord)).getBlock() != Blocks.iron_bars) { + + boolean theFlag = false; + if (dir.getZ() == 0) { + if (DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState( + add1.add(0, 0, 1)).getBlock() == Blocks.air || + DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(add1.add(0, 0, -1)).getBlock() == Blocks.air) { + theFlag = true; + } + } else if (dir.getX() == 0) { + if (DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(add1.add(-1, 0, 0)).getBlock() == Blocks.air || + DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(add1.add(1, 0, 0)).getBlock() == Blocks.air) { + theFlag = true; + } + } + if (theFlag) { + PathPoint pt = openPoint(newX, newY, newZ); + if (pt.visited) continue; + pathOptions[i++] = pt; + } + } + } + return i; + } + + public static final Set allowed = Sets.newHashSet(Blocks.air, Blocks.water, Blocks.lava, Blocks.flowing_water, Blocks.flowing_lava, Blocks.vine, Blocks.ladder + , Blocks.standing_sign, Blocks.wall_sign, Blocks.trapdoor, Blocks.iron_trapdoor, Blocks.wooden_button, Blocks.stone_button, Blocks.fire, + Blocks.torch, Blocks.rail, Blocks.golden_rail, Blocks.activator_rail, Blocks.detector_rail, Blocks.carpet, Blocks.redstone_torch); + public static final IBlockState preBuilt = Blocks.stone.getStateFromMeta(2); + + public static boolean isValidBlock(IBlockState state) { + return state.equals(preBuilt) || allowed.contains(state.getBlock()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/ThetaStar.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/ThetaStar.java new file mode 100644 index 00000000..4a4cf786 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/pathfinding/ThetaStar.java @@ -0,0 +1,209 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.*; +import net.minecraft.util.*; +import net.minecraft.world.World; + +import java.util.*; + +public class ThetaStar { + private final BlockPos min, max; + private final World world; + + int lastSx, lastSy, lastSz; + final int dx, dy, dz; + private DungeonRoom dungeonRoom; + + @Getter + private AxisAlignedBB destinationBB; + + public ThetaStar(DungeonRoom dungeonRoom, Vec3 destination) { + this.min = new BlockPos(dungeonRoom.getMinx(), 0, dungeonRoom.getMinz()); + this.max = new BlockPos(dungeonRoom.getMaxx(), 255, dungeonRoom.getMaxz()); + + this.world = dungeonRoom.getCachedWorld(); + this.dungeonRoom = dungeonRoom; + + this.dx = (int) (destination.xCoord * 2); + this.dy = (int) (destination.yCoord * 2); + this.dz = (int) (destination.zCoord * 2); + destinationBB = AxisAlignedBB.fromBounds(dx-2, dy-2, dz-2, dx+2, dy+2, dz+2); + } + + private Map nodeMap = new HashMap<>(); + + private Node openNode(int x, int y, int z) + { + Node.Coordinate coordinate = new Node.Coordinate(x,y,z); + Node node = this.nodeMap.get(coordinate); + + if (node == null) + { + node = new Node(coordinate); + this.nodeMap.put(coordinate, node); + } + + return node; + } + + @Getter + private LinkedList route = new LinkedList<>(); + + @Getter + private PriorityQueue open = new PriorityQueue<>(Comparator.comparing((Node a) -> a == null ? Float.MAX_VALUE : a.f).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.x).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.y).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.z)); + + private int pfindIdx = 0; + + public boolean pathfind(Vec3 from, long timeout) { + + pfindIdx ++; + if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) + open.clear(); + + this.lastSx = (int) Math.round(from.xCoord * 2); + this.lastSy = (int) Math.round(from.yCoord * 2); + this.lastSz = (int) Math.round(from.zCoord * 2); + if (dungeonRoom.isBlocked(lastSx, lastSy, lastSz)) return false; + + Node startNode = openNode(dx, dy, dz); + Node goalNode = openNode(lastSx, lastSy, lastSz); + startNode.g = 0; + startNode.f = 0; + goalNode.g = Integer.MAX_VALUE; goalNode.f = Integer.MAX_VALUE; + if (goalNode.parent != null) { + LinkedList route = new LinkedList<>(); + Node curr =goalNode; + while(curr.parent != null) { + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + curr = curr.parent; + } + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + this.route = route; + return true; + } + open.add(startNode); + + long end = System.currentTimeMillis() + timeout; + + while (!open.isEmpty()) { + if (System.currentTimeMillis() > end) { + return false; + } + Node n = open.poll(); + if (n.lastVisited == pfindIdx) continue; + n.lastVisited = pfindIdx; + + if (n == goalNode) { + // route = reconstructPath(startNode) + LinkedList route = new LinkedList<>(); + Node curr =goalNode; + while(curr.parent != null) { + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + curr = curr.parent; + } + route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); + this.route = route; + return true; + } + + for (EnumFacing value : EnumFacing.VALUES) { + Node neighbor = openNode(n.coordinate.x + value.getFrontOffsetX(), n.coordinate.y + value.getFrontOffsetY(), n.coordinate.z + value.getFrontOffsetZ()); + + // check blocked. + if (!((destinationBB.minX <= neighbor.coordinate.x && neighbor.coordinate.x <= destinationBB.maxX && + destinationBB.minY <= neighbor.coordinate.y && neighbor.coordinate.y <= destinationBB.maxY && + destinationBB.minZ <= neighbor.coordinate.z && neighbor.coordinate.z <= destinationBB.maxZ) // near destination + || !dungeonRoom.isBlocked(neighbor.coordinate.x, neighbor.coordinate.y, neighbor.coordinate.z))) { // not blocked + continue; + } + if (neighbor.lastVisited == pfindIdx) continue; + + boolean flag = false; + if (n. parent != null) { + float tempGScore = n.parent.g + distSq(n.parent.coordinate.x - neighbor.coordinate.x, n.parent.coordinate.y - neighbor.coordinate.y, n.parent.coordinate.z - neighbor.coordinate.z); + if (tempGScore < neighbor.g && lineofsight(n.parent, neighbor)) { + neighbor.parent = n.parent; + neighbor.g = tempGScore; + neighbor.f = tempGScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); + open.add(neighbor); + flag = true; + } + } + if (!flag) { + float gScore = n.g + 1; // altho it's sq, it should be fine + if (gScore < neighbor.g) { + neighbor.parent = n; + neighbor.g = gScore; + neighbor.f = gScore +distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); + open.add(neighbor); + } else if (neighbor.lastVisited != pfindIdx) { + neighbor.f = neighbor.g + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); + open.add(neighbor); + } + } + } + } + return true; + } + + private boolean lineofsight(Node a, Node b) { + if (a == null || b == null) return false; + float sx = a.coordinate.x, sy = a.coordinate.y, sz = a.coordinate.z; + int ex = b.coordinate.x, ey = b.coordinate.y, ez = b.coordinate.z; + + float dx = ex - sx, dy = ey - sy, dz = ez - sz; + float len = distSq(dx, dy, dz); + dx /= len; dy /= len; dz /= len; + + for (int d = 0; d <= len; d += 1) { + if (dungeonRoom.isBlocked(Math.round(sx), (int) Math.ceil(sy), Math.round(sz))) return false; + if (dungeonRoom.isBlocked(Math.round(sx)+1, (int) Math.ceil(sy), Math.round(sz)+1)) return false; + if (dungeonRoom.isBlocked(Math.round(sx)-1, (int) Math.ceil(sy), Math.round(sz)-1)) return false; + if (dungeonRoom.isBlocked(Math.round(sx)+1, (int) Math.ceil(sy), Math.round(sz)-1)) return false; + if (dungeonRoom.isBlocked(Math.round(sx)-1, (int) Math.ceil(sy), Math.round(sz)+1)) return false; + sx += dx; sy += dy; sz += dz; + } + return true; + } + + private int manhatten(int x, int y, int z) {return Math.abs(x)+ Math.abs(y)+ Math.abs(z);} + private float distSq(float x, float y, float z) { + return MathHelper.sqrt_float(x * x + y * y + z * z); + } + + @Data + public static final class Node { + @Data + public static final class Coordinate { + private final int x, y, z; + } + + private final Coordinate coordinate; + + private float f = Float.MAX_VALUE, g = Float.MAX_VALUE; + private int lastVisited; + + @EqualsAndHashCode.Exclude + @ToString.Exclude + private Node parent; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/EditingContext.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/EditingContext.java new file mode 100755 index 00000000..8f5fec3f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/EditingContext.java @@ -0,0 +1,83 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonRoomEdit; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; + +import java.util.Stack; + +public class EditingContext { + + private static EditingContext editingContext; + + public static void createEditingContext(DungeonRoom dungeonRoom) { + editingContext = new EditingContext(dungeonRoom); + } + + public static EditingContext getEditingContext() { + return editingContext; + } + + public static void endEditingSession() { + editingContext = null; + Minecraft.getMinecraft().displayGuiScreen(null); + } + + + private EditingContext(DungeonRoom dungeonRoom) { + this.room = dungeonRoom; + } + + @Getter + private final DungeonRoom room; + + @Getter + private final Stack guiStack = new Stack(); + + public boolean isEditingSecrets() { + return guiDungeonRoomEdit.isEditingSelected(); + } + public void endEditing() { + guiDungeonRoomEdit.endEditing(); + } + + private GuiDungeonRoomEdit guiDungeonRoomEdit; + @Getter + private GuiScreen current; + + public void openGui(GuiScreen gui) { + if (gui instanceof GuiDungeonRoomEdit) guiDungeonRoomEdit = (GuiDungeonRoomEdit) gui; + guiStack.push(current); + this.current = gui; + Minecraft.getMinecraft().displayGuiScreen(gui); + } + + public void goBack() { + current = guiStack.pop(); + Minecraft.getMinecraft().displayGuiScreen(current); + } + + public void reopen() { + Minecraft.getMinecraft().displayGuiScreen(current); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/Parameter.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/Parameter.java new file mode 100755 index 00000000..850cbe11 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/Parameter.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit; + +import lombok.Data; + +@Data +public class Parameter { + private String name; + private Object previousData; + private Object newData; + + public Parameter(String name, Object previousData, Object newData) { + this.name = name; this.previousData = previousData; this.newData = newData; + } + + private Runnable onSetNewData; + + public void setNewData(Object newData) { + this.newData = newData; + if (onSetNewData != null) onSetNewData.run(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonAddSet.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonAddSet.java new file mode 100755 index 00000000..4e4b5da4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonAddSet.java @@ -0,0 +1,136 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.gui.MGui; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditOffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.Minecraft; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class GuiDungeonAddSet extends MGui { + + private final ValueEditOffsetPointSet valueEditOffsetPointSet; + + private final MButton add; + private final MButton back; + + + @Getter + private final OffsetPoint start; + @Getter + private final OffsetPoint end; + + public void onWorldRender(float partialTicks) { + for (OffsetPoint pos:getBlockPoses()) { + RenderUtils.highlightBlock(pos.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,255,50), partialTicks); + } + RenderUtils.highlightBlock(start.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(255,0,0,100), partialTicks); + RenderUtils.highlightBlock(end.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,0,100), partialTicks); + } + + public List getBlockPoses() { + int minX = Math.min(start.getX(), end.getX()); + int minY = Math.min(start.getY(), end.getY()); + int minZ = Math.min(start.getZ(), end.getZ()); + int maxX = Math.max(start.getX(), end.getX()); + int maxY = Math.max(start.getY(), end.getY()); + int maxZ = Math.max(start.getZ(), end.getZ()); + + List offsetPoints = new ArrayList(); + for (int z = minZ; z <= maxZ; z++) { + for (int x = minX; x <=maxX; x++) { + for (int y = maxY; y >= minY; y --) { + offsetPoints.add(new OffsetPoint(x,y,z)); + } + } + } + return offsetPoints; + } + + public void add() { + valueEditOffsetPointSet.addAll(getBlockPoses()); + } + + public GuiDungeonAddSet(final ValueEditOffsetPointSet processorParameterEditPane) { + this.valueEditOffsetPointSet = processorParameterEditPane; + getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179)); + { + start = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); + end = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); + } + { + MValue mValue = new MValue(start, Collections.emptyList()); + mValue.setBounds(new Rectangle(0,0,150,20)); + getMainPanel().add(mValue); + MValue mValue2 = new MValue(end,Collections.emptyList()); + mValue2.setBounds(new Rectangle(0,20,150,20)); + getMainPanel().add(mValue2); + } + { + add = new MButton() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20)); + } + }; + add.setText("Add"); + add.setBackgroundColor(Color.red); + add.setOnActionPerformed(new Runnable() { + @Override + public void run() { + add(); + EditingContext.getEditingContext().goBack(); + } + }); + + back = new MButton(){ + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20)); + } + }; + back.setText("Go back"); + back.setBackgroundColor(Color.green); + back.setOnActionPerformed(new Runnable() { + @Override + public void run() { + EditingContext.getEditingContext().goBack(); + } + }); + getMainPanel().add(add); + getMainPanel().add(back); + } + } + + @Override + public void initGui() { + super.initGui(); + // update bounds + getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonParameterEdit.java new file mode 100755 index 00000000..0f2764de --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonParameterEdit.java @@ -0,0 +1,173 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MGui; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes.DynamicEditor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditRegistry; +import lombok.Getter; +import net.minecraft.client.Minecraft; + +import java.awt.*; + +public class GuiDungeonParameterEdit extends MGui { + + private final Parameter parameter; + private final DungeonRoom dungeonRoom; + + private String classSelection; + + private final MPanel currentValueEdit; + + private final MButton save; + private final MButton delete; + + @Getter + private ValueEdit valueEdit; + + public GuiDungeonParameterEdit(final MParameter parameter2, final DynamicEditor processorParameterEditPane) { + dungeonRoom = EditingContext.getEditingContext().getRoom(); + getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179)); + this.parameter = parameter2.getParameter(); + { + MTextField mTextField = new MTextField() { + @Override + public void edit(String str) { + parameter.setName(str); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Name", mTextField); + + mTextField.setText(parameter.getName()); + mLabelAndElement.setBounds(new Rectangle(0,0,200, 20)); + getMainPanel().add(mLabelAndElement); + } + { + classSelection = parameter.getNewData() == null ?"null" : parameter.getNewData().getClass().getName(); + final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(processorParameterEditPane.allowedClass(), classSelection) { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, 20, parentWidth,20)); + } + + @Override + public String selectionToDisplay(String selection) { + String[] split = selection.split("\\."); + return super.selectionToDisplay(split[split.length - 1]); + } + }; + + mStringSelectionButton.setOnUpdate(new Runnable() { + @Override + public void run() { + classSelection = mStringSelectionButton.getSelected(); + updateClassSelection(); + } + }); + mStringSelectionButton.setBounds(new Rectangle(0,20,150,20)); + getMainPanel().add(mStringSelectionButton); + } + { + currentValueEdit = new MPanel(){ + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, 40, parentWidth,parentHeight - 60)); + } + }; + getMainPanel().add(currentValueEdit); + } + { + delete = new MButton() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20)); + } + }; + delete.setText("Delete"); + delete.setBackgroundColor(Color.red); + delete.setOnActionPerformed(new Runnable() { + @Override + public void run() { + processorParameterEditPane.delete(parameter2); + EditingContext.getEditingContext().goBack(); + } + }); + + save = new MButton(){ + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20)); + } + }; + save.setText("Go back"); + save.setBackgroundColor(Color.green); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + EditingContext.getEditingContext().goBack(); + } + }); + getMainPanel().add(delete); + getMainPanel().add(save); + } + updateClassSelection(); + } + + public void updateClassSelection() { + currentValueEdit.getChildComponents().clear(); + + ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(classSelection); + + if (!classSelection.equals(parameter.getNewData() == null ?"null" :parameter.getNewData().getClass().getName())) { + parameter.setNewData(valueEditCreator.createDefaultValue(parameter)); + parameter.setPreviousData(valueEditCreator.cloneObj(parameter.getNewData())); + } + + MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(parameter); + if (valueEdit == null) { + MLabel valueEdit2 = new MLabel() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, 0, parentWidth,20)); + } + }; + valueEdit2.setText("No Value Edit"); + valueEdit2.setBounds(new Rectangle(0,0,150,20)); + valueEdit = valueEdit2; + this.valueEdit = null; + } else{ + this.valueEdit = (ValueEdit) valueEdit; + } + valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height); + currentValueEdit.add(valueEdit); + } + @Override + public void initGui() { + super.initGui(); + // update bounds + getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonRoomEdit.java new file mode 100755 index 00000000..181ff640 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonRoomEdit.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MGui; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTabbedPane; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes.*; +import lombok.Getter; +import net.minecraft.client.Minecraft; + +import java.awt.*; + +public class GuiDungeonRoomEdit extends MGui { + + private final DungeonRoom room; + + private final MTabbedPane tabbedPane; + @Getter + private final SecretEditPane sep; + + public GuiDungeonRoomEdit(DungeonRoom room) { + this.room = room; + + MTabbedPane tabbedPane = new MTabbedPane(); + getMainPanel().add(tabbedPane); + tabbedPane.setBackground2(new Color(17, 17, 17, 179)); + + + tabbedPane.addTab("General", new GeneralEditPane(room)); + tabbedPane.addTab("Match", new RoomDataDisplayPane(room)); + tabbedPane.addTab("Secrets", sep = new SecretEditPane(room)); + tabbedPane.addTab("Actions", new ActionDisplayPane(room)); + tabbedPane.addTab("Test", new RoommatchingPane(room)); + tabbedPane.addTab("Proc.Params", new ProcessorParameterEditPane(room)); + this.tabbedPane = tabbedPane; + } + + public boolean isEditingSelected() { + return "Secrets".equals(tabbedPane.getSelectedKey()); + } + public void endEditing() { + tabbedPane.setSelectedKey("General"); + } + + @Override + public void initGui() { + super.initGui(); + // update bounds + getMainPanel().setBounds(new Rectangle(Math.min((Minecraft.getMinecraft().displayWidth - 500) / 2, Minecraft.getMinecraft().displayWidth), Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),500,300)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonValueEdit.java new file mode 100755 index 00000000..af4657f5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/gui/GuiDungeonValueEdit.java @@ -0,0 +1,127 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MGui; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditRegistry; +import lombok.Getter; +import net.minecraft.client.Minecraft; + +import java.awt.*; +import java.util.List; + +public class GuiDungeonValueEdit extends MGui { + private DungeonRoom dungeonRoom; + + + private MPanel currentValueEdit; + + private MButton save; + + @Getter + private ValueEdit valueEdit; + + private List addons; + + private Object editingObj; + + public GuiDungeonValueEdit(final Object object, final List addons) { + try { + dungeonRoom = EditingContext.getEditingContext().getRoom(); + this.addons = addons; + this.editingObj = object; + getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179)); + { + currentValueEdit = new MPanel() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, 0, parentWidth, parentHeight - 20 - addons.size() * 20)); + } + }; + getMainPanel().add(currentValueEdit); + } + + for (MPanel addon : addons) { + getMainPanel().add(addon); + } + { + save = new MButton() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, parentHeight - 20, parentWidth, 20)); + } + }; + save.setText("Go back"); + save.setBackgroundColor(Color.green); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + EditingContext.getEditingContext().goBack(); + } + }); + getMainPanel().add(save); + } + updateClassSelection(); + } catch (Exception e){} + } + + public void updateClassSelection() { + currentValueEdit.getChildComponents().clear(); + + ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(editingObj == null ?"null":editingObj.getClass().getName()); + + MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(new Parameter("", editingObj, editingObj)); + if (valueEdit == null) { + MLabel valueEdit2 = new MLabel() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, 0, parentWidth,20)); + } + }; + valueEdit2.setText("No Value Edit"); + valueEdit2.setBounds(new Rectangle(0,0,150,20)); + valueEdit = valueEdit2; + this.valueEdit = null; + } else{ + this.valueEdit = (ValueEdit) valueEdit; + } + valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height); + currentValueEdit.add(valueEdit); + } + @Override + public void initGui() { + super.initGui(); + // update bounds + getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300)); + + + for (int i = 0; i < addons.size(); i++) { + addons.get(i).setBounds(new Rectangle(0, getMainPanel().getBounds().height - (i+1) * 20 - 20, getMainPanel().getBounds().width, 20)); + } + save.setBounds(new Rectangle(0 ,getMainPanel().getBounds().height - 20, getMainPanel().getBounds().width, 20)); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditBreakableWall.java new file mode 100755 index 00000000..bcde40b9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditBreakableWall.java @@ -0,0 +1,143 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonBreakableWall; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.init.Blocks; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Collections; + +public class ValueEditBreakableWall extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonBreakableWall dungeonBreakableWall; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + private final MButton updateOnlyAir; + + public ValueEditBreakableWall(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonBreakableWall = (DungeonBreakableWall) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Wall Points"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonBreakableWall.getSecretPoint(), Collections.emptyList()); + add(value); + + updateOnlyAir = new MButton(); + updateOnlyAir.setText("Update Air"); + updateOnlyAir.setBackgroundColor(Color.green); + updateOnlyAir.setForeground(Color.black); + updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); + add(updateOnlyAir); + updateOnlyAir.setOnActionPerformed(new Runnable() { + @Override + public void run() { + OffsetPointSet ofs = dungeonBreakableWall.getSecretPoint(); + List filtered = new ArrayList(); + for (OffsetPoint offsetPoint : ofs.getOffsetPointList()) { + if (offsetPoint.getBlock(EditingContext.getEditingContext().getRoom()) != Blocks.air) continue; + filtered.add(offsetPoint); + } + dungeonBreakableWall.getSecretPoint().setOffsetPointList(filtered); + } + }); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonBreakableWall.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonBreakableWall.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonBreakableWall.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditBreakableWall createValueEdit(Parameter parameter) { + return new ValueEditBreakableWall(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonBreakableWall(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonBreakableWall)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditDoor.java new file mode 100755 index 00000000..b2a30bfb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditDoor.java @@ -0,0 +1,157 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDoor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.init.Blocks; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class ValueEditDoor extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonDoor dungeonDoor; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite_par; + private final MTextField preRequisite2; + private final MLabelAndElement preRequisite2_par; + private final MButton updateOnlyAir; + + public ValueEditDoor(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonDoor = (DungeonDoor) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Wall Points"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonDoor.getSecretPoint(), Collections.emptyList()); + add(value); + + updateOnlyAir = new MButton(); + updateOnlyAir.setText("Update Air"); + updateOnlyAir.setBackgroundColor(Color.green); + updateOnlyAir.setForeground(Color.black); + updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); + add(updateOnlyAir); + updateOnlyAir.setOnActionPerformed(new Runnable() { + @Override + public void run() { + OffsetPointSet ofs = dungeonDoor.getSecretPoint(); + List filtered = new ArrayList(); + for (OffsetPoint offsetPoint : ofs.getOffsetPointList()) { + if (offsetPoint.getBlock(EditingContext.getEditingContext().getRoom()) != Blocks.air) continue; + filtered.add(offsetPoint); + } + dungeonDoor.getSecretPoint().setOffsetPointList(filtered); + } + }); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonDoor.setOpenPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonDoor.getOpenPreRequisite(), ",")); + preRequisite_par = new MLabelAndElement("Open Req.",preRequisite); + preRequisite_par.setBounds(new Rectangle(0,60,getBounds().width,20)); + add(preRequisite_par); + + preRequisite2 = new MTextField() { + @Override + public void edit(String str) { + dungeonDoor.setClosePreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite2.setText(TextUtils.join(dungeonDoor.getClosePreRequisite(), ",")); + preRequisite2_par = new MLabelAndElement("Close Req.",preRequisite2); + preRequisite2_par.setBounds(new Rectangle(0,80,getBounds().width,20)); + add(preRequisite2_par); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); + preRequisite_par.setBounds(new Rectangle(0,60,getBounds().width,20)); + preRequisite2_par.setBounds(new Rectangle(0,80,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonDoor.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditDoor createValueEdit(Parameter parameter) { + return new ValueEditDoor(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonDoor(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonDoor)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditDummy.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditDummy.java new file mode 100755 index 00000000..64808dda --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditDummy.java @@ -0,0 +1,121 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDummy; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTextField; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MValue; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditDummy extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonDummy dungeonSecret; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + + public ValueEditDummy(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonSecret = (DungeonDummy) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Dummy Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditDummy createValueEdit(Parameter parameter) { + return new ValueEditDummy(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonDummy(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonDummy)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditFairySoul.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditFairySoul.java new file mode 100755 index 00000000..3bd69eb9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditFairySoul.java @@ -0,0 +1,118 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditFairySoul extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonFairySoul dungeonSecret; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + + public ValueEditFairySoul(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonSecret = (DungeonFairySoul) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("FairySoul Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditFairySoul createValueEdit(Parameter parameter) { + return new ValueEditFairySoul(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonFairySoul(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonFairySoul)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditJournal.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditJournal.java new file mode 100755 index 00000000..1123050e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditJournal.java @@ -0,0 +1,122 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonJournal; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTextField; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MValue; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + + +public class ValueEditJournal extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonJournal dungeonSecret; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + + public ValueEditJournal(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonSecret = (DungeonJournal) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Journal Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditJournal createValueEdit(Parameter parameter) { + return new ValueEditJournal(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonJournal(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonJournal)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditLever.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditLever.java new file mode 100755 index 00000000..080be185 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditLever.java @@ -0,0 +1,133 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonLever; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditLever extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonLever dungeonLever; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + private final MTextField target; + private final MLabelAndElement target2; + + public ValueEditLever(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonLever = (DungeonLever) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Secret Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonLever.getLeverPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonLever.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonLever.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(preRequisite2); + + + target = new MTextField() { + @Override + public void edit(String str) { + dungeonLever.setTriggering(str); + } + }; + target.setText(dungeonLever.getTriggering()); + target2 = new MLabelAndElement("Target",target); + target2.setBounds(new Rectangle(0,60,getBounds().width,20)); + add(target2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + target2.setBounds(new Rectangle(0,60,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonLever.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditLever createValueEdit(Parameter parameter) { + return new ValueEditLever(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonLever(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonLever)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditNPC.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditNPC.java new file mode 100755 index 00000000..20608f8e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditNPC.java @@ -0,0 +1,121 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonNPC; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTextField; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MValue; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditNPC extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonNPC dungeonSecret; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + + public ValueEditNPC(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonSecret = (DungeonNPC) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("NPC Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditNPC createValueEdit(Parameter parameter) { + return new ValueEditNPC(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonNPC(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonNPC)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditOnewayDoor.java new file mode 100755 index 00000000..ffeba48d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditOnewayDoor.java @@ -0,0 +1,143 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayDoor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.init.Blocks; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class ValueEditOnewayDoor extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonOnewayDoor dungeonDoor; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + private final MButton updateOnlyAir; + + public ValueEditOnewayDoor(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonDoor = (DungeonOnewayDoor) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Wall Points"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonDoor.getSecretPoint(), Collections.emptyList()); + add(value); + + updateOnlyAir = new MButton(); + updateOnlyAir.setText("Update Air"); + updateOnlyAir.setBackgroundColor(Color.green); + updateOnlyAir.setForeground(Color.black); + updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); + add(updateOnlyAir); + updateOnlyAir.setOnActionPerformed(new Runnable() { + @Override + public void run() { + OffsetPointSet ofs = dungeonDoor.getSecretPoint(); + List filtered = new ArrayList(); + for (OffsetPoint offsetPoint : ofs.getOffsetPointList()) { + if (offsetPoint.getBlock(EditingContext.getEditingContext().getRoom()) != Blocks.air) continue; + filtered.add(offsetPoint); + } + dungeonDoor.getSecretPoint().setOffsetPointList(filtered); + } + }); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonDoor.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonDoor.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonDoor.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditOnewayDoor createValueEdit(Parameter parameter) { + return new ValueEditOnewayDoor(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonOnewayDoor(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonOnewayDoor)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditOnewayLever.java new file mode 100755 index 00000000..a315b736 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditOnewayLever.java @@ -0,0 +1,137 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayLever; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTextField; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MValue; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditOnewayLever extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonOnewayLever dungeonLever; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + private final MTextField target; + private final MLabelAndElement target2; + + + public ValueEditOnewayLever(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonLever = (DungeonOnewayLever) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Secret Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonLever.getLeverPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonLever.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonLever.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(preRequisite2); + + + target = new MTextField() { + @Override + public void edit(String str) { + dungeonLever.setTriggering(str); + } + }; + target.setText(dungeonLever.getTriggering()); + target2 = new MLabelAndElement("Target",target); + target2.setBounds(new Rectangle(0,60,getBounds().width,20)); + add(target2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + target2.setBounds(new Rectangle(0,60,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonLever.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditOnewayLever createValueEdit(Parameter parameter) { + return new ValueEditOnewayLever(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonOnewayLever(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonOnewayLever)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditPressurePlate.java new file mode 100755 index 00000000..dac3d196 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditPressurePlate.java @@ -0,0 +1,136 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonPressurePlate; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTextField; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MValue; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditPressurePlate extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonPressurePlate dungeonPressureplate; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + private final MTextField target; + private final MLabelAndElement target2; + + + public ValueEditPressurePlate(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonPressureplate = (DungeonPressurePlate) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Secret Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonPressureplate.getPlatePoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonPressureplate.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonPressureplate.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(preRequisite2); + + + target = new MTextField() { + @Override + public void edit(String str) { + dungeonPressureplate.setTriggering(str); + } + }; + target.setText(dungeonPressureplate.getTriggering()); + target2 = new MLabelAndElement("Target",target); + target2.setBounds(new Rectangle(0,60,getBounds().width,20)); + add(target2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + target2.setBounds(new Rectangle(0,60,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonPressureplate.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditPressurePlate createValueEdit(Parameter parameter) { + return new ValueEditPressurePlate(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonPressurePlate(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonPressurePlate)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditSecret.java new file mode 100755 index 00000000..165105aa --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditSecret.java @@ -0,0 +1,129 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditSecret extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonSecret dungeonSecret; + + private final MLabel label; + private final MValue value; + private final MStringSelectionButton selectionButton; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + + public ValueEditSecret(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonSecret = (DungeonSecret) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Secret Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); + add(value); + + selectionButton = new MStringSelectionButton(Arrays.asList("CHEST", "BAT", "ITEM_DROP", "ESSENCE"), dungeonSecret.getSecretType().name()); + selectionButton.setOnUpdate(new Runnable() { + @Override + public void run() { + dungeonSecret.setSecretType(DungeonSecret.SecretType.valueOf(selectionButton.getSelected())); + } + }); + add(selectionButton); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + selectionButton.setBounds(new Rectangle(0,40,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditSecret createValueEdit(Parameter parameter) { + return new ValueEditSecret(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonSecret(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonSecret)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditTomb.java new file mode 100755 index 00000000..2604b873 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/mechanicedit/ValueEditTomb.java @@ -0,0 +1,118 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonTomb; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditTomb extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + private final DungeonTomb dungeonTomb; + + private final MLabel label; + private final MValue value; + private final MTextField preRequisite; + private final MLabelAndElement preRequisite2; + + public ValueEditTomb(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonTomb = (DungeonTomb) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Tomb Points"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonTomb.getSecretPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonTomb.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonTomb.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonTomb.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditTomb createValueEdit(Parameter parameter) { + return new ValueEditTomb(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonTomb(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonTomb)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ActionDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ActionDisplayPane.java new file mode 100755 index 00000000..2c886ac9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ActionDisplayPane.java @@ -0,0 +1,82 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionTree; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; + +import java.awt.*; + +public class ActionDisplayPane extends MPanel { + private final DungeonRoom dungeonRoom; + + private ActionTreeDisplayPane displayPane; + + private final MTextField textField; + private final MButton calculate; + public ActionDisplayPane(final DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + + { + textField = new MTextField(); + textField.setBounds(new Rectangle(0,0,getBounds().width - 100, 20)); + add(textField); + } + { + calculate = new MButton(); + calculate.setBounds(new Rectangle(getBounds().width - 100,0,100, 20)); + calculate.setText("calculate"); + calculate.setOnActionPerformed(new Runnable() { + @Override + public void run() { + try { + remove(displayPane); + + String text = textField.getText(); + String target = text.split(":")[0]; + String state = text.split(":")[1]; + ActionChangeState actionChangeState = new ActionChangeState(target, state); + ActionTree tree= ActionTree.buildActionTree(actionChangeState, dungeonRoom); + + displayPane = new ActionTreeDisplayPane(dungeonRoom, tree); + displayPane.setBounds(new Rectangle(0,25,getBounds().width,getBounds().height-25)); + add(displayPane); + } catch (Throwable t) { + t.printStackTrace(); + } + } + }); + add(calculate); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + @Override + public void onBoundsUpdate() { + textField.setBounds(new Rectangle(0,0,getBounds().width - 100, 20)); + calculate.setBounds(new Rectangle(getBounds().width - 100,0,100, 20)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ActionTreeDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ActionTreeDisplayPane.java new file mode 100755 index 00000000..bcc75a98 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ActionTreeDisplayPane.java @@ -0,0 +1,216 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionTree; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionTreeUtil; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class ActionTreeDisplayPane extends MPanel { + + private int offsetX = 0; + private int offsetY = 0; + + private float scale; + + private final DungeonRoom dungeonRoom; + private final ActionTree tree; + private List linearified; + public ActionTreeDisplayPane(DungeonRoom dungeonRoom, ActionTree tree) { + this.dungeonRoom = dungeonRoom; + this.tree = tree; + try { + this.linearified = ActionTreeUtil.linearifyActionTree(tree); + } catch (Exception e) { + linearified = new ArrayList(); + e.printStackTrace(); + } + scale = 1.0f; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + GlStateManager.pushMatrix(); + GlStateManager.translate(offsetX, offsetY, 0); + GlStateManager.scale(scale,scale,1); + int x = renderTree(tree, 5, 5, Minecraft.getMinecraft().fontRendererObj, null, new HashMap()); + renderLinearified(linearified, x, 5, fr); + GlStateManager.popMatrix(); + } + + public int renderTree(ActionTree actionTree, int x, int y, FontRenderer fr, Point drawLineFrom, HashMap drawmPoints) { + if (drawmPoints.containsKey(actionTree)) { + // recursive, fu + Point pt = drawmPoints.get(actionTree); + + GlStateManager.pushMatrix(); + + GlStateManager.enableBlend(); + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(770, 771); + GlStateManager.enableBlend(); + GL11.glLineWidth(1); + GlStateManager.color(1, 0, 0, 1); + GL11.glBegin(2); + GL11.glVertex2d(drawLineFrom.x, drawLineFrom.y); + GL11.glVertex2d(pt.x, pt.y); + GL11.glEnd(); + GlStateManager.disableBlend(); + GlStateManager.enableTexture2D(); + GlStateManager.enableDepth(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + + return 0; + } + + Dimension dim = renderAction(actionTree.getCurrent(), x, y, fr); + if (drawLineFrom != null) { + GlStateManager.pushMatrix(); + + + GlStateManager.enableBlend(); + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(770, 771); + GlStateManager.enableBlend(); + GL11.glLineWidth(1); + GlStateManager.color(1, 1, 1, 1); + GL11.glBegin(2); + GL11.glVertex2d(drawLineFrom.x, drawLineFrom.y); + GL11.glVertex2d(x + dim.width / 2, y); + GL11.glEnd(); + GlStateManager.disableBlend(); + GlStateManager.enableTexture2D(); + GlStateManager.enableDepth(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + + } + Point pt = new Point(x + dim.width / 2, y + dim.height); + + drawmPoints.put(actionTree, new Point(x + dim.width / 2, y + dim.height / 2)); + int xOff = 0; + for (ActionTree tree:actionTree.getChildren()) { + xOff += renderTree(tree, x + xOff, y + dim.height + 10, fr, pt, drawmPoints) + 10; + } + return Math.max(xOff, dim.width); + } + + public void renderLinearified(List actions, int x, int y, FontRenderer fr) { + Point lastPt = null; + int y2 = y; + + for (AbstractAction action : actions) { + Dimension dim = renderAction(action, x, y2, fr); + if (lastPt != null) { + GlStateManager.pushMatrix(); + + + GlStateManager.enableBlend(); + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(770, 771); + GlStateManager.enableBlend(); + GL11.glLineWidth(1); + GlStateManager.color(1, 1, 1, 1); + GL11.glBegin(2); + GL11.glVertex2d(lastPt.x, lastPt.y); + GL11.glVertex2d(x + dim.width / 2, y2); + GL11.glEnd(); + GlStateManager.disableBlend(); + GlStateManager.enableTexture2D(); + GlStateManager.enableDepth(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + + } + lastPt = new Point(x + dim.width / 2, y2 + dim.height); + + y2 += dim.height + 10; + } + } + + public Dimension renderAction(AbstractAction action, int x, int y, FontRenderer fr) { + String[] lines = action.toString().split("\n"); + int maxWidth = 0; + for (String line : lines) { + if (fr.getStringWidth(line) > maxWidth) maxWidth= fr.getStringWidth(line); + } + int offset = 2; + int height = (fr.FONT_HEIGHT + offset) * lines.length; + + Gui.drawRect(x,y,x + maxWidth +10, y + height + 10, 0xff000000); + Gui.drawRect(x+1,y+1,x + maxWidth +8, y + height + 8, 0xff4d4d4d); + for (int i = 0; i < lines.length; i++) { + fr.drawString(lines[i], x + 5, y + 5 + i*(fr.FONT_HEIGHT + offset), 0xffffffff); + } + + return new Dimension(maxWidth + 10, height + 10); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,25,parentWidth,parentHeight-25)); + } + + + private int lastX; + private int lastY; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + lastX = absMouseX; + lastY = absMouseY; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + int dX = absMouseX - lastX; + int dY = absMouseY - lastY; + offsetX += dX; + offsetY += dY; + lastX = absMouseX; + lastY = absMouseY; + } + + @Override + public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (scrollAmount > 0) scale += 0.1; + if (scrollAmount < 0) scale -= 0.1; + + if (scale < 0) scale = 0.1f; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/DynamicEditor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/DynamicEditor.java new file mode 100755 index 00000000..5be67660 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/DynamicEditor.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.mod.gui.elements.MParameter; + +import java.util.List; + +public interface DynamicEditor { + void delete(MParameter parameter); + + List allowedClass(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/GeneralEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/GeneralEditPane.java new file mode 100755 index 00000000..a60797e8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/GeneralEditPane.java @@ -0,0 +1,286 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.Main; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoomInfoRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.ProcessorFactory; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; + +import java.awt.*; +import java.io.*; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.UUID; +import java.util.zip.GZIPOutputStream; + +public class GeneralEditPane extends MPanel { + private final DungeonRoom dungeonRoom; + + private final MLabelAndElement uuid; + private final MLabelAndElement name; + private final MLabelAndElement secrets; + + private final MLabelAndElement shape; + private final MLabelAndElement rotation; + private final MLabelAndElement shape2; + + private MButton save; + private final MButton end; + private final MButton schematic; + + private final MLabelAndElement roomProcessor; + + public GeneralEditPane(final DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + { + MLabel la; + uuid = new MLabelAndElement("Room UUID: ", la = new MLabel()); + la.setText(dungeonRoom.getDungeonRoomInfo().getUuid().toString()); + uuid.setBounds(new Rectangle(0,0,getBounds().width, 20)); + add(uuid); + } + { + MTextField la = new MTextField() { + @Override + public void edit(String str) { + dungeonRoom.getDungeonRoomInfo().setName(str); + } + }; + name = new MLabelAndElement("Room Name: ", la); + la.setText(dungeonRoom.getDungeonRoomInfo().getName()); + name.setBounds(new Rectangle(0,20,getBounds().width, 20)); + add(name); + } + { + final MIntegerSelectionButton la = new MIntegerSelectionButton(dungeonRoom.getDungeonRoomInfo().getTotalSecrets()); + la.setOnUpdate(new Runnable() { + @Override + public void run() { + dungeonRoom.getDungeonRoomInfo().setTotalSecrets(la.getData()); + } + }); + secrets = new MLabelAndElement("Room Secrets: ", la); + secrets.setBounds(new Rectangle(0,40,getBounds().width, 20)); + add(secrets); + } + + { + MLabel la; + shape = new MLabelAndElement("Room Shape: ", la = new MLabel()); + la.setText(dungeonRoom.getDungeonRoomInfo().getShape()+""); + shape.setBounds(new Rectangle(0,60,getBounds().width, 20)); + add(shape); + } + + { + MLabel la; + rotation = new MLabelAndElement("Found Room Rotation: ", la = new MLabel()); + la.setText(dungeonRoom.getRoomMatcher().getRotation()+""); + rotation.setBounds(new Rectangle(0,80,getBounds().width, 20)); + add(rotation); + } + { + MLabel la; + shape2 = new MLabelAndElement("Found Room Shape: ", la = new MLabel()); + la.setText(dungeonRoom.getShape()+""); + shape2.setBounds(new Rectangle(0,100,getBounds().width, 20)); + add(shape2); + } + { + final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList(ProcessorFactory.getProcessors()), dungeonRoom.getDungeonRoomInfo().getProcessorId()); + roomProcessor = new MLabelAndElement("Room Processor: ", mStringSelectionButton); + roomProcessor.setBounds(new Rectangle(0,120,getBounds().width, 20)); + add(roomProcessor); + + mStringSelectionButton.setOnUpdate(new Runnable() { + @Override + public void run() { + dungeonRoom.getDungeonRoomInfo().setProcessorId(mStringSelectionButton.getSelected()); + dungeonRoom.updateRoomProcessor(); + } + }); + } + { + end = new MButton(); + end.setText("End Editing Session"); + end.setOnActionPerformed(new Runnable() { + @Override + public void run() { + EditingContext.endEditingSession(); + } + }); + end.setBackgroundColor(Color.green); + end.setBounds(new Rectangle(0,140,getBounds().width, 20)); + add(end); + } + { + schematic = new MButton(); + schematic.setText("Save Schematic"); + schematic.setOnActionPerformed(new Runnable() { + @Override + public void run() { + try { + NBTTagCompound nbtTagCompound2 = createNBT(); + + File f=new File(Main.getConfigDir(), "schematics/"+ + dungeonRoom.getDungeonRoomInfo().getName()+"-"+dungeonRoom.getDungeonRoomInfo().getUuid().toString()+"-"+ UUID.randomUUID()+".schematic"); + + Method method = null; + try { + method = NBTTagCompound.class.getDeclaredMethod("write", DataOutput.class); + method.setAccessible(true); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + return; + } + FileOutputStream fos = new FileOutputStream(f); + DataOutputStream dataoutputstream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fos))); + + try + { + dataoutputstream.writeByte(nbtTagCompound2.getId()); + + dataoutputstream.writeUTF("Schematic"); + method.invoke(nbtTagCompound2, dataoutputstream); + } + finally + { + dataoutputstream.close(); + } + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSaved to "+f.getName())); + } catch (Throwable e) { + e.printStackTrace(); + } + + } + }); + schematic.setBackgroundColor(Color.orange); + schematic.setBounds(new Rectangle(0,180,getBounds().width, 20)); + add(schematic); + } + { + if (dungeonRoom.getDungeonRoomInfo().isRegistered()) return; + save = new MButton(); + save.setText("Save RoomData"); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + DungeonRoomInfoRegistry.register(dungeonRoom.getDungeonRoomInfo()); + remove(save); + } + }); + save.setBackgroundColor(Color.green); + save.setBounds(new Rectangle(0,10,getBounds().width, 20)); + add(save); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + @Override + public void onBoundsUpdate() { + if (save != null) + save.setBounds(new Rectangle(0,160,getBounds().width, 20)); + end.setBounds(new Rectangle(1,140,getBounds().width-2, 20)); + if (schematic != null) + schematic.setBounds(new Rectangle(0,180,getBounds().width, 20)); + } + + private NBTTagCompound createNBT() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setShort("Width", (short) (dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 1)); + compound.setShort("Height", (short) 255); + compound.setShort("Length", (short) (dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 1)); + int size =compound.getShort("Width") * compound.getShort("Height") * compound.getShort("Length"); + + byte[] blocks = new byte[size]; + byte[] meta = new byte[size]; + byte[] extra = new byte[size]; + byte[] extranibble = new byte[(int) Math.ceil(size / 2.0)]; + + boolean extraEx = false; + NBTTagList tileEntitiesList = new NBTTagList(); + for (int x = 0; x < compound.getShort("Width"); x++) { + for (int y = 0; y < compound.getShort("Height"); y++) { + for (int z = 0; z < compound.getShort("Length"); z++) { + int index = x + (y * compound.getShort("Length") + z) * compound.getShort("Width"); + BlockPos pos = dungeonRoom.getRelativeBlockPosAt(x,y - 70,z); + IBlockState blockState = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos); + boolean acc = dungeonRoom.canAccessRelative(x,z); + int id = Block.getIdFromBlock(blockState.getBlock()); + blocks[index] = acc ? (byte) id : 0; + meta[index] = acc ? (byte) blockState.getBlock().getMetaFromState(blockState) : 0; + if ((extra[index] = (byte) ((acc ? id : 0) >> 8)) > 0) { + extraEx = true; + } + + if (blockState.getBlock().hasTileEntity(blockState)) { + TileEntity tileEntity = dungeonRoom.getContext().getWorld().getTileEntity(pos); + try { + final NBTTagCompound tileEntityCompound = new NBTTagCompound(); + tileEntity.writeToNBT(tileEntityCompound); + tileEntitiesList.appendTag(tileEntityCompound); + } catch (final Exception e) { + final BlockPos tePos = tileEntity.getPos(); + + blocks[index] = (byte) 7; + meta[index] = 0; + extra[index] = 0; + } + } + } + } + } + for (int i = 0; i < extranibble.length; i++) { + if (i * 2 + 1 < extra.length) { + extranibble[i] = (byte) ((extra[i * 2 + 0] << 4) | extra[i * 2 + 1]); + } else { + extranibble[i] = (byte) (extra[i * 2 + 0] << 4); + } + } + + + compound.setByteArray("Blocks", blocks); + compound.setByteArray("Data", meta); + compound.setString("Materials", "Alpha"); + if (extraEx) { + compound.setByteArray("AddBlocks", extranibble); + } + compound.setTag("Entities", new NBTTagList()); + compound.setTag("TileEntities", tileEntitiesList); + + return compound; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ProcessorParameterEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ProcessorParameterEditPane.java new file mode 100755 index 00000000..5b907fb7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/ProcessorParameterEditPane.java @@ -0,0 +1,144 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MParameter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditRegistry; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class ProcessorParameterEditPane extends MPanel implements DynamicEditor { + private final DungeonRoom dungeonRoom; + + private MButton save; + private MButton create; + private final List parameters = new ArrayList(); + + public ProcessorParameterEditPane(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + buildElements(); + } + + public void buildElements() { + { + create = new MButton(); + create.setText("Create New Parameter"); + create.setBackgroundColor(Color.cyan); + create.setBounds(new Rectangle(0,0,100,20)); + create.setOnActionPerformed(new Runnable() { + @Override + public void run() { + MParameter parameter; + parameters.add(parameter = new MParameter(new Parameter(UUID.randomUUID().toString(), null, null), ProcessorParameterEditPane.this)); + parameter.setParent(ProcessorParameterEditPane.this); + parameter.setBounds(new Rectangle(0,0,getBounds().width, 20)); + } + }); + + save = new MButton(); + save.setText("Save"); + save.setBackgroundColor(Color.green); + save.setBounds(new Rectangle(0,0,100,20)); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + DungeonRoomInfo dungeonRoomInfo = dungeonRoom.getDungeonRoomInfo(); + dungeonRoomInfo.getProperties().clear(); + + for (MParameter parameter : parameters) { + Parameter real = parameter.getParameter(); + + ValueEditCreator vec = ValueEditRegistry.getValueEditMap(real.getNewData() == null ? "null" :real.getNewData().getClass().getName()); + + real.setPreviousData(vec.cloneObj(real.getNewData())); + dungeonRoomInfo.getProperties().put(real.getName(), real.getNewData()); + } + } + }); + create.setParent(this); save.setParent(this); + } + { + for (Map.Entry en : dungeonRoom.getDungeonRoomInfo().getProperties().entrySet()) { + ValueEditCreator vec = ValueEditRegistry.getValueEditMap(en.getValue() == null ? "null" :en.getValue().getClass().getName()); + + MParameter mParameter = new MParameter(new Parameter(en.getKey(), vec.cloneObj(en.getValue()), vec.cloneObj(en.getValue())), this); + mParameter.setBounds(new Rectangle(0,0,getBounds().width,20)); + parameters.add(mParameter); + mParameter.setParent(this); + } + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); + } + } + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + + public void delete(MParameter parameter) { + parameters.remove(parameter); + } + + @Override + public List allowedClass() { + return ValueEditRegistry.getClassesSupported(); + } + + + @Override + public List getChildComponents() { + ArrayList panels = new ArrayList(parameters); + panels.add(create); + panels.add(save); + return panels; + } + + private int offsetY = 0; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + int heights = 0; + for (MPanel panel:getChildComponents()) { + panel.setPosition(new Point(0, -offsetY + heights)); + heights += panel.getBounds().height; + } + } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (scrollAmount > 0) offsetY -= 20; + else if (scrollAmount < 0) offsetY += 20; + if (offsetY < 0) offsetY = 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoomDataDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoomDataDisplayPane.java new file mode 100755 index 00000000..f2ae85c3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoomDataDisplayPane.java @@ -0,0 +1,126 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.awt.*; + +public class RoomDataDisplayPane extends MPanel { + + private int offsetX = 0; + private int offsetY = 0; + + private int selectedX = -1; + private int selectedY = -1; + + private final DungeonRoom dungeonRoom; + public RoomDataDisplayPane(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + int[][] blocks = dungeonRoom.getDungeonRoomInfo().getBlocks(); + // draw Axis; + Gui.drawRect(0,0,10,10,0x77777777); + clip(clip.x + 10, clip.y, clip.width - 10, 10); + Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); + for (int x = 0; x < blocks[0].length; x++) { + fr.drawString(x+"", x * 16 +10 + offsetX, 0, 0xFFFFFFFF); + } + clip(clip.x, clip.y +10, 10, clip.height-10); + Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); + for (int z = 0; z < blocks.length; z++) { + fr.drawString(z+"", 2, z * 16 + 10 + offsetY, 0xFFFFFFFF); + } + + int hoverX = (relMousex0 - offsetX - 10) / 16; + int hoverY = (relMousey0 - offsetY - 10) / 16; + // draw Content + clip(clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10); + for (int z = 0; z < blocks.length; z++) { + for (int x = 0; x < blocks[z].length; x++) { + int data = blocks[z][x]; + if (z == selectedY && x == selectedX){ + Gui.drawRect(x *16 +10+offsetX, z *16 +10 + offsetY, x *16 +26 +offsetX, z *16 +26 + offsetY, 0xAA707070); + } else if (z == hoverY && x == hoverX) { + Gui.drawRect(x *16 +10+offsetX, z *16 +10 + offsetY, x *16 +26 +offsetX, z *16 +26 + offsetY, 0xAA505050); + } + + + if (data == -1) fr.drawString("X", x *16 +10 + offsetX, z *16 +10 + offsetY,0xFFFFFF); + else drawItemStack(new ItemStack(Item.getItemFromBlock(Block.getBlockById(data)), 1), x * 16 +10 + offsetX, z *16 +10 + offsetY); + } + } + + } + private void drawItemStack(ItemStack stack, int x, int y) + { + Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, x, y); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + @Override + public void keyPressed(char typedChar, int keyCode) { + int[][] blocks = dungeonRoom.getDungeonRoomInfo().getBlocks(); + if (selectedX != -1 && selectedY != -1 && selectedY < blocks.length && selectedX < blocks[0].length) { + dungeonRoom.getDungeonRoomInfo().getBlocks()[selectedY][selectedX] = -1; + } + } + + private int lastX; + private int lastY; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + lastX = absMouseX; + lastY = absMouseY; + + if (lastAbsClip.contains(absMouseX, absMouseY)) { + selectedX = (relMouseX - offsetX - 10) / 16; + selectedY = (relMouseY - offsetY - 10) / 16; + } + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + int dX = absMouseX - lastX; + int dY = absMouseY - lastY; + offsetX += dX; + offsetY += dY; + lastX = absMouseX; + lastY = absMouseY; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoomMatchDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoomMatchDisplayPane.java new file mode 100755 index 00000000..b7023c4b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoomMatchDisplayPane.java @@ -0,0 +1,152 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoomInfoRegistry; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltip; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltipText; +import kr.syeyoung.dungeonsguide.mod.utils.ArrayUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.awt.*; +import java.util.Arrays; +import java.util.UUID; + +public class RoomMatchDisplayPane extends MPanel { + + private int offsetX = 0; + private int offsetY = 0; + + private final DungeonRoom dungeonRoom; + + private final int[][] currentBlocks; + private int[][] targetBlocks; + public RoomMatchDisplayPane(DungeonRoom dungeonRoom, UUID uid, int rotation) { + this.dungeonRoom = dungeonRoom; + + currentBlocks = dungeonRoom.getRoomMatcher().createNew().getBlocks(); + targetBlocks = DungeonRoomInfoRegistry.getByUUID(uid).getBlocks(); + for (int i = 0; i < rotation; i++) + targetBlocks = ArrayUtils.rotateCounterClockwise(targetBlocks); + } + + MTooltip mTooltip; + int lastTooltipX = -1, lastTooltipZ = -1; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + int height = Math.max(currentBlocks.length, targetBlocks.length); + int width = Math.max(currentBlocks[0].length, targetBlocks[0].length); + + // draw Axis; + Gui.drawRect(0,0,10,10,0x77777777); + clip(clip.x + 10, clip.y, clip.width - 10, 10); + Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); + for (int x = 0; x < width; x++) { + fr.drawString(x+"", x * 16 +10 + offsetX, 0, 0xFFFFFFFF); + } + clip(clip.x, clip.y +10, 10, clip.height-10); + Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); + for (int z = 0; z < height; z++) { + fr.drawString(z+"", 2, z * 16 + 10 + offsetY, 0xFFFFFFFF); + } + + int hoverX = (relMousex0 - offsetX - 10) / 16; + int hoverY = (relMousey0 - offsetY - 10) / 16; + // draw Content + clip(clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10); + boolean tooltiped=false; + for (int z = 0; z < height; z++) { + for (int x = 0; x < width; x++) { + int data1; + try { data1 = currentBlocks[z][x]; } catch (Exception e) { + data1 = -2; + } + int data2; + try { data2 = targetBlocks[z][x]; } catch (Exception e) { + data2 = -2; + } + + if (z == hoverY && x == hoverX) { + Gui.drawRect(x *16 +10+offsetX, z *16 +10 + offsetY, x *16 +26 +offsetX, z *16 +26 + offsetY, 0xAA505050); + } + + if (data1 == data2) drawItemStack(new ItemStack(Item.getItemFromBlock(Block.getBlockById(data1)), 1), x * 16 +10 + offsetX, z *16 +10 + offsetY); + else if (data2 == -1 || data1 == -1) { + drawItemStack(new ItemStack(Item.getItemFromBlock(Block.getBlockById(data1 == -1 ? data2 : data1)), 1), x * 16 +10 + offsetX, z *16 +10 + offsetY); + fr.drawString("S", x *16 +10 + offsetX, z *16 +10 + offsetY,0xFFFFFF00); + } else { + fr.drawString("N", x *16 +10 + offsetX, z *16 +10 + offsetY,0xFFFF0000); + } + if (z == hoverY && x == hoverX) { + tooltiped = true; + if (lastTooltipX != x || lastTooltipZ != z){ + if (mTooltip != null) mTooltip.close(); + mTooltip = new MTooltipText(Arrays.asList("Expected "+data2 +" But found "+data1)); + mTooltip.open(this); + } + } + } + } + if (!tooltiped && mTooltip != null) { + mTooltip.close(); + mTooltip = null; + } + + } + private void drawItemStack(ItemStack stack, int x, int y) + { + Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, x, y); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + private int lastX; + private int lastY; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + lastX = absMouseX; + lastY = absMouseY; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + int dX = absMouseX - lastX; + int dY = absMouseY - lastY; + offsetX += dX; + offsetY += dY; + lastX = absMouseX; + lastY = absMouseY; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoommatchingPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoommatchingPane.java new file mode 100755 index 00000000..964c450b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/RoommatchingPane.java @@ -0,0 +1,84 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTextField; + +import java.awt.*; +import java.util.UUID; + +public class RoommatchingPane extends MPanel { + private final DungeonRoom dungeonRoom; + + private RoomMatchDisplayPane displayPane; + + private final MTextField textField; + private final MButton calculate; + public RoommatchingPane(final DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + + { + textField = new MTextField(); + textField.setBounds(new Rectangle(0,0,getBounds().width - 100, 20)); + add(textField); + } + { + calculate = new MButton(); + calculate.setBounds(new Rectangle(getBounds().width - 100,0,100, 20)); + calculate.setText("match"); + calculate.setOnActionPerformed(new Runnable() { + @Override + public void run() { + try { + remove(displayPane); + + String text = textField.getText(); + String target = text.split(":")[0]; + String state = text.split(":")[1]; + + UUID uid = UUID.fromString(target); + int rotation = Integer.parseInt(state) % 4; + + + displayPane = new RoomMatchDisplayPane(dungeonRoom, uid, rotation); + displayPane.setBounds(new Rectangle(0,25,getBounds().width,getBounds().height-25)); + add(displayPane); + } catch (Throwable t) { + t.printStackTrace(); + } + } + }); + add(calculate); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + @Override + public void onBoundsUpdate() { + textField.setBounds(new Rectangle(0,0,getBounds().width - 100, 20)); + calculate.setBounds(new Rectangle(getBounds().width - 100,0,100, 20)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/SecretEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/SecretEditPane.java new file mode 100755 index 00000000..5c52e770 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/panes/SecretEditPane.java @@ -0,0 +1,156 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes; + +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MParameter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditRegistry; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class SecretEditPane extends MPanel implements DynamicEditor { + private final DungeonRoom dungeonRoom; + + private MButton save; + private MButton create; + private final List parameters = new ArrayList(); + + private final List allowedClasses = new ArrayList(); + + public SecretEditPane(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + buildElements(); + + for (String clazz : ValueEditRegistry.getClassesSupported()) { + if (clazz.contains("mechanics") || clazz.equals("null")) { + allowedClasses.add(clazz); + } + } + } + + public void createNewMechanic(String uid, DungeonMechanic data) { + MParameter parameter; + parameters.add(parameter = new MParameter(new Parameter(uid, data, data), SecretEditPane.this)); + parameter.setBounds(new Rectangle(0,0,getBounds().width, 20)); + parameter.setParent(SecretEditPane.this); + } + + public void buildElements() { + { + create = new MButton(); + create.setText("Create New Mechanic"); + create.setBackgroundColor(Color.cyan); + create.setBounds(new Rectangle(0,0,100,20)); + create.setOnActionPerformed(new Runnable() { + @Override + public void run() { + createNewMechanic(UUID.randomUUID().toString(), null); + } + }); + + save = new MButton(); + save.setText("Save"); + save.setBackgroundColor(Color.green); + save.setBounds(new Rectangle(0,0,100,20)); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + DungeonRoomInfo dungeonRoomInfo = dungeonRoom.getDungeonRoomInfo(); + dungeonRoomInfo.getMechanics().clear(); + + for (MParameter parameter : parameters) { + Parameter real = parameter.getParameter(); + + ValueEditCreator vec = ValueEditRegistry.getValueEditMap(real.getNewData() == null ? "null" :real.getNewData().getClass().getName()); + + real.setPreviousData(vec.cloneObj(real.getNewData())); + dungeonRoomInfo.getMechanics().put(real.getName(), (DungeonMechanic) real.getNewData()); + } + } + }); + create.setParent(this); save.setParent(this); + } + { + for (Map.Entry en : dungeonRoom.getDungeonRoomInfo().getMechanics().entrySet()) { + ValueEditCreator vec = ValueEditRegistry.getValueEditMap(en.getValue() == null ? "null" :en.getValue().getClass().getName()); + + MParameter mParameter = new MParameter(new Parameter(en.getKey(), vec.cloneObj(en.getValue()), vec.cloneObj(en.getValue())), this); + mParameter.setBounds(new Rectangle(0,0,getBounds().width,20)); + parameters.add(mParameter); + mParameter.setParent(this); + } + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); + } + } + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + + public void delete(MParameter parameter) { + parameters.remove(parameter); + } + + @Override + public List allowedClass() { + return allowedClasses; + } + + @Override + public List getChildComponents() { + ArrayList panels = new ArrayList(parameters); + panels.add(create); + panels.add(save); + return panels; + } + + private int offsetY = 0; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + int heights = 0; + for (MPanel panel:getChildComponents()) { + panel.setPosition(new Point(0, -offsetY + heights)); + heights += panel.getBounds().height; + } + } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (scrollAmount > 0) offsetY -= 20; + else if (scrollAmount < 0) offsetY += 20; + if (offsetY < 0) offsetY = 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEdit.java new file mode 100755 index 00000000..d52094de --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEdit.java @@ -0,0 +1,27 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; + +public interface ValueEdit { + void setParameter(Parameter parameter); + + void renderWorld(float partialTicks); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditAColor.java new file mode 100755 index 00000000..c42fa423 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditAColor.java @@ -0,0 +1,339 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MColor; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MFloatSelectionButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class ValueEditAColor extends MPanel implements ValueEdit { + private Parameter parameter; + private final MFloatSelectionButton h; + private final MFloatSelectionButton s; + private final MFloatSelectionButton v; + private final MFloatSelectionButton a; + + + @Override + public void renderWorld(float partialTicks) { + + } + public ValueEditAColor(final Parameter parameter2) { + this.parameter = parameter2; + { + MColor color = new MColor() { + @Override + public Color getColor() { + return (Color) parameter2.getPreviousData(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",color); + mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); + add(mLabelAndElement); + } + { + MColor color = new MColor() { + @Override + public Color getColor() { + return (Color) parameter2.getNewData(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("New",color); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + + Color color = (Color) parameter2.getNewData(); + Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsv); + alpha = color.getAlpha() / 255.0f; + + { + h = new MFloatSelectionButton(hsv[0] * 360); + h.setOnUpdate(new Runnable() { + @Override + public void run() { + hsv[0] = h.getData() / 360; + update(); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("H", h); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + { + s = new MFloatSelectionButton(hsv[1] * 100); + s.setOnUpdate(new Runnable() { + @Override + public void run() { + hsv[1] = s.getData() / 100; + update(); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("S", s); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + { + v = new MFloatSelectionButton(hsv[2] * 100); + v.setOnUpdate(new Runnable() { + @Override + public void run() { + hsv[2] = v.getData() / 100; + update(); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("V", v); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + { + a = new MFloatSelectionButton(alpha * 100); + a.setOnUpdate(new Runnable() { + @Override + public void run() { + alpha = a.getData() / 100; + update(); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("A", a); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + } + + private final float[] hsv = new float[3]; + private float alpha = 0; + + public void update() { + if (hsv[2] > 1) hsv[2] = 1; + if (hsv[2] < 0) hsv[2] = 0; + if (hsv[1] > 1) hsv[1] = 1; + if (hsv[1] < 0) hsv[1] = 0; + parameter.setNewData(new AColor(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0xffffff | (MathHelper.clamp_int((int)(alpha * 255), 0, 255) << 24), true )); + h.setData((float) Math.floor(hsv[0] * 360)); + s.setData((float) Math.floor(hsv[1] * 100)); + v.setData((float) Math.floor(hsv[2] * 100)); + a.setData((float) Math.floor(alpha * 100)); + h.updateSelected(); + s.updateSelected(); + v.updateSelected(); + a.updateSelected(); + } + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + // draw CoolRect + int width = getBounds().width - 60; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + int shademodel = GL11.glGetInteger(GL11.GL_SHADE_MODEL); + GlStateManager.shadeModel(GL11.GL_SMOOTH); + GlStateManager.enableBlend(); + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + +// worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); + + int rgb = Color.HSBtoRGB(hsv[0], hsv[1], 1); + float r = (rgb >> 16 & 255) / 255.0f; + float g = (rgb >> 8 & 255) / 255.0f; + float b = (rgb & 255) / 255.0f; + GL11.glBegin(GL11.GL_TRIANGLES); + GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(25+width ,45, 0); + GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(10+width , 45, 0); + GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(25+width , 45+width, 0); + + GlStateManager.color(0,0,0,alpha); GL11.glVertex3i(10+width , 45, 0); + GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(10+width , 45 + width, 0); + GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(25+width , 45+width, 0); + GL11.glEnd(); + rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); + r = (rgb >> 16 & 255) / 255.0f; + g = (rgb >> 8 & 255) / 255.0f; + b = (rgb & 255) / 255.0f; + GL11.glBegin(GL11.GL_TRIANGLES); + GlStateManager.color(r,g,b,0);GL11.glVertex3i(50+width ,45, 0); + GlStateManager.color(r,g,b,0);GL11.glVertex3i(35+width , 45, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(50+width , 45+width, 0); + +// GlStateManager.color(r,g,b,0); GL11.glVertex3i(35+width , 45, 0); +// GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width , 45 + width, 0); +// GlStateManager.color(r,g,b,1);GL11.glVertex3i(50+width , 45+width, 0); + GL11.glEnd(); + + + float radius = width/2f; + float cx = 5 + radius; + float cy = 45 + radius; + + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GlStateManager.color(1,1,1,alpha); + GL11.glVertex3f(cx,cy,0); + for (int i = 0; i <= 360; i++) { + float rad = 3.141592653f * i / 180; + int rgb2 = Color.HSBtoRGB(i / 360f, 1, hsv[2]); + float r2 = (rgb2 >> 16 & 255) / 255.0f; + float g2 = (rgb2 >> 8 & 255) / 255.0f; + float b2 = (rgb2 & 255) / 255.0f; + GlStateManager.color(r2,g2,b2, alpha); + GL11.glVertex3f(MathHelper.sin(rad) * radius + cx, MathHelper.cos(rad) * radius + cy, 0); + } + GL11.glEnd(); + GlStateManager.shadeModel(shademodel); + + GlStateManager.color(1,1,1,1); + worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); + float rad2 = 2 * 3.141592653f * hsv[0] ; + float x = 5 + radius + (MathHelper.sin(rad2)) * hsv[1] * radius; + float y = 45 + radius + (MathHelper.cos(rad2))* hsv[1] * radius; + for (int i = 0; i < 100; i++) { + float rad = 2 * 3.141592653f * (i / 100f); + worldrenderer.pos(MathHelper.sin(rad) * 2 + x, MathHelper.cos(rad) * 2 + y, 0).endVertex(); + } + tessellator.draw(); + + worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + worldrenderer.pos(8+width, 45 + (hsv[2]) * width, 0.5).endVertex(); + worldrenderer.pos(27+width, 45 + (hsv[2]) * width, 0.5).endVertex(); + tessellator.draw(); + + worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + worldrenderer.pos(33+width, 45 + (alpha) * width, 0.5).endVertex(); + worldrenderer.pos(52+width, 45 + (alpha) * width, 0.5).endVertex(); + tessellator.draw(); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.color(1,1,1,1); + GlStateManager.color(1,1,1,1); + } + private int selected = 0; + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + int width = getBounds().width - 60; + float radius = width / 2f; + float circleX = 5 + radius; + float circleY = 45 + radius; + selected = 0; + { + // check circle + float dx = relMouseX - circleX; + float dy = circleY - relMouseY; + if (dx * dx + dy * dy <= radius * radius) { + double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; + hsv[0] = (float) theta / 360f; + hsv[1] = MathHelper.sqrt_float(dx * dx + dy * dy) / radius; + selected = 1; + } + } + { + if (10+width <= relMouseX && relMouseX <= 25 + width && + 45 <= relMouseY && relMouseY <= 45 + width) { + hsv[2] = (relMouseY - 45) / (float)width; + selected = 2; + } + } + { + if (35+width <= relMouseX && relMouseX <= 50 + width && + 45 <= relMouseY && relMouseY <= 45 + width) { + alpha = (relMouseY - 45) / (float)width; + selected = 3; + } + } + update(); + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + int width = getBounds().width - 60; + float radius = width / 2f; + float circleX = 5 + radius; + float circleY = 45 + radius; + { + // check circle + float dx = relMouseX - circleX; + float dy = circleY - relMouseY; + if (selected == 1) { + double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; + hsv[0] = (float) theta / 360f; + hsv[1] = MathHelper.clamp_float(MathHelper.sqrt_float(dx * dx + dy * dy) / radius, 0, 1); + } + } + { + if (selected == 2) { + hsv[2] = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); + } + if (selected == 3) { + alpha = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); + } + } + update(); + } + + @Override + public void onBoundsUpdate() { + int cnt = 0; + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); cnt++; + if (cnt > 2) { + panel.setPosition(new Point(0, getBounds().width + (cnt - 3) * 20)); + } + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditAColor createValueEdit(Parameter parameter) { + return new ValueEditAColor(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new AColor(255,0,0,255); + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditBoolean.java new file mode 100755 index 00000000..639afc20 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditBoolean.java @@ -0,0 +1,101 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MStringSelectionButton; + +import java.awt.*; +import java.util.Arrays; + +public class ValueEditBoolean extends MPanel implements ValueEdit { + private Parameter parameter; + + + public ValueEditBoolean(Parameter parameter2) { + this.parameter = parameter2; + { + MLabel label = new MLabel() { + @Override + public String getText() { + return parameter.getPreviousData().toString(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); + add(mLabelAndElement); + } + { + boolean newData = (Boolean) parameter.getNewData(); + final MStringSelectionButton textField = new MStringSelectionButton(Arrays.asList("true", "false"), Boolean.toString(newData)); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + parameter.setNewData(Boolean.valueOf(textField.getSelected())); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditBoolean createValueEdit(Parameter parameter) { + return new ValueEditBoolean(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return true; + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditColor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditColor.java new file mode 100755 index 00000000..5ef977a1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditColor.java @@ -0,0 +1,287 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class ValueEditColor extends MPanel implements ValueEdit { + private Parameter parameter; + private final MFloatSelectionButton h; + private final MFloatSelectionButton s; + private final MFloatSelectionButton v; + + + @Override + public void renderWorld(float partialTicks) { + + } + public ValueEditColor(final Parameter parameter2) { + this.parameter = parameter2; + { + MColor color = new MColor() { + @Override + public Color getColor() { + return (Color) parameter2.getPreviousData(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",color); + mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); + add(mLabelAndElement); + } + { + MColor color = new MColor() { + @Override + public Color getColor() { + return (Color) parameter2.getNewData(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("New",color); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + + Color color = (Color) parameter2.getNewData(); + Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsv); + + { + h = new MFloatSelectionButton(hsv[0] * 360); + h.setOnUpdate(new Runnable() { + @Override + public void run() { + hsv[0] = h.getData() / 360; + update(); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("H", h); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + { + s = new MFloatSelectionButton(hsv[1] * 100); + s.setOnUpdate(new Runnable() { + @Override + public void run() { + hsv[1] = s.getData() / 100; + update(); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("S", s); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + { + v = new MFloatSelectionButton(hsv[2] * 100); + v.setOnUpdate(new Runnable() { + @Override + public void run() { + hsv[2] = v.getData() / 100; + update(); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("V", v); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + } + + private final float[] hsv = new float[3]; + + public void update() { + if (hsv[2] > 1) hsv[2] = 1; + if (hsv[2] < 0) hsv[2] = 0; + if (hsv[1] > 1) hsv[1] = 1; + if (hsv[1] < 0) hsv[1] = 0; + parameter.setNewData(new Color(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]))); + h.setData((float) Math.floor(hsv[0] * 360)); + s.setData((float) Math.floor(hsv[1] * 100)); + v.setData((float) Math.floor(hsv[2] * 100)); + h.updateSelected(); + s.updateSelected(); + v.updateSelected(); + } + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + // draw CoolRect + int width = getBounds().width - 30; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + int shademodel = GL11.glGetInteger(GL11.GL_SHADE_MODEL); + GlStateManager.shadeModel(GL11.GL_SMOOTH); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); +// worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); + + int rgb = Color.HSBtoRGB(hsv[0], hsv[1], 1); + float r = (rgb >> 16 & 255) / 255.0f; + float g = (rgb >> 8 & 255) / 255.0f; + float b = (rgb & 255) / 255.0f; + GL11.glBegin(GL11.GL_TRIANGLES); + GlStateManager.color(0,0,0,1);GL11.glVertex3i(25+width ,45, 0); + GlStateManager.color(0,0,0,1);GL11.glVertex3i(10+width , 45, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 45+width, 0); + + GlStateManager.color(0,0,0,1); GL11.glVertex3i(10+width , 45, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(10+width , 45 + width, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 45+width, 0); + GL11.glEnd(); + + float radius = width/2f; + float cx = 5 + radius; + float cy = 45 + radius; + + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GlStateManager.color(1,1,1,1); + GL11.glVertex3f(cx,cy,0); + for (int i = 0; i <= 360; i++) { + float rad = 3.141592653f * i / 180; + int rgb2 = Color.HSBtoRGB(i / 360f, 1, hsv[2]); + float r2 = (rgb2 >> 16 & 255) / 255.0f; + float g2 = (rgb2 >> 8 & 255) / 255.0f; + float b2 = (rgb2 & 255) / 255.0f; + GlStateManager.color(r2,g2,b2, 1); + GL11.glVertex3f(MathHelper.sin(rad) * radius + cx, MathHelper.cos(rad) * radius + cy, 0); + } + GL11.glEnd(); + GlStateManager.shadeModel(shademodel); + + GlStateManager.color(1,1,1,1); + worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); + float rad2 = 2 * 3.141592653f * hsv[0] ; + float x = 5 + radius + (MathHelper.sin(rad2)) * hsv[1] * radius; + float y = 45 + radius + (MathHelper.cos(rad2))* hsv[1] * radius; + for (int i = 0; i < 100; i++) { + float rad = 2 * 3.141592653f * (i / 100f); + worldrenderer.pos(MathHelper.sin(rad) * 2 + x, MathHelper.cos(rad) * 2 + y, 0).endVertex(); + } + tessellator.draw(); + + worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + worldrenderer.pos(8+width, 45 + (hsv[2]) * width, 0.5).endVertex(); + worldrenderer.pos(27+width, 45 + (hsv[2]) * width, 0.5).endVertex(); + tessellator.draw(); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.color(1,1,1,1); + GlStateManager.color(1,1,1,1); + } + private int selected = 0; + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + int width = getBounds().width - 30; + float radius = width / 2f; + float circleX = 5 + radius; + float circleY = 45 + radius; + selected = 0; + { + // check circle + float dx = relMouseX - circleX; + float dy = circleY - relMouseY; + if (dx * dx + dy * dy <= radius * radius) { + double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; + hsv[0] = (float) theta / 360f; + hsv[1] = MathHelper.sqrt_float(dx * dx + dy * dy) / radius; + selected = 1; + } + } + { + if (10+width <= relMouseX && relMouseX <= 25 + width && + 45 <= relMouseY && relMouseY <= 45 + width) { + hsv[2] = (relMouseY - 45) / (float)width; + selected = 2; + } + } + update(); + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + int width = getBounds().width - 30; + float radius = width / 2f; + float circleX = 5 + radius; + float circleY = 45 + radius; + { + // check circle + float dx = relMouseX - circleX; + float dy = circleY - relMouseY; + if (selected == 1) { + double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; + hsv[0] = (float) theta / 360f; + hsv[1] = MathHelper.clamp_float(MathHelper.sqrt_float(dx * dx + dy * dy) / radius, 0, 1); + } + } + { + if (selected == 2) { + hsv[2] = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); + } + } + update(); + } + + @Override + public void onBoundsUpdate() { + int cnt = 0; + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); cnt++; + if (cnt > 2) { + panel.setPosition(new Point(0, getBounds().width + (cnt - 2) * 20)); + } + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditColor createValueEdit(Parameter parameter) { + return new ValueEditColor(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return Color.red; + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditCreator.java new file mode 100755 index 00000000..5d37040b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditCreator.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; + +public interface ValueEditCreator { + T createValueEdit(Parameter parameter); + + Object createDefaultValue(Parameter parameter); + + Object cloneObj(Object object); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditFloat.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditFloat.java new file mode 100755 index 00000000..e44adab1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditFloat.java @@ -0,0 +1,99 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MFloatSelectionButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; + +import java.awt.*; + +public class ValueEditFloat extends MPanel implements ValueEdit { + private Parameter parameter; + + + @Override + public void renderWorld(float partialTicks) { + + } + public ValueEditFloat(final Parameter parameter2) { + this.parameter = parameter2; + { + MLabel label = new MLabel() { + @Override + public String getText() { + return parameter.getPreviousData().toString(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); + add(mLabelAndElement); + } + { + float newData = (Float) parameter.getNewData(); + final MFloatSelectionButton textField = new MFloatSelectionButton(newData); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + parameter.setNewData(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditFloat createValueEdit(Parameter parameter) { + return new ValueEditFloat(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return 0.0f; + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditInteger.java new file mode 100755 index 00000000..4b93a30d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditInteger.java @@ -0,0 +1,99 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MIntegerSelectionButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; + +import java.awt.*; + +public class ValueEditInteger extends MPanel implements ValueEdit { + private Parameter parameter; + + + @Override + public void renderWorld(float partialTicks) { + + } + public ValueEditInteger(final Parameter parameter2) { + this.parameter = parameter2; + { + MLabel label = new MLabel() { + @Override + public String getText() { + return parameter.getPreviousData().toString(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); + add(mLabelAndElement); + } + { + int newData = (Integer) parameter.getNewData(); + final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + parameter.setNewData(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditInteger createValueEdit(Parameter parameter) { + return new ValueEditInteger(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return 0; + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditNull.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditNull.java new file mode 100755 index 00000000..0868470e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditNull.java @@ -0,0 +1,38 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; + +public class ValueEditNull implements ValueEditCreator { + @Override + public ValueEdit createValueEdit(Parameter parameter) { + return null; + } + + @Override + public Cloneable createDefaultValue(Parameter parameter) { + return null; + } + + @Override + public Object cloneObj(Object object) { + return null; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditOffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditOffsetPoint.java new file mode 100755 index 00000000..813ac68a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditOffsetPoint.java @@ -0,0 +1,163 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; +import java.awt.*; + +public class ValueEditOffsetPoint extends MPanel implements ValueEdit { + private Parameter parameter; + + @Override + public void renderWorld(float partialTicks) { + RenderUtils.highlightBlock(((OffsetPoint)parameter.getPreviousData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(255,0,0,150), partialTicks); + RenderUtils.highlightBlock(((OffsetPoint)parameter.getNewData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,0,150), partialTicks); + } + + public ValueEditOffsetPoint(final Parameter parameter2) { + this.parameter = parameter2; + { + MLabel label = new MLabel() { + @Override + public String getText() { + return parameter.getPreviousData().toString(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); + add(mLabelAndElement); + } + OffsetPoint newData = (OffsetPoint) parameter.getNewData(); + { + final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getX()); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + ((OffsetPoint) parameter.getNewData()).setX(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("x",textField); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + { + final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getY()); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + ((OffsetPoint) parameter.getNewData()).setY(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("y",textField); + mLabelAndElement.setBounds(new Rectangle(0,40,getBounds().width,20)); + add(mLabelAndElement); + } + { + final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getZ()); + textField.setOnUpdate(new Runnable() { + @Override + public void run() { + ((OffsetPoint) parameter.getNewData()).setZ(textField.getData()); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("z",textField); + mLabelAndElement.setBounds(new Rectangle(0,60,getBounds().width,20)); + add(mLabelAndElement); + } + { + final MLabel setToHEre = new MLabel() { + @Override + public String getText() { + OffsetPoint offsetPoint = (OffsetPoint) parameter.getNewData(); + return Block.getIdFromBlock(offsetPoint.getBlock(EditingContext.getEditingContext().getRoom())) + + ":" + offsetPoint.getData(EditingContext.getEditingContext().getRoom()); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("newPt",setToHEre); + mLabelAndElement.setBounds(new Rectangle(0,80,getBounds().width,20)); + add(mLabelAndElement); + } + { + final MButton setToHEre2 = new MButton(); + setToHEre2.setText("Set to here"); + setToHEre2.setBackgroundColor(Color.green); + setToHEre2.setOnActionPerformed(new Runnable() { + @Override + public void run() { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ); + ((OffsetPoint)parameter2.getNewData()).setPosInWorld(EditingContext.getEditingContext().getRoom(),pos ); + } + }); + MLabelAndElement mLabelAndElement = new MLabelAndElement("set",setToHEre2); + mLabelAndElement.setBounds(new Rectangle(0,100,getBounds().width,20)); + add(mLabelAndElement); + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditOffsetPoint createValueEdit(Parameter parameter) { + return new ValueEditOffsetPoint(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((OffsetPoint)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditOffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditOffsetPointSet.java new file mode 100755 index 00000000..cd6351bd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditOffsetPointSet.java @@ -0,0 +1,250 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MValue; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonAddSet; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.Minecraft; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class ValueEditOffsetPointSet extends MPanel implements ValueEdit { + private Parameter parameter; + + // scroll pane + // just create + // add set + + private final MPanel scroll; + @Getter + private final List MParameters = new ArrayList(); + + private final MButton add; + private final MButton addSet; + + public void delete(OffsetPoint offsetPoint) { + ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().remove(offsetPoint); + Iterator iterator = MParameters.iterator(); + while (iterator.hasNext()) { + MValue panel = (MValue) iterator.next(); + if (panel.getData() == offsetPoint) { + iterator.remove(); + break; + } + } + + } + + public ValueEditOffsetPointSet(final Parameter parameter2) { + this.parameter = parameter2; + { + scroll = new MPanel() { + private int offsetY = 0; + + @Override + public List getChildComponents() { + return MParameters; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + int heights = 0; + for (MPanel panel:getChildComponents()) { + panel.setPosition(new Point(0, -offsetY + heights)); + heights += panel.getBounds().height; + } + } + + @Override + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + if (!getBounds().contains(relMouseX0, relMouseY0)) { + return false; + } + + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + boolean noClip = true; + boolean focusedOverall = false; + for (MPanel childComponent : getChildComponents()) { + if (childComponent.mouseClicked0(absMouseX, absMouseY, relMousex, relMousey, mouseButton)) { + noClip = false; + focusedOverall = true; + } + } + + if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { + isFocused = true; + focusedOverall = true; + } else { + isFocused = false; + } + + mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); + return focusedOverall; + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); + } + } + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (new Rectangle(new Point(0,0), getSize()).contains(relMouseX0, relMouseY0)) { + if (scrollAmount >0) offsetY += 20; + else if (scrollAmount < 0) offsetY -= 20; + if (offsetY <0) offsetY = 0; + } + } + }; + scroll.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height-20)); + add(scroll); + } + + { + add = new MButton() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20)); + } + }; + add.setText("Add"); + add.setBackgroundColor(Color.green); + add.setOnActionPerformed(new Runnable() { + @Override + public void run() { + OffsetPoint offsetPoint = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); + MValue mValue; + MParameters.add(mValue = new MValue(offsetPoint, buildAddonsFor(offsetPoint))); + ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().add(offsetPoint); + mValue.setSize(new Dimension(getBounds().width, 20)); + } + }); + + addSet = new MButton(){ + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20)); + } + }; + addSet.setText("Add Set"); + addSet.setBackgroundColor(Color.cyan); + addSet.setOnActionPerformed(new Runnable() { + @Override + public void run() { + EditingContext.getEditingContext().openGui(new GuiDungeonAddSet(ValueEditOffsetPointSet.this)); + } + }); + add(add); + add(addSet); + } + for (OffsetPoint offsetPoint : ((OffsetPointSet)parameter.getNewData()).getOffsetPointList()) { + MParameters.add(new MValue(offsetPoint, buildAddonsFor(offsetPoint))); + } + } + + public List buildAddonsFor(final OffsetPoint offsetPoint) { + ArrayList panels = new ArrayList(); + MButton mButton = new MButton(); + mButton.setText("Delete"); + mButton.setForeground(Color.white); + mButton.setBackgroundColor(Color.red); + mButton.setOnActionPerformed(new Runnable() { + @Override + public void run() { + delete(offsetPoint); + } + }); + panels.add(mButton); + return panels; + } + + @Override + public void onBoundsUpdate() { + scroll.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height-20)); + add.setBounds(new Rectangle(0,getBounds().height-20,getBounds().width / 2, 20)); + addSet.setBounds(new Rectangle(getBounds().width / 2,getBounds().height-20,getBounds().width / 2, 20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + for (OffsetPoint offsetPoint :((OffsetPointSet)parameter.getNewData()).getOffsetPointList()) { + RenderUtils.highlightBlock(offsetPoint.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,255,50), partialTicks); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public void addAll(List blockPoses) { + ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().addAll(blockPoses); + for (OffsetPoint blockPose : blockPoses) { + MParameters.add(new MValue(blockPose, buildAddonsFor(blockPose))); + } + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditOffsetPointSet createValueEdit(Parameter parameter) { + return new ValueEditOffsetPointSet(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new OffsetPointSet(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((OffsetPointSet)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditRegistry.java new file mode 100755 index 00000000..af368f2c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditRegistry.java @@ -0,0 +1,70 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.mechanicedit.*; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ValueEditRegistry { + private static final Map valueEditMap = new HashMap(); + + public static ValueEditCreator getValueEditMap(String className) { + return valueEditMap.get(className); + } + + public static List getClassesSupported() { + return new ArrayList(valueEditMap.keySet()); + } + + static { + valueEditMap.put("null", new ValueEditNull()); + valueEditMap.put(String.class.getName(), new ValueEditString.Generator()); + valueEditMap.put(Boolean.class.getName(), new ValueEditBoolean.Generator()); + valueEditMap.put(Integer.class.getName(), new ValueEditInteger.Generator()); + valueEditMap.put(Float.class.getName(), new ValueEditFloat.Generator()); + valueEditMap.put(OffsetPoint.class.getName(), new ValueEditOffsetPoint.Generator()); + valueEditMap.put(OffsetPointSet.class.getName(), new ValueEditOffsetPointSet.Generator()); + valueEditMap.put(Color.class.getName(), new ValueEditColor.Generator()); + valueEditMap.put(AColor.class.getName(), new ValueEditAColor.Generator()); + + + valueEditMap.put(DungeonSecret.class.getName(), new ValueEditSecret.Generator()); + valueEditMap.put(DungeonFairySoul.class.getName(), new ValueEditFairySoul.Generator()); + valueEditMap.put(DungeonNPC.class.getName(), new ValueEditNPC.Generator()); + valueEditMap.put(DungeonTomb.class.getName(), new ValueEditTomb.Generator()); + valueEditMap.put(DungeonBreakableWall.class.getName(), new ValueEditBreakableWall.Generator()); + valueEditMap.put(DungeonJournal.class.getName(), new ValueEditJournal.Generator()); + valueEditMap.put(DungeonDummy.class.getName(), new ValueEditDummy.Generator()); + + valueEditMap.put(DungeonPressurePlate.class.getName(), new ValueEditPressurePlate.Generator()); + valueEditMap.put(DungeonOnewayLever.class.getName(), new ValueEditOnewayLever.Generator()); + valueEditMap.put(DungeonLever.class.getName(), new ValueEditLever.Generator()); + valueEditMap.put(DungeonDoor.class.getName(), new ValueEditDoor.Generator()); + valueEditMap.put(DungeonOnewayDoor.class.getName(), new ValueEditOnewayDoor.Generator()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditString.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditString.java new file mode 100755 index 00000000..0d2b3697 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomedit/valueedit/ValueEditString.java @@ -0,0 +1,99 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTextField; + +import java.awt.*; + +public class ValueEditString extends MPanel implements ValueEdit { + private Parameter parameter; + + @Override + public void renderWorld(float partialTicks) { + + } + + public ValueEditString(Parameter parameter2) { + this.parameter = parameter2; + { + MLabel label = new MLabel() { + @Override + public String getText() { + return parameter.getPreviousData().toString(); + } + }; + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); + add(mLabelAndElement); + } + { + String newData = (String) parameter.getNewData(); + MTextField textField = new MTextField() { + @Override + public void edit(String str) { + parameter.setNewData(str); + } + }; + textField.setText(newData); + MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); + mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); + add(mLabelAndElement); + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(getBounds().width, 20)); + } + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator { + + @Override + public ValueEditString createValueEdit(Parameter parameter) { + return new ValueEditString(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return "default"; + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/DungeonRoom.java new file mode 100755 index 00000000..5834d67e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/DungeonRoom.java @@ -0,0 +1,381 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder; + +import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.MapProcessor; +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.EDungeonDoorType; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonStateChangeEvent; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonRoomDoor; +import kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding.*; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.ProcessorFactory; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessorGenerator; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.impl.secret.FeaturePathfindStrategy; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.pathfinding.PathFinder; +import net.minecraft.pathfinding.PathPoint; +import net.minecraft.util.*; +import net.minecraft.world.ChunkCache; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import javax.vecmath.Vector2d; +import java.awt.*; +import java.util.List; +import java.util.*; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +@Getter +public class DungeonRoom { + private final List unitPoints; + private final short shape; + private final byte color; + + private final BlockPos min; + private final BlockPos max; + private final Point minRoomPt; + + private final DungeonContext context; + + private final List doors = new ArrayList<>(); + + private DungeonRoomInfo dungeonRoomInfo; + + private final int unitWidth; // X + private final int unitHeight; // Z + + @Setter + private int totalSecrets = -1; + private RoomState currentState = RoomState.DISCOVERED; + + private Map cached = null; + + @Getter + private final World cachedWorld; + public Map getMechanics() { + if (cached == null || EditingContext.getEditingContext() != null) { + cached = new HashMap<>(dungeonRoomInfo.getMechanics()); + int index = 0; + for (DungeonDoor door : doors) { + if (door.getType().isExist()) cached.put((door.getType().getName())+"-"+(++index), new DungeonRoomDoor(this, door)); + } + } + return cached; + } + + public void setCurrentState(RoomState currentState) { + context.createEvent(new DungeonStateChangeEvent(unitPoints.get(0), dungeonRoomInfo.getName(), this.currentState, currentState)); + this.currentState = currentState; + } + + private final Map activeBetterAStar = new HashMap<>(); + private final Map activeBetterAStarCornerCut = new HashMap<>(); + private final Map activeThetaStar = new HashMap<>(); + + public ScheduledFuture> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist, int timeout) { + FeaturePathfindStrategy.PathfindStrategy pathfindStrategy = FeatureRegistry.SECRET_PATHFIND_STRATEGY.getPathfindStrat(); + if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.JPS_LEGACY) { + return asyncPathFinder.schedule(() -> { + BlockPos min = new BlockPos(getMin().getX(), 0, getMin().getZ()); + BlockPos max= new BlockPos(getMax().getX(), 255, getMax().getZ()); + JPSPathfinder pathFinder = new JPSPathfinder(this); + pathFinder.pathfind(entityIn.getPositionVector(), new Vec3(targetPos).addVector(0.5, 0.5, 0.5), 1.5f,timeout); + return pathFinder.getRoute(); + }, 0, TimeUnit.MILLISECONDS); + } else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.A_STAR_FINE_GRID) { + return asyncPathFinder.schedule(() -> { + AStarFineGrid pathFinder = + activeBetterAStar.computeIfAbsent(targetPos, (pos) -> new AStarFineGrid(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5))); + pathFinder.pathfind(entityIn.getPositionVector(),timeout); + return pathFinder.getRoute(); + }, 0, TimeUnit.MILLISECONDS); + }else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.A_STAR_DIAGONAL) { + return asyncPathFinder.schedule(() -> { + AStarCornerCut pathFinder = + activeBetterAStarCornerCut.computeIfAbsent(targetPos, (pos) -> new AStarCornerCut(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5))); + pathFinder.pathfind(entityIn.getPositionVector(),timeout); + return pathFinder.getRoute(); + }, 0, TimeUnit.MILLISECONDS); + } else if (pathfindStrategy == FeaturePathfindStrategy.PathfindStrategy.THETA_STAR) { + return asyncPathFinder.schedule(() -> { + ThetaStar pathFinder = + activeThetaStar.computeIfAbsent(targetPos, (pos) -> new ThetaStar(this, new Vec3(pos.getX(), pos.getY(), pos.getZ()).addVector(0.5, 0.5, 0.5))); + pathFinder.pathfind(entityIn.getPositionVector(),timeout); + return pathFinder.getRoute(); + }, 0, TimeUnit.MILLISECONDS); + } else { + return asyncPathFinder.schedule(() -> { + PathFinder pathFinder = new PathFinder(nodeProcessorDungeonRoom); + PathEntity latest = pathFinder.createEntityPathTo(blockaccess, entityIn, targetPos, dist); + if (latest != null) { + List poses = new ArrayList<>(); + for (int i = 0; i < latest.getCurrentPathLength(); i++) { + PathPoint pathPoint = latest.getPathPointFromIndex(i); + poses.add(new Vec3(getMin().add(pathPoint.xCoord, pathPoint.yCoord, pathPoint.zCoord)).addVector(0.5,0.5,0.5)); + } + return poses; + } + return new ArrayList<>(); + }, 0, TimeUnit.MILLISECONDS); + } + } + + private static final ScheduledExecutorService asyncPathFinder = Executors.newScheduledThreadPool(4); + @Getter + private final NodeProcessorDungeonRoom nodeProcessorDungeonRoom; + + @Getter + private final Map roomContext = new HashMap<>(); + + @AllArgsConstructor + @Getter + public enum RoomState { + DISCOVERED(0), COMPLETE_WITHOUT_SECRETS(0), FINISHED(0), FAILED(-14); + private final int scoreModifier; + } + + private RoomProcessor roomProcessor; + + public DungeonRoom(List points, short shape, byte color, BlockPos min, BlockPos max, DungeonContext context, Set> doorsAndStates) { + this.unitPoints = points; + this.shape = shape; + this.color = color; + this.min = min; + this.max = max; + this.context = context; + + minRoomPt = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); + for (Point pt : unitPoints) { + if (pt.x < minRoomPt.x) minRoomPt.x = pt.x; + if (pt.y < minRoomPt.y) minRoomPt.y = pt.y; + } + unitWidth = (int) Math.ceil(max.getX() - min.getX() / 32.0); + unitHeight = (int) Math.ceil(max.getZ() - min.getZ() / 32.0); + + + ChunkCache chunkCache = new ChunkCache(getContext().getWorld(), min.add(-3, 0, -3), max.add(3,0,3), 0); + this.cachedWorld = new CachedWorld(chunkCache); + + + + minx = min.getX() * 2; miny = 0; minz = min.getZ() * 2; + maxx = max.getX() * 2 + 2; maxy = 255 * 2 + 2; maxz = max.getZ() * 2 + 2; + + lenx = maxx - minx; + leny = maxy - miny; + lenz = maxz - minz; + arr = new long[lenx *leny * lenz * 2 / 8];; + + buildDoors(doorsAndStates); + buildRoom(); + nodeProcessorDungeonRoom = new NodeProcessorDungeonRoom(this); + updateRoomProcessor(); + + + } + + private static final Set directions = Sets.newHashSet(new Vector2d(0,16), new Vector2d(0, -16), new Vector2d(16, 0), new Vector2d(-16 , 0)); + + private void buildDoors(Set> doorsAndStates) { + Set> positions = new HashSet<>(); + BlockPos pos = context.getMapProcessor().roomPointToWorldPoint(minRoomPt).add(16,0,16); + for (Tuple doorsAndState : doorsAndStates) { + Vector2d vector2d = doorsAndState.getFirst(); + BlockPos neu = pos.add(vector2d.x * 32, 0, vector2d.y * 32); + positions.add(new Tuple<>(neu, doorsAndState.getSecond())); + } + + for (Tuple door : positions) { + doors.add(new DungeonDoor(context.getWorld(), door.getFirst(), door.getSecond())); + } + } + + private RoomMatcher roomMatcher = null; + private void buildRoom() { + if (roomMatcher == null) + roomMatcher = new RoomMatcher(this); + DungeonRoomInfo dungeonRoomInfo = roomMatcher.match(); + if (dungeonRoomInfo == null) { + dungeonRoomInfo = roomMatcher.createNew(); + if (color == 18) dungeonRoomInfo.setProcessorId("bossroom"); + } + this.dungeonRoomInfo = dungeonRoomInfo; + totalSecrets = dungeonRoomInfo.getTotalSecrets(); + } + + public void updateRoomProcessor() { + RoomProcessorGenerator roomProcessorGenerator = ProcessorFactory.getRoomProcessorGenerator(dungeonRoomInfo.getProcessorId()); + if (roomProcessorGenerator == null) this.roomProcessor = null; + else this.roomProcessor = roomProcessorGenerator.createNew(this); + } + + public Block getAbsoluteBlockAt(int x, int y, int z) { + // validate x y z's + BlockPos pos = new BlockPos(x,y,z); + if (canAccessAbsolute(pos)) { + return cachedWorld.getBlockState(pos).getBlock(); + } + return null; + } + + public Block getRelativeBlockAt(int x, int y, int z) { + // validate x y z's + if (canAccessRelative(x,z)) { + BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ()); + return cachedWorld.getBlockState(pos).getBlock(); + } + return null; + } + + public BlockPos getRelativeBlockPosAt(int x, int y, int z) { + BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ()); + return pos; + } + + public int getRelativeBlockDataAt(int x, int y, int z) { + // validate x y z's + if (canAccessRelative(x,z)) { + BlockPos pos = new BlockPos(x,y,z).add(min.getX(),min.getY(),min.getZ()); + IBlockState iBlockState = cachedWorld.getBlockState(pos); + return iBlockState.getBlock().getMetaFromState(iBlockState); + } + return -1; + } + + public int getAbsoluteBlockDataAt(int x, int y, int z) { + // validate x y z's + BlockPos pos = new BlockPos(x,y,z); + if (canAccessAbsolute(pos)) { + IBlockState iBlockState = cachedWorld.getBlockState(pos); + return iBlockState.getBlock().getMetaFromState(iBlockState); + } + return -1; + } + + public boolean canAccessAbsolute(BlockPos pos) { + MapProcessor mapProcessor = this.context.getMapProcessor(); + Point roomPt = mapProcessor.worldPointToRoomPoint(pos); + roomPt.translate(-minRoomPt.x, -minRoomPt.y); + + return (shape >>(roomPt.y *4 +roomPt.x) & 0x1) > 0; + } + public boolean canAccessRelative(int x, int z) { + return x>= 0 && z >= 0 && (shape >>((z/32) *4 +(x/32)) & 0x1) > 0; + } + + + + long[] arr; + // These values are doubled + private final int minx; + private final int miny; + private final int minz; + private final int maxx; + private final int maxy; + private final int maxz; + private final int lenx, leny, lenz; + private static final float playerWidth = 0.3f; + public boolean isBlocked(int x,int y, int z) { + if (x < minx || z < minz || x >= maxx || z >= maxz || y < miny || y >= maxy) return true; + int dx = x - minx, dy = y - miny, dz = z - minz; + int bitIdx = dx * leny * lenz + dy * lenz + dz; + int location = bitIdx / 4; + int bitStart = (2 * (bitIdx % 4)); + long theBit = arr[location]; + if (((theBit >> bitStart) & 0x2) > 0) return ((theBit >> bitStart) & 1) > 0; + float wX = x / 2.0f, wY = y / 2.0f, wZ = z / 2.0f; + + + AxisAlignedBB bb = AxisAlignedBB.fromBounds(wX - playerWidth, wY, wZ - playerWidth, wX + playerWidth, wY + 1.9f, wZ + playerWidth); + + int i = MathHelper.floor_double(bb.minX); + int j = MathHelper.floor_double(bb.maxX + 1.0D); + int k = MathHelper.floor_double(bb.minY); + int l = MathHelper.floor_double(bb.maxY + 1.0D); + int i1 = MathHelper.floor_double(bb.minZ); + int j1 = MathHelper.floor_double(bb.maxZ + 1.0D); + BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); + + List list = new ArrayList<>(); + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = i1; l1 < j1; ++l1) { + for (int i2 = k - 1; i2 < l; ++i2) { + blockPos.set(k1, i2, l1); + IBlockState iblockstate1 = cachedWorld.getBlockState(blockPos); + Block b = iblockstate1.getBlock(); + if (!b.getMaterial().blocksMovement())continue; + if (b.isFullCube() && i2 == k-1) continue; + if (iblockstate1.equals( NodeProcessorDungeonRoom.preBuilt)) continue; + if (b.isFullCube()) { + theBit |= (3L << bitStart); + arr[location] = theBit; + return true; + } + try { + b.addCollisionBoxesToList(cachedWorld, blockPos, iblockstate1, bb, list, null); + } catch (Exception e) { + return true; + } + if (list.size() > 0) { + theBit |= (3L << bitStart); + arr[location] = theBit; + return true; + } + } + } + } + theBit |= 2L << bitStart; + arr[location] = theBit; + return false; + } + + + public void resetBlock(BlockPos pos) { + for (int x = -1; x <= 1; x++) { + for (int y = -1; y <= 1; y++) { + for (int z = -1; z <= 1; z++) { + resetBlock(pos.getX()*2 + x, pos.getY()*2 + y, pos.getZ()*2 + z); + } + } + } + } + private void resetBlock(int x, int y, int z) { + if (x < minx || z < minz || x >= maxx || z >= maxz || y < miny || y >= maxy) return; + int dx = x - minx, dy = y - miny, dz = z - minz; + int bitIdx = dx * leny * lenz + dy * lenz + dz; + int location = bitIdx / 4; + arr[location] = 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/DungeonRoomInfoRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/DungeonRoomInfoRegistry.java new file mode 100755 index 00000000..72000d38 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/DungeonRoomInfoRegistry.java @@ -0,0 +1,163 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder; + +import com.google.common.io.Files; +import com.google.gson.Gson; +import kr.syeyoung.dungeonsguide.Main; +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import org.apache.commons.io.IOUtils; +import org.jetbrains.annotations.NotNull; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import java.io.*; +import java.nio.charset.Charset; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.*; + +public class DungeonRoomInfoRegistry { + @Getter + private static final List registered = new ArrayList(); + private static final Map> shapeMap = new HashMap>(); + private static final Map uuidMap = new HashMap(); + + static Gson gson = new Gson(); + + public static void register(@NotNull DungeonRoomInfo dungeonRoomInfo) { + +// System.out.println("Loading room: " + dungeonRoomInfo.getUuid()); +// +// File file = new File(Main.getConfigDir() + "/" + "rooms" + "/" + dungeonRoomInfo.getUuid() + ".json"); +// if(!file.exists()){ +// try { +// FileUtils.writeStringToFile(file, gson.toJson(dungeonRoomInfo)); +// } catch (IOException e) { +// throw new RuntimeException(e); +// } +// } + + + + if (uuidMap.containsKey(dungeonRoomInfo.getUuid())) { + DungeonRoomInfo dri1 = uuidMap.get(dungeonRoomInfo.getUuid()); + registered.remove(dri1); + shapeMap.get(dri1.getShape()).remove(dri1); + uuidMap.remove(dri1.getUuid()); + } + dungeonRoomInfo.setRegistered(true); + registered.add(dungeonRoomInfo); + uuidMap.put(dungeonRoomInfo.getUuid(), dungeonRoomInfo); + List roomInfos = shapeMap.get(dungeonRoomInfo.getShape()); + if (roomInfos == null) { + roomInfos = new ArrayList<>(); + } + roomInfos.add(dungeonRoomInfo); + shapeMap.put(dungeonRoomInfo.getShape(), roomInfos); + } + + + public static List getByShape(Short shape) { + List dungeonRoomInfos = shapeMap.get(shape); + return dungeonRoomInfos == null ? Collections.emptyList() : dungeonRoomInfos; + } + + public static DungeonRoomInfo getByUUID(UUID uid) { + return uuidMap.get(uid); + } + + public static void unregister(DungeonRoomInfo dungeonRoomInfo) { + if (!dungeonRoomInfo.isRegistered()) throw new IllegalStateException("what tha fak? that is not registered one"); + if (!uuidMap.containsKey(dungeonRoomInfo.getUuid())) throw new IllegalStateException("what tha fak? that is not registered one, but you desperately wanted to trick this program"); + dungeonRoomInfo.setRegistered(false); + registered.remove(dungeonRoomInfo); + shapeMap.get(dungeonRoomInfo.getShape()).remove(dungeonRoomInfo); + uuidMap.remove(dungeonRoomInfo.getUuid()); + } + + public static void saveAll(File dir) { + dir.mkdirs(); + boolean isDev = Minecraft.getMinecraft().getSession().getPlayerID().replace("-","").equals("e686fe0aab804a71ac7011dc8c2b534c"); + StringBuilder nameidstring = new StringBuilder("name,uuid,processsor,secrets"); + StringBuilder ids = new StringBuilder(); + for (DungeonRoomInfo dungeonRoomInfo : registered) { + try { + if (!dungeonRoomInfo.isUserMade() && !isDev) continue; + FileOutputStream fos = new FileOutputStream(new File(dir, dungeonRoomInfo.getUuid().toString() + ".roomdata")); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(dungeonRoomInfo); + oos.flush(); + oos.close(); + + nameidstring.append("\n").append(dungeonRoomInfo.getName()).append(",").append(dungeonRoomInfo.getUuid()).append(",").append(dungeonRoomInfo.getProcessorId()).append(",").append(dungeonRoomInfo.getTotalSecrets()); + ids.append("roomdata/").append(dungeonRoomInfo.getUuid()).append(".roomdata\n"); + } catch (Exception e) {e.printStackTrace();} + } + + try { + Files.write(nameidstring.toString(), new File(dir, "roomidmapping.csv"), Charset.defaultCharset()); + Files.write(ids.toString(), new File(dir, "datas.txt"), Charset.defaultCharset()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void loadAll(File dir) throws BadPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException, IllegalBlockSizeException, NoSuchPaddingException, InvalidKeyException { + registered.clear(); + shapeMap.clear(); + uuidMap.clear(); + try { + List lines = IOUtils.readLines(Main.class.getResourceAsStream("/roomdata/datas.txt")); + for (String name : lines) { + if (!name.endsWith(".roomdata")) continue; + try { + InputStream fis = Main.class.getResourceAsStream("/"+name); + ObjectInputStream ois = new ObjectInputStream(fis); + DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); + ois.close(); + fis.close(); + register(dri); + } catch (Exception e) { + System.out.println(name); + e.printStackTrace(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + for (File f : dir.listFiles()) { + if (!f.getName().endsWith(".roomdata")) continue; + try { + InputStream fis = new FileInputStream(f); + ObjectInputStream ois = new ObjectInputStream(fis); + DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); + ois.close(); + fis.close(); + register(dri); + } catch (Exception e) { + System.out.println(f.getName());e.printStackTrace();} + } + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/RoomMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/RoomMatcher.java new file mode 100755 index 00000000..994a19d8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomfinder/RoomMatcher.java @@ -0,0 +1,145 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import kr.syeyoung.dungeonsguide.mod.utils.ArrayUtils; +import kr.syeyoung.dungeonsguide.mod.utils.ShortUtils; +import lombok.Getter; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.ChatComponentText; + +import java.util.List; + +public class RoomMatcher { + private final DungeonRoom dungeonRoom; + @Getter + private DungeonRoomInfo match; + @Getter + private int rotation; // how much the "found room" has to rotate clockwise to match the given dungeon room info. ! + private boolean triedMatch = false; + + + public RoomMatcher(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + } + + public DungeonRoomInfo match() { + if (triedMatch) return match; + + int zz = dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 1; + int xx = dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 1; + for (int z = 0; z < zz; z ++) { + for (int x = 0; x < xx; x++) { + if (x % 8 == 0 && z % 8 == 0 && dungeonRoom.getContext().getWorld().getChunkFromBlockCoords(dungeonRoom.getRelativeBlockPosAt(x, 0, z)).isEmpty()) { + ChatTransmitter.sendDebugChat(new ChatComponentText("Chunk Not loaded in Room Matcher")); + } + } + } + + triedMatch = true; + int lowestcost = 10; + int lowestRot = 0; + DungeonRoomInfo bestMatch = null; + for (int rotation = 0; rotation < 4; rotation++) { + short shape = dungeonRoom.getShape(); + for (int j = 0; j roomInfoList = DungeonRoomInfoRegistry.getByShape(shape); + for (DungeonRoomInfo roomInfo : roomInfoList) { + int cost = tryMatching(roomInfo, rotation); + if (cost == 0) { + match = roomInfo; + this.rotation = rotation; + return match; + } + if (cost < lowestcost) { + lowestcost = cost; + bestMatch = roomInfo; + lowestRot = rotation; + } + } + } + match = bestMatch; + this.rotation = lowestRot; + return bestMatch; + } + + private int tryMatching(DungeonRoomInfo dungeonRoomInfo, int rotation) { + if (dungeonRoomInfo.getColor() != dungeonRoom.getColor()) return Integer.MAX_VALUE; + + int[][] res = dungeonRoomInfo.getBlocks(); + for (int i = 0; i < rotation; i++) + res = ArrayUtils.rotateCounterClockwise(res); + + int wrongs = 0; + for (int z = 0; z < res.length; z ++) { + for (int x = 0; x < res[0].length; x++) { + int data = res[z][x]; + if (data == -1) continue; + Block b = dungeonRoom.getRelativeBlockAt(x,0,z); + + if (b == null || Block.getIdFromBlock(b) != data) { + wrongs++; + + if (wrongs > 10) return wrongs; + } + } + } + return wrongs; + } + + private static final int offset = 3; + public DungeonRoomInfo createNew() { + DungeonRoomInfo roomInfo = new DungeonRoomInfo(dungeonRoom.getShape(), dungeonRoom.getColor()); + + int maxX = dungeonRoom.getMax().getX(); + int maxZ = dungeonRoom.getMax().getZ(); + int minX = dungeonRoom.getMin().getX(); + int minZ = dungeonRoom.getMin().getZ(); + int[][] data = new int[dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() +2][dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 2]; + + for (int z = 0; z < data.length; z++) { + for (int x = 0; x < data[0].length; x++) { + if (!(dungeonRoom.canAccessRelative(x + offset, z + offset) + && dungeonRoom.canAccessRelative(x - offset -1 , z - offset-1) + && dungeonRoom.canAccessRelative(x + offset , z - offset-1) + && dungeonRoom.canAccessRelative(x - offset -1 , z + offset))) { + data[z][x] = -1; + continue; + } + + Block b = dungeonRoom.getRelativeBlockAt(x,0,z); + if (b == null || b == Blocks.chest || b == Blocks.trapped_chest) { + data[z][x] = -1; + } else { + data[z][x] = Block.getIdFromBlock(b); + } + } + } + + roomInfo.setBlocks(data); + roomInfo.setUserMade(true); + return roomInfo; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/GeneralRoomProcessor.java new file mode 100755 index 00000000..22cdb20c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/GeneralRoomProcessor.java @@ -0,0 +1,448 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonActionContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionComplete; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionMove; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.ActionMoveNearestAir; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRoute; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonRoomDoor; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.events.impl.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.pathfinding.NodeProcessorDungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonAddSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonRoomEdit; +import kr.syeyoung.dungeonsguide.mod.utils.VectorUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.util.*; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; + +public class GeneralRoomProcessor implements RoomProcessor { + + @Getter + @Setter + private DungeonRoom dungeonRoom; + public GeneralRoomProcessor(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + } + private boolean ticked = false; + + + @Override + public void tick() { + if (!ticked && FeatureRegistry.SECRET_AUTO_START.isEnabled()) { + searchForNextTarget(); + }else if (!ticked && FeatureRegistry.SECRET_PATHFIND_ALL.isEnabled()) { + for (Map.Entry value : getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonSecret && ((DungeonSecret) value.getValue()).getSecretStatus(dungeonRoom) != DungeonSecret.SecretStatus.FOUND) { + DungeonSecret dungeonSecret = (DungeonSecret) value.getValue(); + if (FeatureRegistry.SECRET_PATHFIND_ALL.isBat() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.BAT) + pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_BAT.getRouteProperties()); + if (FeatureRegistry.SECRET_PATHFIND_ALL.isChest() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.CHEST) + pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_CHEST.getRouteProperties()); + if (FeatureRegistry.SECRET_PATHFIND_ALL.isEssence() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.ESSENCE) + pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_ESSENCE.getRouteProperties()); + if (FeatureRegistry.SECRET_PATHFIND_ALL.isItemdrop() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.ITEM_DROP) + pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_ITEM_DROP.getRouteProperties()); + } + } + } else if (!ticked && FeatureRegistry.SECRET_BLOOD_RUSH.isEnabled()) { + for (Map.Entry value : getDungeonRoom().getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonRoomDoor) { + DungeonRoomDoor dungeonDoor = (DungeonRoomDoor) value.getValue(); + if (dungeonDoor.getDoorfinder().getType().isHeadToBlood()) { + pathfind(value.getKey(), "navigate", FeatureRegistry.SECRET_BLOOD_RUSH_LINE_PROPERTIES.getRouteProperties()); + } + } + } + } + ticked = true; + + Set toRemove = new HashSet<>(); + path.entrySet().forEach(a -> { + a.getValue().onTick(); + if (a.getValue().getCurrentAction() instanceof ActionComplete) + toRemove.add(a.getKey()); + }); + toRemove.forEach(path::remove); + + + for (DungeonMechanic value : dungeonRoom.getMechanics().values()) { + if (value instanceof DungeonSecret) ((DungeonSecret) value).tick(dungeonRoom); + } + + if (toRemove.contains("AUTO-BROWSE") && FeatureRegistry.SECRET_AUTO_BROWSE_NEXT.isEnabled()) { + searchForNextTarget(); + } + } + private final Set visited = new HashSet(); + + public void searchForNextTarget() { + if (getDungeonRoom().getCurrentState() == DungeonRoom.RoomState.FINISHED) { + cancelAll(); + return; + } + + BlockPos pos = Minecraft.getMinecraft().thePlayer.getPosition(); + + double lowestCost = 99999999999999.0; + Map.Entry lowestWeightMechanic = null; + for (Map.Entry mech: dungeonRoom.getMechanics().entrySet()) { + if (!(mech.getValue() instanceof DungeonSecret)) continue; + if (visited.contains(mech.getKey())) continue; + if (((DungeonSecret) mech.getValue()).getSecretStatus(getDungeonRoom()) != DungeonSecret.SecretStatus.FOUND) { + double cost = 0; + if (((DungeonSecret) mech.getValue()).getSecretType() == DungeonSecret.SecretType.BAT && + ((DungeonSecret) mech.getValue()).getPreRequisite().size() == 0) { + cost += -100000000; + } + if (mech.getValue().getRepresentingPoint(getDungeonRoom()) == null) continue; + BlockPos blockpos = mech.getValue().getRepresentingPoint(getDungeonRoom()).getBlockPos(getDungeonRoom()); + + cost += blockpos.distanceSq(pos); + cost += ((DungeonSecret) mech.getValue()).getPreRequisite().size() * 100; + + if (cost < lowestCost) { + lowestCost = cost; + lowestWeightMechanic = mech; + } + } + } + if (lowestWeightMechanic != null) { + visited.add(lowestWeightMechanic.getKey()); + pathfind("AUTO-BROWSE", lowestWeightMechanic.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_AUTOPATHFIND.getRouteProperties()); + } else { + visited.clear(); + } + } + + @Override + public void drawScreen(float partialTicks) { + path.values().forEach(a -> { + a.onRenderScreen(partialTicks); + }); + + if (FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && FeatureRegistry.DEBUG.isEnabled()) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + if (Minecraft.getMinecraft().objectMouseOver == null) return; + Entity en = Minecraft.getMinecraft().objectMouseOver.entityHit; + if (en == null) return; + + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + if (DungeonActionContext.getSpawnLocation().containsKey(en.getEntityId())) { + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Spawned at " + DungeonActionContext.getSpawnLocation().get(en.getEntityId()), sr.getScaledWidth() / 2, sr.getScaledHeight() / 2, 0xFFFFFFFF); + } + } + } + + @Override + public void drawWorld(float partialTicks) { + if (FeatureRegistry.DEBUG.isEnabled() && (EditingContext.getEditingContext() != null && EditingContext.getEditingContext().getCurrent() instanceof GuiDungeonRoomEdit)) { + for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() == null) continue; + value.getValue().highlight(new Color(0,255,255,50), value.getKey(), dungeonRoom, partialTicks); + } + } + + + ActionRoute finalSmallest = getBestFit(partialTicks); + path.values().forEach(a -> { + a.onRenderWorld(partialTicks, finalSmallest == a); + }); + } + + private ActionRoute getBestFit(float partialTicks) { + + ActionRoute smallest = null; + double smallestTan = 0.002; + for (ActionRoute value : path.values()) { + BlockPos target; + if (value.getCurrentAction() instanceof ActionMove) { + target = ((ActionMove) value.getCurrentAction()).getTarget().getBlockPos(dungeonRoom); + } else if (value.getCurrentAction() instanceof ActionMoveNearestAir) { + target = ((ActionMoveNearestAir) value.getCurrentAction()).getTarget().getBlockPos(dungeonRoom); + } else if (value.getCurrent() >= 1 && value.getActions().get(value.getCurrent()-1) instanceof ActionMove) { + target = ((ActionMove)value.getActions().get(value.getCurrent()-1)).getTarget().getBlockPos(dungeonRoom); + } else if (value.getCurrent() >= 1 && value.getActions().get(value.getCurrent()-1) instanceof ActionMoveNearestAir) { + target = ((ActionMoveNearestAir)value.getActions().get(value.getCurrent()-1)).getTarget().getBlockPos(dungeonRoom); + } else continue; + + if (value.getActionRouteProperties().getLineRefreshRate() != -1 && value.getActionRouteProperties().isPathfind() && !FeatureRegistry.SECRET_FREEZE_LINES.isEnabled()) continue; + + Entity e = Minecraft.getMinecraft().getRenderViewEntity(); + + double vectorV = VectorUtils.distSquared(e.getLook(partialTicks), e.getPositionEyes(partialTicks), new Vec3(target).addVector(0.5,0.5,0.5)); + + if (vectorV < smallestTan) { + smallest = value; + smallestTan = vectorV; + } + } + return smallest; + } + + @Override + public void chatReceived(IChatComponent chat) { + if (lastChest != null && chat.getFormattedText().equals("ยงrยงcThis chest has already been searched!ยงr")) { + getDungeonRoom().getRoomContext().put("c-"+lastChest.toString(), 2); + lastChest = null; + } + } + + private int stack = 0; + private long secrets2 = 0; + @Override + public void actionbarReceived(IChatComponent chat) { + if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + if (dungeonRoom.getTotalSecrets() == -1) { + ChatTransmitter.sendDebugChat(new ChatComponentText(chat.getFormattedText().replace('ยง', '&') + " - received")); + } + if (!chat.getFormattedText().contains("/")) return; + BlockPos pos = Minecraft.getMinecraft().thePlayer.getPosition(); + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + Point pt1 = context.getMapProcessor().worldPointToRoomPoint(pos.add(2, 0, 2)); + Point pt2 = context.getMapProcessor().worldPointToRoomPoint(pos.add(-2, 0, -2)); + if (!pt1.equals(pt2)) { + stack = 0; + secrets2 = -1; + return; + } + BlockPos pos2 = dungeonRoom.getMin().add(5, 0, 5); + + String text = chat.getFormattedText(); + int secretsIndex = text.indexOf("Secrets"); + int secrets = 0; + if (secretsIndex != -1) { + int theindex = 0; + for (int i = secretsIndex; i >= 0; i--) { + if (text.startsWith("ยง7", i)) { + theindex = i; + } + } + String it = text.substring(theindex + 2, secretsIndex - 1); + + secrets = Integer.parseInt(it.split("/")[1]); + } + + if (secrets2 == secrets) stack++; + else { + stack = 0; + secrets2 = secrets; + } + + if (stack == 4 && dungeonRoom.getTotalSecrets() != secrets) { + dungeonRoom.setTotalSecrets(secrets); + if (FeatureRegistry.DUNGEON_INTERMODCOMM.isEnabled()) + Minecraft.getMinecraft().thePlayer.sendChatMessage("/pchat $DG-Comm " + pos2.getX() + "/" + pos2.getZ() + " " + secrets); + } + } + + @Override + public boolean readGlobalChat() { + return false; + } + + @Getter + private Map path = new HashMap<>(); + + public ActionRoute getPath(String id){ + return path.get(id); + } + + public String pathfind(String mechanic, String state, ActionRouteProperties actionRouteProperties) { + String str = UUID.randomUUID().toString(); + pathfind(str, mechanic, state, actionRouteProperties); + return str; + } + public void pathfind(String id, String mechanic, String state, ActionRouteProperties actionRouteProperties) { + path.put(id, new ActionRoute(getDungeonRoom(), mechanic, state, actionRouteProperties)); + } + public void cancelAll() { + path.clear(); + } + public void cancel(String id) { + path.remove(id); + } + + @Override + public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { + + } + + @Override + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + if (updateEvent.entityLiving instanceof EntityArmorStand && + updateEvent.entityLiving.getName() != null && + updateEvent.entityLiving.getName().contains("Mimic") && + !dungeonRoom.getContext().isGotMimic()) { + dungeonRoom.getContext().setGotMimic(true); +// Minecraft.getMinecraft().thePlayer.sendChatMessage("/pc $DG-Mimic"); + } + } + + @Override + public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { + if (FeatureRegistry.SECRET_NEXT_KEY.isEnabled() && FeatureRegistry.SECRET_NEXT_KEY.getParameter("key").getValue() == keyInputEvent.getKey()) { + searchForNextTarget(); + } else if (FeatureRegistry.SECRET_CREATE_REFRESH_LINE.getKeybind() == keyInputEvent.getKey() && FeatureRegistry.SECRET_CREATE_REFRESH_LINE.isEnabled()) { + ActionRoute actionRoute = getBestFit(0); + // actually do force refresh because of force freeze pathfind + if (actionRoute.getCurrentAction() instanceof ActionMove) { + ActionMove ac = (ActionMove) actionRoute.getCurrentAction(); + ac.forceRefresh(getDungeonRoom()); + } else if (actionRoute.getCurrentAction() instanceof ActionMoveNearestAir) { + ActionMoveNearestAir ac = (ActionMoveNearestAir) actionRoute.getCurrentAction(); + ac.forceRefresh(getDungeonRoom()); + } else if (actionRoute.getCurrent() >= 1 && actionRoute.getActions().get(actionRoute.getCurrent()-1) instanceof ActionMove) { + ((ActionMove)actionRoute.getActions().get(actionRoute.getCurrent()-1)).forceRefresh(dungeonRoom); + } else if (actionRoute.getCurrent() >= 1 && actionRoute.getActions().get(actionRoute.getCurrent()-1) instanceof ActionMoveNearestAir) { + ((ActionMoveNearestAir)actionRoute.getActions().get(actionRoute.getCurrent()-1)).forceRefresh(dungeonRoom); + } + + if (FeatureRegistry.SECRET_CREATE_REFRESH_LINE.isPathfind() && !actionRoute.getActionRouteProperties().isPathfind()) { + actionRoute.getActionRouteProperties().setPathfind(true); + actionRoute.getActionRouteProperties().setLineRefreshRate(FeatureRegistry.SECRET_CREATE_REFRESH_LINE.getRefreshRate()); + } + } + } + + @Override + public void onInteract(PlayerInteractEntityEvent event) { + path.values().forEach(a -> { + a.onLivingInteract(event); + }); + } + + private boolean last = false; + private BlockPos lastChest; + @Override + public void onInteractBlock(PlayerInteractEvent event) { + path.values().forEach(a -> { + a.onPlayerInteract(event); + }); + + if (event.pos != null) { + IBlockState iBlockState = event.world.getBlockState(event.pos); + if (iBlockState.getBlock() == Blocks.chest || iBlockState.getBlock() == Blocks.trapped_chest) + lastChest = event.pos; + } + + if (event.entityPlayer.getHeldItem() != null && + event.entityPlayer.getHeldItem().getItem() == Items.stick && + FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && + FeatureRegistry.DEBUG.isEnabled()) { + EditingContext ec = EditingContext.getEditingContext(); + if (ec == null) return; + if (!(ec.getCurrent() instanceof GuiDungeonAddSet)) return; + GuiDungeonAddSet gdas = (GuiDungeonAddSet) ec.getCurrent(); + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + if (last) + gdas.getEnd().setPosInWorld(getDungeonRoom(), event.pos); + else + gdas.getStart().setPosInWorld(getDungeonRoom(), event.pos); + + last = !last; + } + } + } + + @Override + public void onEntityDeath(LivingDeathEvent deathEvent) { + path.values().forEach(a -> { + a.onLivingDeath(deathEvent); + }); + if (EditingContext.getEditingContext() != null && EditingContext.getEditingContext().getRoom() == getDungeonRoom()) { + if (deathEvent.entity instanceof EntityBat) { + for (GuiScreen screen : EditingContext.getEditingContext().getGuiStack()) { + if (screen instanceof GuiDungeonRoomEdit) { + DungeonSecret secret = new DungeonSecret(); + secret.setSecretType(DungeonSecret.SecretType.BAT); + secret.setSecretPoint(new OffsetPoint(dungeonRoom, + DungeonActionContext.getSpawnLocation().get(deathEvent.entity.getEntityId()) + )); + ((GuiDungeonRoomEdit) screen).getSep().createNewMechanic("BAT-"+ UUID.randomUUID(), + secret); + return; + } + } + if (EditingContext.getEditingContext().getCurrent() instanceof GuiDungeonRoomEdit) { + DungeonSecret secret = new DungeonSecret(); + secret.setSecretType(DungeonSecret.SecretType.BAT); + secret.setSecretPoint(new OffsetPoint(dungeonRoom, + DungeonActionContext.getSpawnLocation().get(deathEvent.entity.getEntityId()) + )); + ((GuiDungeonRoomEdit) EditingContext.getEditingContext().getCurrent()).getSep().createNewMechanic("BAT-"+ UUID.randomUUID(), + secret); + } + } + } + } + @Override + public void onBlockUpdate(BlockUpdateEvent blockUpdateEvent) { + for (Tuple updatedBlock : blockUpdateEvent.getUpdatedBlocks()) { + if (updatedBlock.getSecond().equals(NodeProcessorDungeonRoom.preBuilt)) continue; + dungeonRoom.resetBlock(updatedBlock.getFirst()); + } + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public GeneralRoomProcessor createNew(DungeonRoom dungeonRoom) { + GeneralRoomProcessor defaultRoomProcessor = new GeneralRoomProcessor(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/ProcessorFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/ProcessorFactory.java new file mode 100755 index 00000000..1c61a45d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/ProcessorFactory.java @@ -0,0 +1,65 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.boxpuzzle.RoomProcessorBoxSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.icefill.RoomProcessorIcePath2; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.RoomProcessorWaterPuzzle; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class ProcessorFactory { + private static final Map map = new HashMap<>(); + + public static RoomProcessorGenerator getRoomProcessorGenerator(String processorId) { + return map.get(processorId); + } + + public static void registerRoomProcessor(String processorId, RoomProcessorGenerator generator) { + map.put(processorId, generator); + } + + public static Set getProcessors() { + return map.keySet(); + } + + static { + registerRoomProcessor("default", new GeneralRoomProcessor.Generator()); + registerRoomProcessor("button_5", new RoomProcessorButtonSolver.Generator()); + registerRoomProcessor("puzzle_water_solver", new RoomProcessorWaterPuzzle.Generator()); + registerRoomProcessor("puzzle_teleport_solver", new RoomProcessorTeleportMazeSolver.Generator()); + registerRoomProcessor("puzzle_riddle_solver", new RoomProcessorRiddle.Generator()); + registerRoomProcessor("puzzle_creeper_solver", new RoomProcessorCreeperSolver.Generator()); + registerRoomProcessor("puzzle_tictactoe_solver", new RoomProcessorTicTacToeSolver.Generator()); + + registerRoomProcessor("puzzle_blaze_solver", new RoomProcessorBlazeSolver.Generator()); + + + registerRoomProcessor("puzzle_silverfish", new RoomProcessorIcePath.Generator()); // done + registerRoomProcessor("puzzle_icefill", new RoomProcessorIcePath2.Generator()); + registerRoomProcessor("puzzle_box", new RoomProcessorBoxSolver.Generator()); + registerRoomProcessor("puzzle_trivia", new RoomProcessorTrivia.Generator()); + registerRoomProcessor("puzzle_bombdefuse", new RoomProcessorBombDefuseSolver.Generator()); + + registerRoomProcessor("bossroom", new RoomProcessorRedRoom.Generator()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessor.java new file mode 100755 index 00000000..96b9fb72 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessor.java @@ -0,0 +1,49 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.mod.events.impl.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +public interface RoomProcessor { + void tick(); + void drawScreen(float partialTicks); + void drawWorld(float partialTicks); + void chatReceived(IChatComponent chat); + void actionbarReceived(IChatComponent chat); + + boolean readGlobalChat(); + + void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event); + void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent); + void onEntityDeath(LivingDeathEvent deathEvent); + + void onKeybindPress(KeyBindPressedEvent keyInputEvent); + + void onInteract(PlayerInteractEntityEvent event); + void onInteractBlock(PlayerInteractEvent event); + + void onBlockUpdate(BlockUpdateEvent blockUpdateEvent); +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorBlazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorBlazeSolver.java new file mode 100755 index 00000000..f36fd71b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorBlazeSolver.java @@ -0,0 +1,201 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.util.*; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { + + private boolean highToLow = false; + + private List entityList = new ArrayList(); + private List blazeList = new ArrayList<>(); + private EntityArmorStand next; + private EntityBlaze nextBlaze, theoneafterit; + public RoomProcessorBlazeSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + Object highToLow = dungeonRoom.getDungeonRoomInfo().getProperties().get("order"); + if (highToLow == null) this.highToLow = false; + else this.highToLow = (Boolean) highToLow; + } + + @Override + public void tick() { + super.tick(); + + DungeonRoom dungeonRoom = getDungeonRoom(); + World w = dungeonRoom.getContext().getWorld(); + final BlockPos low = dungeonRoom.getMin(); + final BlockPos high = dungeonRoom.getMax(); + entityList = new ArrayList(w.getEntities(EntityArmorStand.class, input -> { + BlockPos pos = input.getPosition(); + return low.getX() < pos.getX() && pos.getX() < high.getX() + && low.getZ() < pos.getZ() && pos.getZ() < high.getZ() && input.getName().toLowerCase().contains("blaze"); + })); + blazeList = new ArrayList(w.getEntities(EntityBlaze.class, input -> { + BlockPos pos = input.getPosition(); + return low.getX() < pos.getX() && pos.getX() < high.getX() + && low.getZ() < pos.getZ() && pos.getZ() < high.getZ(); + })); + + Comparator comparator = Comparator.comparingInt(a -> { + String name = a.getName(); + String colorGone = TextUtils.stripColor(name); + String health2 = TextUtils.keepIntegerCharactersOnly(colorGone.split("/")[1]); + try { + return Integer.parseInt(health2); + } catch (Exception e) {return -1;} + }); + if (highToLow) { + entityList.sort(comparator.reversed()); + } else { + entityList.sort(comparator); + } + + if (entityList.size() > 0) { + next = entityList.get(0); + nextBlaze = blazeList.stream().min(Comparator.comparingDouble(e -> e.getDistanceSqToEntity(next))).orElse(null); + } else { + next = null; + nextBlaze = null; + } + if (entityList.size() > 1) { + EntityArmorStand thenextone = entityList.get(1); + theoneafterit = blazeList.stream().min(Comparator.comparingDouble(e -> e.getDistanceSqToEntity(thenextone))).orElse(null); + } else { + theoneafterit = null; + } + } + + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_BLAZE.isEnabled()) return; + if (next == null) return; + Vec3 pos = next.getPositionEyes(partialTicks); + RenderUtils.drawTextAtWorld("NEXT", (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, 0xFFFF0000, 0.5f, true, false, partialTicks); + + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + + for (EntityBlaze entity : blazeList) { + GlStateManager.pushMatrix(); + float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks; + double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks; + double y = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks; + double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks; + + + GL11.glEnable(GL11.GL_STENCIL_TEST); + GL11.glClearStencil(0); + GlStateManager.disableDepth(); + GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); + + GL11.glStencilMask(0xFF); + GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.colorMask(false, false, false, false); + Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, x,y,z,f,partialTicks, true); + GlStateManager.colorMask(true, true, true, true); + + GlStateManager.popMatrix(); + + + GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); + +// Gui.drawRect(-9999,-9999, 9999, 9999, 0xFFFFFFFF); + + boolean border = true; + + RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-0.8,0, -0.8, 0.8, 2, 0.8), FeatureRegistry.SOLVER_BLAZE.getBlazeColor(), partialTicks, false); + if (entity == theoneafterit) { + RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-0.8,0, -0.8, 0.8, 2, 0.8), FeatureRegistry.SOLVER_BLAZE.getNextUpBlazeColor(), partialTicks, false); + } else if (entity == nextBlaze) + RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-0.8,0, -0.8, 0.8, 2, 0.8), FeatureRegistry.SOLVER_BLAZE.getNextBlazeColor(), partialTicks, false); + + GlStateManager.color(1,1,1,1); + + + if (FeatureRegistry.SOLVER_BLAZE.getParameter("blazeborder").getValue().getAlpha() > 0x10) { + GL11.glStencilFunc(GL11.GL_NOTEQUAL, 3, 0x01); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + GlStateManager.translate(x, y + 0.7, z); + GlStateManager.scale(1.1f, 1.1f, 1.1f); + + GlStateManager.colorMask(false, false, false, false); + Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0, -0.7, 0, f, partialTicks, true); + GlStateManager.colorMask(true, true, true, true); + + GlStateManager.popMatrix(); + + + + GL11.glStencilFunc(GL11.GL_EQUAL, 3, 0xFF); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); + + RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-1, 0, -1, 1, 2, 1), FeatureRegistry.SOLVER_BLAZE.getParameter("blazeborder").getValue(), partialTicks, false); + + + } + GL11.glDisable(GL11.GL_STENCIL_TEST); + GlStateManager.enableDepth(); + GlStateManager.popMatrix(); + } + } + + + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorBlazeSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorBlazeSolver defaultRoomProcessor = new RoomProcessorBlazeSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorButtonSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorButtonSolver.java new file mode 100644 index 00000000..709922a0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorButtonSolver.java @@ -0,0 +1,132 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.util.BlockPos; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.awt.*; +import java.util.Arrays; + +public class RoomProcessorButtonSolver extends GeneralRoomProcessor { + public RoomProcessorButtonSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + + OffsetPointSet ops = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("buttons"); + if (ops == null) { + bugged = true; + return; + } + + buttons = new BlockPos[12]; + woods = new BlockPos[12]; + for (int i = 0; i < ops.getOffsetPointList().size(); i++) { + buttons[i] = ops.getOffsetPointList().get(i).getBlockPos(dungeonRoom); + woods[i] = buttons[i].add(0,-1,0); + } + } + + private boolean bugged; + + private BlockPos[] buttons; + private BlockPos[] woods; + + private long clicked; + private int clickedButton = -1; + + private final int[] result = new int[12]; + + @Override + public void onInteractBlock(PlayerInteractEvent event) { + super.onInteractBlock(event); + if (bugged) return; + + if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return; + for (int i = 0; i < buttons.length; i++) { + if (event.pos.equals(buttons[i])) { + clicked = System.currentTimeMillis(); + clickedButton = i; + return; + } + } + } + + @Override + public void chatReceived(IChatComponent chat) { + super.chatReceived(chat); + if (bugged) return; + + if (clickedButton == -1) return; + if (clicked + 500 < System.currentTimeMillis()) return; + + String msg = chat.getFormattedText(); + if (msg.equals("ยงrยงcThis button doesn't seem to do anything...ยงr")) { + result[clickedButton] = -1; + clickedButton = -1; + } else if (msg.equals("ยงrยงaThis button seems connected to somethingยงr")) { + Arrays.fill(result, -1); + if (clickedButton % 4 != 0) result[clickedButton - 1] = 1; + if (clickedButton % 4 != 3) result[clickedButton + 1] = 1; + clickedButton = -1; + } else if (msg.equals("ยงrยงaClick! you Hear the sound of a door openingยงr")) { + Arrays.fill(result, -1); + result[clickedButton] = 2; + clickedButton = -1; + } else if (msg.equals("ยงrยงaWrong button, looks like the system reset!ยงr")) { + Arrays.fill(result, 0); + clickedButton = -1; + } + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (bugged) return; + if (Minecraft.getMinecraft().thePlayer.getPosition().distanceSq(woods[6]) > 100) return; + + + for (int i = 0; i < woods.length; i++) { + int data = result[i]; + BlockPos pos = woods[i]; + + if (data == 0) { + RenderUtils.highlightBlock(pos, new Color(0, 255, 255, 50), partialTicks, false); + } else if (data == -1) { + RenderUtils.highlightBlock(pos, new Color(255, 0, 0, 50), partialTicks, false); + } else if (data == 1) { + RenderUtils.highlightBlock(pos, new Color(0, 255, 0, 50), partialTicks, false); + } else if (data == 2) { + RenderUtils.highlightBlock(pos, new Color(0, 255, 0, 100), partialTicks, false); + } + } + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorButtonSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorButtonSolver defaultRoomProcessor = new RoomProcessorButtonSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorCreeperSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorCreeperSolver.java new file mode 100755 index 00000000..b2c236c8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorCreeperSolver.java @@ -0,0 +1,148 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class RoomProcessorCreeperSolver extends GeneralRoomProcessor { + + private final List poses = new ArrayList(); + + private final boolean bugged = false; + + public RoomProcessorCreeperSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + + findCreeperAndDoPoses(); + } + + private boolean check(AxisAlignedBB axis, Vec3 vec) { + if (vec == null) return false; + return axis.isVecInside(vec); + } + + private void findCreeperAndDoPoses() { + World w = getDungeonRoom().getContext().getWorld(); + List prismarines = new ArrayList(); + final BlockPos low = getDungeonRoom().getMin().add(0,-2,0); + final BlockPos high = getDungeonRoom().getMax().add(0,20,0); + final AxisAlignedBB axis = AxisAlignedBB.fromBounds( + low.getX() + 17, low.getY() + 7, low.getZ() + 17, + low.getX() + 16, low.getY() + 10.5, low.getZ() + 16 + ); + + for (BlockPos pos : BlockPos.getAllInBox(low, high)) { + Block b = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos).getBlock(); + if (b == Blocks.prismarine || b == Blocks.sea_lantern) { + for (EnumFacing face:EnumFacing.VALUES) { + if (w.getBlockState(pos.offset(face)).getBlock() == Blocks.air) { + prismarines.add(pos); + break; + } + } + } + } + double offset = 0.1; + + while (prismarines.size() > 1) { + BlockPos first = prismarines.get(0); + BlockPos highestMatch = null; + int highestDist = 0; + label: for (int i = 1; i < prismarines.size(); i++) { + BlockPos second = prismarines.get(i); + + if (second.distanceSq(first) < highestDist) continue; + + Vec3 startLoc = new Vec3(first).addVector(0.5,0.5,0.5); + Vec3 dest = new Vec3(second).addVector(0.5,0.5,0.5); + if (check(axis, startLoc.getIntermediateWithYValue(dest, axis.minY+offset)) || + check(axis, startLoc.getIntermediateWithYValue(dest, axis.maxY-offset)) || + check(axis, startLoc.getIntermediateWithXValue(dest, axis.minX+offset)) || + check(axis, startLoc.getIntermediateWithXValue(dest, axis.maxX-offset)) || + check(axis, startLoc.getIntermediateWithZValue(dest, axis.minZ+offset)) || + check(axis, startLoc.getIntermediateWithZValue(dest, axis.maxZ-offset))) { + highestDist = (int) second.distanceSq(first); + highestMatch = second; + } + + } + + + if (highestMatch == null) { + prismarines.remove(first); + } else { + prismarines.remove(first); + prismarines.remove(highestMatch); + poses.add(new BlockPos[] {first, highestMatch}); + } + } + } + + @Override + public void tick() { + super.tick(); + if (bugged) { + findCreeperAndDoPoses(); + } + } + + private static final Color[] colors = new Color[] {Color.red, Color.orange, Color.green, Color.cyan, Color.blue, Color.pink, Color.yellow, Color.darkGray, Color.lightGray}; + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_CREEPER.isEnabled()) return; + World w = getDungeonRoom().getContext().getWorld(); + for (int i = 0; i < poses.size(); i++) { + BlockPos[] poset = poses.get(i); + Color color = colors[i % colors.length]; + boolean oneIsConnected = w.getChunkFromBlockCoords(poset[0]).getBlock(poset[0]) != Blocks.sea_lantern && + w.getChunkFromBlockCoords(poset[1]).getBlock(poset[1]) != Blocks.sea_lantern; + RenderUtils.drawLine(new Vec3(poset[0].getX() +0.5, poset[0].getY() +0.5, poset[0].getZ()+0.5), + new Vec3(poset[1].getX() +0.5, poset[1].getY() +0.5, poset[1].getZ()+0.5), oneIsConnected ? new Color(0,0,0,50) : color, partialTicks, true); + } + final BlockPos low = getDungeonRoom().getMin(); + final AxisAlignedBB axis = AxisAlignedBB.fromBounds( + low.getX() + 17, low.getY() + 5, low.getZ() + 17, + low.getX() + 16, low.getY() + 8.5, low.getZ() + 16 + ); + RenderUtils.highlightBox(axis, new Color(0x4400FF00, true), partialTicks, false); + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorCreeperSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorCreeperSolver defaultRoomProcessor = new RoomProcessorCreeperSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorGenerator.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorGenerator.java new file mode 100755 index 00000000..969424d9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorGenerator.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; + +public interface RoomProcessorGenerator { + T createNew(DungeonRoom dungeonRoom); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorIcePath.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorIcePath.java new file mode 100755 index 00000000..df902858 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorIcePath.java @@ -0,0 +1,234 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class RoomProcessorIcePath extends GeneralRoomProcessor { + + private int[][] map; + private OffsetPoint[][] map2; + private final Set endNode = new HashSet(); + + private final List solution = new ArrayList(); + + private BlockPos lastSilverfishLoc; + private int sameTick; + + private Entity silverfish; + + private boolean err; + + public RoomProcessorIcePath(DungeonRoom dungeonRoom) { + super(dungeonRoom); + findSilverFishanddoStuff(); + } + + public void findSilverFishanddoStuff() { + final BlockPos low = getDungeonRoom().getMin(); + final BlockPos high = getDungeonRoom().getMax(); + List silverfishs = getDungeonRoom().getContext().getWorld().getEntities(EntitySilverfish.class, new Predicate() { + @Override + public boolean apply(@Nullable EntitySilverfish input) { + if (input.isInvisible()) return false; + BlockPos pos = input.getPosition(); + return low.getX() < pos.getX() && pos.getX() < high.getX() + && low.getZ() < pos.getZ() && pos.getZ() < high.getZ(); + } + }); + + if (!silverfishs.isEmpty()) silverfish = silverfishs.get(0); + if (silverfishs.isEmpty()) { + err = true; + return; + } + try { + buildMap(); + err = false; + } catch (Exception e) { + e.printStackTrace(); + err = true; + return; + } + } + + private void buildMap() { + int width = (Integer) getDungeonRoom().getDungeonRoomInfo().getProperties().get("width"); + int height = (Integer) getDungeonRoom().getDungeonRoomInfo().getProperties().get("height"); + OffsetPointSet ops = (OffsetPointSet) getDungeonRoom().getDungeonRoomInfo().getProperties().get("board"); + OffsetPointSet endNodes = (OffsetPointSet) getDungeonRoom().getDungeonRoomInfo().getProperties().get("endnodes"); + map2 = new OffsetPoint[width][height]; + map = new int[width][height]; + for (int y = 0; y < height; y ++) { + for (int x =0; x < width; x++) { + OffsetPoint op = ops.getOffsetPointList().get(y * width + x); + map2[y][x] = op; + map[y][x] = op.getBlock(getDungeonRoom()) == Blocks.air ? 0 : 1; + } + } + endNode.addAll(endNodes.getOffsetPointList()); + } + + public void tick() { + super.tick(); + if (err || silverfish.isDead) { + findSilverFishanddoStuff(); + if (err) return; + } + if (silverfish.getPosition().equals(lastSilverfishLoc)) { + if (sameTick < 10) { + sameTick ++; + return; + } else if (sameTick == 10) { + sameTick ++; + Point silverfish = getPointOfSilverFishOnMap(this.silverfish.getPosition()); + List tempSol = solve(map, silverfish.x, silverfish.y, new Predicate() { + @Override + public boolean apply(@Nullable Point input) { + return endNode.contains(map2[input.y][input.x]); + } + }); + { + solution.clear(); + for (Point point : tempSol) { + solution.add(map2[point.y][point.x].getBlockPos(getDungeonRoom())); + } + } + + } + } else { + sameTick = 0; + } + + lastSilverfishLoc = silverfish.getPosition(); + } + + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_SILVERFISH.isEnabled()) return; + if (!err) + RenderUtils.drawLines(solution, FeatureRegistry.SOLVER_SILVERFISH.getLineColor(),FeatureRegistry.SOLVER_SILVERFISH.getLineWidth(), partialTicks, true); + } + + public Point getPointOfSilverFishOnMap(BlockPos blockPos) { + for (int y = 0; y < map.length; y ++) { + for (int x = 0; x < map[0].length; x++) { + if (map2[y][x].getBlockPos(getDungeonRoom()).equals(blockPos)) + return new Point(x,y); + } + } + return null; + } + + + // Taken from https://stackoverflow.com/a/55271133 and modified to suit our needs + // Answer by ofekp (https://stackoverflow.com/users/4295037/ofekp) + public static List solve(int[][] board, int startX, int startY, Predicate finishLinePredicate) { + Point startPoint = new Point(startX, startY); + + LinkedList queue = new LinkedList(); + Point[][] boardSearch = new Point[board.length][board[0].length]; + + queue.addLast(new Point(startX, startY)); + boardSearch[startY][startX] = startPoint; + + while (queue.size() != 0) { + Point currPos = queue.pollFirst(); + for (Direction dir : Direction.values()) { + Point nextPos = move(board, boardSearch, currPos, dir); + if (nextPos != null) { + queue.addLast(nextPos); + boardSearch[nextPos.y][nextPos.x] = new Point(currPos.x, currPos.y); + if (finishLinePredicate.apply(nextPos)) { + List route = new ArrayList(); + Point tmp = currPos; + route.add(nextPos); + route.add(currPos); + while (tmp != startPoint) { + tmp = boardSearch[tmp.y][tmp.x]; + route.add(tmp); + } + return route; + } + } + } + } + return Collections.emptyList(); + } + + public static Point move(int[][] board, Point[][] boardSearch, Point currPos, Direction dir) { + int x = currPos.x; + int y = currPos.y; + + int diffX = dir.dx; + int diffY = dir.dy; + + int i = 1; + while (x + i * diffX >= 0 && x + i * diffX < board[0].length + && y + i * diffY >= 0 && y + i * diffY < board.length + && board[y + i * diffY][x + i * diffX] != 1) { + i++; + } + i--; + + if (boardSearch[y + i * diffY][x + i * diffX] != null) { + return null; + } + + return new Point(x + i * diffX, y + i * diffY); + } + + @Getter + @AllArgsConstructor + public enum Direction { + LEFT(-1,0), + RIGHT(1,0), + UP(0,-1), + DOWN(0,1); + + int dx, dy; + } + + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorIcePath createNew(DungeonRoom dungeonRoom) { + RoomProcessorIcePath defaultRoomProcessor = new RoomProcessorIcePath(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorRedRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorRedRoom.java new file mode 100644 index 00000000..d171c928 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorRedRoom.java @@ -0,0 +1,121 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.impl.boss.FeatureWarningOnPortal; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledTextRenderer; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; + +import javax.vecmath.Vector3f; + +public class RoomProcessorRedRoom extends GeneralRoomProcessor { + public RoomProcessorRedRoom(DungeonRoom dungeonRoom) { + super(dungeonRoom); + BlockPos basePt = dungeonRoom.getMin().add(dungeonRoom.getMax()); + this.basePt = new Vec3(basePt.getX() / 2.0f, basePt.getY() / 2.0f, basePt.getZ() / 2.0f); + } + + Vec3 basePt; + int dir = 0; + + @Override + public void tick() { + BlockPos basePt = getDungeonRoom().getMin().add(getDungeonRoom().getMax()); + this.basePt = new Vec3(basePt.getX() / 2.0f, basePt.getY() / 2.0f + 4, basePt.getZ() / 2.0f); + DungeonDoor real = null; + for (DungeonDoor door : getDungeonRoom().getDoors()) { + if (door.getType().isExist()) { + real = door;break; + } + } + if (real != null) { + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), real.getPosition()); + offsetPoint = new OffsetPoint(33- offsetPoint.getX(), offsetPoint.getY(), 33 - offsetPoint.getZ()); + BlockPos opposite =offsetPoint.getBlockPos(getDungeonRoom()); + BlockPos dir = new BlockPos(real.getPosition().subtract(opposite)); + dir = new BlockPos(MathHelper.clamp_int(dir.getX() / 10, -1, 1), 0, MathHelper.clamp_int(dir.getZ() / 10, -1, 1)); + + this.basePt = new Vec3(opposite.add(dir.getX() * 6 + dir.getZ(), 3, dir.getZ() * 6 - dir.getX())); + + if (dir.getX() > 0) this.dir = 270; + else if (dir.getX() < 0) this.dir = 90; + else if (dir.getZ() < 0) this.dir = 0; + else if (dir.getZ() > 0) this.dir = 180; + else this.dir = Integer.MIN_VALUE; + } else { + dir = Integer.MIN_VALUE; + } + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.BOSSFIGHT_WARNING_ON_PORTAL.isEnabled()) return; + + + FeatureWarningOnPortal featureWarningOnPortal = FeatureRegistry.BOSSFIGHT_WARNING_ON_PORTAL; + { + RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); + + Vector3f renderPos = RenderUtils.getRenderPos((float)basePt.xCoord,(float) basePt.yCoord, (float)basePt.zCoord, partialTicks); + + GlStateManager.color(1f, 1f, 1f, 0.5f); + GlStateManager.pushMatrix(); + GlStateManager.translate(renderPos.x, renderPos.y, renderPos.z); + if (dir == Integer.MIN_VALUE) + GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); + else + GlStateManager.rotate(dir, 0.0f, 1.0f, 0.0f); + GlStateManager.scale(-0.05f, -0.05f, 0.05f); + GlStateManager.disableLighting(); + GlStateManager.depthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + + StyledTextRenderer.drawTextWithStylesAssociated(featureWarningOnPortal.getText(), 0, 0,0, featureWarningOnPortal.getStylesMap(), StyledTextRenderer.Alignment.LEFT); + + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GlStateManager.depthMask(true); + GlStateManager.enableDepth(); + GlStateManager.popMatrix(); + } + } + + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorRedRoom createNew(DungeonRoom dungeonRoom) { + RoomProcessorRedRoom defaultRoomProcessor = new RoomProcessorRedRoom(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorRiddle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorRiddle.java new file mode 100755 index 00000000..f7a0b65f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorRiddle.java @@ -0,0 +1,121 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +public class RoomProcessorRiddle extends GeneralRoomProcessor { + + public RoomProcessorRiddle(DungeonRoom dungeonRoom) { + super(dungeonRoom); + } + + private static final List patternList = Arrays.asList( + Pattern.compile("My chest doesn't have the reward. We are all telling the truth.*"), + Pattern.compile("The reward isn't in any of our chests.*"), + Pattern.compile("The reward is not in my chest!.*"), + Pattern.compile("At least one of them is lying, and the reward is not in .+'s chest.*"), + Pattern.compile("Both of them are telling the truth. Also,.+has the reward in their chest.*"), + Pattern.compile("My chest has the reward and I'm telling the truth.*") + ); + + @Override + public void chatReceived(IChatComponent chat) { + super.chatReceived(chat); + if (!FeatureRegistry.SOLVER_RIDDLE.isEnabled()) return; + String ch2 = chat.getUnformattedText(); + if (!ch2.startsWith("ยงe[NPC] ")) { + return; + } + String watsaid = TextUtils.stripColor(ch2.split(":")[1]).trim(); + boolean foundMatch = false; + for (Pattern p:patternList) { + if (p.matcher(watsaid).matches()) { + foundMatch = true; + break; + } + } + if (foundMatch) { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeRiddle ยง7:: "+ch2.split(":")[0].trim()+" ยงfhas the reward!")); + final String name = TextUtils.stripColor(ch2.split(":")[0]).replace("[NPC] ","").trim(); + final BlockPos low = getDungeonRoom().getMin(); + final BlockPos high = getDungeonRoom().getMax(); + World w = getDungeonRoom().getContext().getWorld(); + List armor = w.getEntities(EntityArmorStand.class, new Predicate() { + @Override + public boolean apply(@Nullable EntityArmorStand input) { + BlockPos pos = input.getPosition(); + return low.getX() < pos.getX() && pos.getX() < high.getX() + && low.getZ() < pos.getZ() && pos.getZ() < high.getZ() && TextUtils.stripColor(input.getName()).equalsIgnoreCase(name); + } + }); + + if (armor != null) { + this.chest = null; + BlockPos pos = armor.get(0).getPosition(); + for (BlockPos allInBox : BlockPos.getAllInBox(pos.add(-1, 0, -1), pos.add(1, 0, 1))) { + Block b = w.getChunkFromBlockCoords(allInBox).getBlock(allInBox); + + if ((b == Blocks.chest || b == Blocks.trapped_chest)&& allInBox.distanceSq(pos) == 1 ) { + this.chest = allInBox; + return; + } + } + } + + } + } + + BlockPos chest; + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_RIDDLE.isEnabled()) return; + if (chest != null) { + RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(chest.getX(), chest.getY(), chest.getZ(), chest.getX()+1, chest.getY() + 1, chest.getZ() + 1), FeatureRegistry.SOLVER_RIDDLE.getTargetColor(), partialTicks, true); + } + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorRiddle createNew(DungeonRoom dungeonRoom) { + RoomProcessorRiddle defaultRoomProcessor = new RoomProcessorRiddle(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTeleportMazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTeleportMazeSolver.java new file mode 100755 index 00000000..30f1d385 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTeleportMazeSolver.java @@ -0,0 +1,145 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor { + @Nullable + private BlockPos lastPlayerLocation; + + public RoomProcessorTeleportMazeSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + yLevel = dungeonRoom.getMin().getY() - 1; + } + + private final List visitedPortals = new ArrayList(); + + private int yLevel = 0; + private double slope1, slope2; + private double posX1, posZ1, posX2, posZ2; + private int times=0 ; + + private double intersectionX, intersectionZ; + private BlockPos intersection; + + @Override + public void tick() { + super.tick(); + + + + World w = getDungeonRoom().getContext().getWorld(); + EntityPlayerSP entityPlayerSP = Minecraft.getMinecraft().thePlayer; + BlockPos pos2 = new BlockPos(Math.floor(entityPlayerSP.posX), Math.floor(entityPlayerSP.posY), Math.floor(entityPlayerSP.posZ)); + Block b = w.getChunkFromBlockCoords(pos2).getBlock(pos2); + Vec3 lookVec = entityPlayerSP.getLookVec(); + + if (times % 4 == 1) { + posX1 = entityPlayerSP.posX; + posZ1 = entityPlayerSP.posZ; + slope1 = lookVec.zCoord / lookVec.xCoord; + times ++; + } else if (times % 4 == 3) { + posX2 = entityPlayerSP.posX; + posZ2 = entityPlayerSP.posZ; + slope2 = lookVec.zCoord / lookVec.xCoord; + + double yInt1 = posZ1 - posX1 * slope1; + double yInt2 = posZ2 - posX2 * slope2; + + intersectionX = (yInt2 - yInt1) / (slope1 - slope2); + intersectionZ = (slope1 * intersectionX + yInt1); + intersection = new BlockPos((int) intersectionX, yLevel, (int) intersectionZ); + times++; + } + + if (b == Blocks.stone_slab || b == Blocks.stone_slab2) { + boolean teleport = false; + if (lastPlayerLocation != null && lastPlayerLocation.distanceSq(pos2) < 3) { + return; + } + for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation, pos2)) { + if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.iron_bars) { + teleport = true; + break; + } + } + + if (teleport) { + if (times % 4 == 0) { + times ++; + } else if (times % 4 == 2){ + times++; + } + + for (BlockPos allInBox : BlockPos.getAllInBox(pos2.add(-1, 0, -1), pos2.add(1, 0, 1))) { + if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) { + if (!visitedPortals.contains(allInBox)) + visitedPortals.add(allInBox); + break; + } + } + for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation.add(-1, -1, -1), lastPlayerLocation.add(1, 1, 1))) { + if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) { + if (!visitedPortals.contains(allInBox)) + visitedPortals.add(allInBox); + break; + } + } + } + } + + lastPlayerLocation = pos2; + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_TELEPORT.isEnabled()) return; + for (BlockPos bpos:visitedPortals) { + RenderUtils.highlightBoxAColor( AxisAlignedBB.fromBounds(bpos.getX(), bpos.getY(), bpos.getZ(), bpos.getX()+1, bpos.getY() + 1, bpos.getZ() + 1), FeatureRegistry.SOLVER_TELEPORT.getTargetColor2(), partialTicks, true); + } + + if (intersection != null) { + RenderUtils.highlightBoxAColor( AxisAlignedBB.fromBounds(intersection.getX(), intersection.getY(), intersection.getZ(), intersection.getX()+1, intersection.getY() + 1, intersection.getZ() + 1), FeatureRegistry.SOLVER_TELEPORT.getTargetColor(), partialTicks, false); + } + } + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorTeleportMazeSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorTeleportMazeSolver defaultRoomProcessor = new RoomProcessorTeleportMazeSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTicTacToeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTicTacToeSolver.java new file mode 100755 index 00000000..9ee8c215 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTicTacToeSolver.java @@ -0,0 +1,214 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.storage.MapData; + +import java.util.List; + +public class RoomProcessorTicTacToeSolver extends GeneralRoomProcessor { + + private final OffsetPointSet board; + private byte[][] lastBoard; + public RoomProcessorTicTacToeSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + + board = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("board"); + } + + // -1 com, 1 pla, 0 emp + private byte[][] buildBoardState() { + byte[][] board = new byte[3][3]; + World w= getDungeonRoom().getContext().getWorld(); + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + OffsetPoint op = this.board.getOffsetPointList().get(x * 3 + y); + BlockPos bpos = op.getBlockPos(getDungeonRoom()); + Block b = w.getChunkFromBlockCoords(bpos).getBlock(bpos); + if (b == Blocks.stone_button) { + board[y][x] = 0; + } else if (b == Blocks.air){ + AxisAlignedBB abab = AxisAlignedBB.fromBounds(bpos.getX() , bpos.getY(), bpos.getZ(), bpos.getX() +1, bpos.getY() +1, bpos.getZ() +1); + List frames = getDungeonRoom().getContext().getWorld().getEntitiesWithinAABB(EntityItemFrame.class, abab); + if (frames.isEmpty()) board[y][x] = 0; + else { + ItemStack displayedItem = frames.get(0).getDisplayedItem(); + if (displayedItem == null || displayedItem.getItem() == null || !displayedItem.getItem().isMap()) { + board[y][x] = 0; + continue; + } + MapData mapData = ((ItemMap)displayedItem.getItem()).getMapData(displayedItem, w); + byte center = mapData.colors[64 * 128+64]; + if (center == 114) + board[y][x] = -1; + else + board[y][x] = 1; + } + } + } + } + return board; + } + + private byte checkWinner(byte[][] board) { + for (int y = 0; y <3; y++) { + byte potentialWinner = board[y][0]; + if (potentialWinner == 0) continue; + boolean found = false; + for (int x = 0; x < 3; x++) { + if (potentialWinner != board[y][x]) { + found = true; + break; + } + } + if (!found) { + return potentialWinner; + } + } + for (int x = 0; x <3; x++) { + byte potentialWinner = board[0][x]; + if (potentialWinner == 0) continue; + boolean found = false; + for (int y = 0; y < 3; y++) { + if (potentialWinner != board[y][x]) { + found = true; + break; + } + } + if (!found) { + return potentialWinner; + } + } + if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != 0) { + return board[0][0]; + } + if (board[0][2] == board[1][1] && board[1][1] == board[2][0] && board[0][2] != 0) { + return board[0][2]; + } + return 0; + } + + private int chosePos = -1; + private int minimax(byte[][] board, byte player) { + byte winner = checkWinner(board); + if (winner != 0) { + return winner * player; + } + + int move = -1; + int score = -2; + for (int i = 0; i < 9; i++) { + if (board[i % 3][i / 3] == 0) { + byte[][] cloned = new byte[3][]; + for(int k = 0; k < 3; k++) + cloned[k] = board[k].clone(); + + cloned[i % 3][i/3] = player; + int scoreForMove = -minimax(cloned, (byte) -player); + if (scoreForMove > score) { + score = scoreForMove; + move = i; + } + } + } + chosePos = move; + if (move == -1) { + return 0; + } + + return score; + } + + private boolean gameEnded = false; + + @Override + public void tick() { + super.tick(); + if (board == null) return; + if (gameEnded) return; + byte[][] board = buildBoardState(); + if (checkWinner(board) != 0) { + gameEnded = true; + return; + } + if (lastBoard != null) { + boolean yesdoit = false; + label: + for (int y = 0; y < 3; y++) + for (int x = 0; x < 3; x++) + if (board[y][x] != lastBoard[y][x]) { + yesdoit = true; + break label; + } + if (!yesdoit) return; + } + lastBoard = board; + + minimax(board, (byte) 1); + if (chosePos == -1) { + gameEnded = true; + return; + } + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_TICTACTOE.isEnabled()) return; + if (chosePos != -1) { + BlockPos block = board.getOffsetPointList().get(chosePos).getBlockPos(getDungeonRoom()); + boolean whoseturn = false; // false => hype true => me + if (lastBoard != null) { + int ones = 0; + int negativeones = 0; + for (byte[] bytes : lastBoard) { + for (byte aByte : bytes) { + if (aByte == 1) ones++; + else if (aByte == -1) negativeones++; + } + } + whoseturn = ones < negativeones; + } + RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(block.getX(), block.getY(), block.getZ(), block.getX()+1, block.getY() + 1, block.getZ() + 1), + whoseturn ? FeatureRegistry.SOLVER_TICTACTOE.getTargetColor() + : FeatureRegistry.SOLVER_TICTACTOE.getTargetColor2(), partialTicks, true); + } + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorTicTacToeSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorTicTacToeSolver defaultRoomProcessor = new RoomProcessorTicTacToeSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTrivia.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTrivia.java new file mode 100755 index 00000000..b7956122 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/RoomProcessorTrivia.java @@ -0,0 +1,165 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.SkyblockUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import kr.syeyoung.dungeonsguide.mod.wsresource.StaticResourceCache; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import org.apache.commons.lang3.math.NumberUtils; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RoomProcessorTrivia extends GeneralRoomProcessor { + + public RoomProcessorTrivia(DungeonRoom dungeonRoom) { + super(dungeonRoom); + } + + + private final List questionDialog = new ArrayList(); + private boolean questionDialogStart = false; + + private boolean parseDialog = false; + @Override + public void chatReceived(IChatComponent chat) { + super.chatReceived(chat); + if (!FeatureRegistry.SOLVER_KAHOOT.isEnabled()) return; + String ch2 = chat.getUnformattedText(); + if (parseDialog) { + parseDialog = false; + parseDialog(); + } + if (chat.getFormattedText().contains("ยงrยง6ยงlQuestion ")) { + questionDialogStart = true; + questionDialog.clear(); + } + if (questionDialogStart && (chat.getFormattedText().startsWith("ยงrยงrยงr") || chat.getFormattedText().startsWith("ยงrยงrยงr") || chat.getFormattedText().trim().startsWith("ยงrยง6 "))) { + questionDialog.add(chat.getFormattedText()); + } + + if (chat.getFormattedText().contains("ยงrยง6 โ“’")) { + questionDialogStart = false; + parseDialog = true; + } + } + public static final Pattern anwerPattern = Pattern.compile("ยงrยง6 . ยงa(.+)ยงr"); + private void parseDialog() { + String question = TextUtils.stripColor(questionDialog.get(1)).trim(); + String answerA = getAnswer(questionDialog.get(2)); + String answerB = getAnswer(questionDialog.get(3)); + String answerC = getAnswer(questionDialog.get(4)); + match(question, answerA, answerB, answerC); + + } + String correctAnswer; + + + private String getAnswer(String answerString) { + Matcher matcher = anwerPattern.matcher(answerString.trim()); + if (!matcher.matches()) return ""; + return matcher.group(1); + } + private void match(String question, String a, String b, String c) { + StaticResourceCache.INSTANCE.getResource(StaticResourceCache.TRIVIA_ANSWERS).thenAccept(value -> { + JSONObject answersJSON = new JSONObject(value.getValue()); + + String semi_answers = answersJSON.getString(question.toLowerCase().trim()); + String theRealAnswer; + if (semi_answers == null) theRealAnswer = null; + else { + semi_answers = takeCareOfPlaceHolders(semi_answers); + String[] answers = semi_answers.split(","); + if (match(answers, a)) theRealAnswer = "A"; + else if (match(answers, b)) theRealAnswer = "B"; + else if (match(answers, c)) theRealAnswer = "C"; + else theRealAnswer = semi_answers; + } + if (theRealAnswer == null) + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeTrivia ยง7:: ยงcCouldn't determine the answer! (no question found)")); + else if (theRealAnswer.length() >1) + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeTrivia ยง7:: ยงcCouldn't determine the answer! ("+theRealAnswer+")")); + else + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeTrivia ยง7:: "+theRealAnswer+"ยงf is the correct answer!")); + correctAnswer = theRealAnswer; + }); + } + + private String takeCareOfPlaceHolders(String input) { + String str = input; + if (str.contains("$year")) { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยงfuses ยงeInventiveTalentยง7(https://github.com/InventivetalentDev)ยงe's Skyblock Api ยงfto fetch current skyblock year!")); + try { + str = str.replace("$year", SkyblockUtils.getSkyblockYear()+""); + } catch (IOException e) { + str = str.replace("$year", "Couldn't determine current skyblock year :: "+e.getMessage()); + } + } + return str; + } + private boolean match(String[] match, String match2) { + for (String s : match) { + if (NumberUtils.isNumber(s)) { + if (match2.toLowerCase().contains(s)) return true; + } else { + if (match2.equalsIgnoreCase(s)) return true; + } + } + return false; + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_KAHOOT.isEnabled()) return; + if (correctAnswer == null) return; + + OffsetPoint op = (OffsetPoint) getDungeonRoom().getDungeonRoomInfo().getProperties().get(correctAnswer); + if (op != null) { + BlockPos solution = op.getBlockPos(getDungeonRoom()); + RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(solution.getX(), solution.getY(), solution.getZ(), solution.getX()+1, solution.getY() + 1, solution.getZ() + 1), FeatureRegistry.SOLVER_KAHOOT.getTargetColor(), partialTicks, false); + } + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorTrivia createNew(DungeonRoom dungeonRoom) { + RoomProcessorTrivia defaultRoomProcessor = new RoomProcessorTrivia(dungeonRoom); + return defaultRoomProcessor; + } + } + + @Override + public boolean readGlobalChat() { + return true; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java new file mode 100644 index 00000000..d3d7ae3b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java @@ -0,0 +1,441 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessorGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.DummyDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.arrow.ArrowProcessorMatcher; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.bugged.ImpossibleMatcher; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.color.ColorProcessorMatcher; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.creeper.CreeperProcessorMatcher; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.goldenpath.GoldenPathProcessorMatcher; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.maze.MazeProcessorMatcher; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.number.NumberProcessorMatcher; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import org.apache.commons.codec.binary.Base64; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { + + @Getter + private final List chambers = new ArrayList(); + @Getter + private OffsetPointSet doors; + + private static final List chamberGenerators = new ArrayList(); + { + chamberGenerators.add(new ArrowProcessorMatcher()); + chamberGenerators.add(new ColorProcessorMatcher()); + chamberGenerators.add(new CreeperProcessorMatcher()); + chamberGenerators.add(new NumberProcessorMatcher()); + chamberGenerators.add(new GoldenPathProcessorMatcher()); + chamberGenerators.add(new MazeProcessorMatcher()); + chamberGenerators.add(new ImpossibleMatcher()); + } + + private boolean bugged = false; + private boolean maze = false; + private boolean impossible = false; + + public RoomProcessorBombDefuseSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + if (!FeatureRegistry.SOLVER_BOMBDEFUSE.isEnabled()) { + bugged = true; + return; + } + chambers.add(new ChamberSet( + buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("L1"), 1, true), + buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("R1"), 1, true), null + )); + chambers.add(new ChamberSet( + buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("L2"), 2, true), + buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("R2"), 2, true), null + )); + chambers.add(new ChamberSet( + buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("L3"), 3, true), + buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("R3"), 3, true), null + )); + chambers.add(new ChamberSet( + buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("L4"), 4, true), + buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("R4"), 4, true), null + )); + doors = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("Door"); + if (doors == null) {bugged = true; return;} + for (ChamberSet set:chambers) { + if (set.getLeft().getChamberBlocks() == null) { + bugged = true; + return; + } + if (set.getRight().getChamberBlocks() == null) { + bugged = true; + return; + } + } + + for (ChamberSet set:chambers) { + if (set.getLeft().getChamberBlocks() == null) { + bugged = true; + return; + } + if (set.getRight().getChamberBlocks() == null) { + bugged = true; + return; + } + } + + for (ChamberSet set:chambers) { + for (BombDefuseChamberGenerator bdcg:chamberGenerators) { + if (bdcg.match(set.getLeft(), set.getRight())) { + set.setChamberGen(bdcg); + set.getLeft().setProcessor(bdcg.createLeft(set.getLeft(), this)); + set.getRight().setProcessor(bdcg.createRight(set.getRight(), this)); + if (bdcg instanceof ImpossibleMatcher) impossible=true; + if (bdcg instanceof MazeProcessorMatcher) maze = true; + break; + } + } + if (set.getChamberGen() == null) { + set.setChamberGen(null); + set.getLeft().setProcessor(new DummyDefuseChamberProcessor(this, set.getLeft())); + set.getRight().setProcessor(new DummyDefuseChamberProcessor(this, set.getRight())); + } + } + + OffsetPoint warning1 = (OffsetPoint) dungeonRoom.getDungeonRoomInfo().getProperties().get("Warning"); + if (warning1 != null) warning = warning1.getBlockPos(dungeonRoom); + } + + public BDChamber buildChamber(OffsetPointSet ops, int level, boolean left) { + return new BDChamber(getDungeonRoom(), ops, left, level, null); + } + BlockPos warning; + + + public void communicate(NBTTagCompound compound) { + if (bugged) return; + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream w = new DataOutputStream(baos); + CompressedStreamTools.writeCompressed(compound, w); + w.flush(); + byte[] bytes = baos.toByteArray(); + String str = Base64.encodeBase64String(bytes); + Minecraft.getMinecraft().thePlayer.sendChatMessage("/pc $DG-BD " +str); + + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) + ch.getLeft().getProcessor().onDataRecieve(compound); + if (ch.getRight() != null && ch.getRight().getProcessor() != null) + ch.getRight().getProcessor().onDataRecieve(compound); + } + } catch (IOException e2) { + e2.printStackTrace(); + ChatTransmitter.sendDebugChat(new ChatComponentText("Failed to send Bomb Defuse Chat")); + } + } + + @Override + public void chatReceived(IChatComponent component) { + super.chatReceived(component); + if (bugged) return; + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) + ch.getLeft().getProcessor().chatReceived(component); + if (ch.getRight() != null && ch.getRight().getProcessor() != null) + ch.getRight().getProcessor().chatReceived(component); + } + + if (component.getFormattedText().contains("$DG-BD ")) { + try { + String data = component.getFormattedText().substring(component.getFormattedText().indexOf("$DG-BD")); + String actual = TextUtils.stripColor(data).trim().split(" ")[1]; + byte[] data2 = Base64.decodeBase64(actual); + NBTTagCompound compound = CompressedStreamTools.readCompressed(new ByteArrayInputStream(data2)); + + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) + ch.getLeft().getProcessor().onDataRecieve(compound); + if (ch.getRight() != null && ch.getRight().getProcessor() != null) + ch.getRight().getProcessor().onDataRecieve(compound); + } + } catch (Throwable t) { + t.printStackTrace(); + ChatTransmitter.sendDebugChat(new ChatComponentText("Failed to analyze Bomb Defuse Chat")); + } + } + } + + + @Override + public void tick() { + super.tick(); + if (bugged) return; + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().tick(); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().tick(); + } + } + } + } + + + @Override + public void drawScreen(float partialTicks) { + super.drawScreen(partialTicks); + if (bugged) return; + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + if (FeatureRegistry.DEBUG.isEnabled()) { + for (ChamberSet ch : chambers) { + if (ch.getChamberGen() == null) continue; + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().drawScreen(partialTicks); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String str = "Current: " + ch.getChamberGen().getName() + " Specific: " + ch.getLeft().getProcessor().getName(); + fr.drawString(str, 0, 0, 0xFFFFFFFF); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().drawScreen(partialTicks); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + if (ch.getChamberGen() == null || ch.getRight().getProcessor() == null) continue; + String str = "Current: " + ch.getChamberGen().getName() + " Specific: " + ch.getRight().getProcessor().getName(); + fr.drawString(str, 0, 0, 0xFFFFFFFF); + } + } + } + } + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (bugged) return; + + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos((int)Minecraft.getMinecraft().thePlayer.posX, 68, (int)Minecraft.getMinecraft().thePlayer.posZ)); + boolean found = false; + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + found = true; + ch.getLeft().getProcessor().drawWorld(partialTicks); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + found = true; + ch.getRight().getProcessor().drawWorld(partialTicks); + } + } + } + + if ((maze || impossible) && warning != null && !found) { + if (impossible) { + RenderUtils.drawTextAtWorld("Warning: This Bomb Defuse is bugged and Impossible" , warning.getX()+ 0.5f, warning.getY(), warning.getZ()+ 0.5f, 0xFF00FF00, 0.03F, false, false, partialTicks); + } else { + RenderUtils.drawTextAtWorld("Warning: This Bomb Defuse must be done with 2 people (maze)" , warning.getX()+ 0.5f, warning.getY(), warning.getZ()+ 0.5f, 0xFF00FF00, 0.03F, false, false, partialTicks); + } + } + if (warning != null && !found) { + for (int i = 0; i < 4; i++) { + BombDefuseChamberGenerator bdcg = chambers.get(i).getChamberGen(); + RenderUtils.drawTextAtWorld((i + 1) + ". " + (bdcg == null ? "null" : bdcg.getName()), warning.getX() + 0.5f, warning.getY() - ((i + 1) * 0.3f), warning.getZ() + 0.5f, 0xFF00FF00, 0.03F, false, false, partialTicks); + } + } + } + + @Override + public void actionbarReceived(IChatComponent chat) { + super.actionbarReceived(chat); + if (bugged) return; + + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) + ch.getLeft().getProcessor().actionbarReceived(chat); + if (ch.getRight() != null && ch.getRight().getProcessor() != null) + ch.getRight().getProcessor().actionbarReceived(chat); + } + } + + @Override + public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { + super.onPostGuiRender(event); + if (bugged) return; + + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().onPostGuiRender(event); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().onPostGuiRender(event); + } + } + } + } + + @Override + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + super.onEntityUpdate(updateEvent); + if (bugged) return; + + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().onEntityUpdate(updateEvent); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { +// if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().onEntityUpdate(updateEvent); +// } + } + } + } + + @Override + public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { + super.onKeybindPress(keyInputEvent); + if (bugged) return; + + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().onKeybindPress(keyInputEvent); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().onKeybindPress(keyInputEvent); + } + } + } + } + + @Override + public void onInteract(PlayerInteractEntityEvent event) { + super.onInteract(event); + if (bugged) return; + + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().onInteract(event); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().onInteract(event); + } + } + } + } + + @Override + public void onInteractBlock(PlayerInteractEvent event) { + super.onInteractBlock(event); + if (bugged) return; + + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); + for (ChamberSet ch:chambers) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { + if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getLeft().getProcessor().onInteractBlock(event); + } + } + if (ch.getRight() != null && ch.getRight().getProcessor() != null) { + if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { + ch.getRight().getProcessor().onInteractBlock(event); + } + } + } + } + + @Override public boolean readGlobalChat() { return true; } + + @Data + @AllArgsConstructor + public static class ChamberSet { + private BDChamber left; + private BDChamber right; + private BombDefuseChamberGenerator chamberGen; + } + + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorBombDefuseSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorBombDefuseSolver defaultRoomProcessor = new RoomProcessorBombDefuseSolver(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/BDChamber.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/BDChamber.java new file mode 100644 index 00000000..2dc754b1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/BDChamber.java @@ -0,0 +1,83 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.util.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +@AllArgsConstructor +@Data +public class BDChamber { + private DungeonRoom room; + private OffsetPointSet chamberBlocks; + + private boolean isLeft; + private int level; + + private ChamberProcessor processor; + + // for whatever's sake, 6: z, 9: x. Starts from botoom right, left, then up + + public OffsetPoint getOffsetPoint(int x, int z) { + return chamberBlocks.getOffsetPointList().get(z * 9 + x); + } + + public BlockPos getBlockPos(int x, int y, int z) { + return getOffsetPoint(x,z).getBlockPos(room).add(0,y,0); + } + + public IBlockState getBlock(int x, int y, int z) { + BlockPos pos = getBlockPos(x,y,z); + return DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos); + } + + public boolean isWithinAbsolute(int x, int y, int z) { + return isWithinAbsolute(new BlockPos(x,68,z)); + } + public boolean isWithinAbsolute(BlockPos pos) { + return chamberBlocks.getOffsetPointList().contains(new OffsetPoint(room, new BlockPos(pos.getX(), 68, pos.getZ()))); + } + + + public T getEntityAt(Class entity, int x, int y, int z) { + final BlockPos pos = getBlockPos(x,y,z); + return getEntityAt(entity, pos); + } + public T getEntityAt(Class entity, final BlockPos pos) { + List entities = room.getContext().getWorld().getEntities(entity, new Predicate() { + @Override + public boolean apply(@Nullable T input) { + return input.getPosition().equals(pos); + } + }); + if (entities.size() == 0) return null; + return entities.get(0); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java new file mode 100644 index 00000000..8c43ca36 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java @@ -0,0 +1,30 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; + +public interface BombDefuseChamberGenerator { + boolean match(BDChamber left, BDChamber right); + + String getName(); + + ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver); + ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver); +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/ChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/ChamberProcessor.java new file mode 100644 index 00000000..c4d63f42 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/ChamberProcessor.java @@ -0,0 +1,27 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessor; +import net.minecraft.nbt.NBTTagCompound; + +public interface ChamberProcessor extends RoomProcessor { + void onDataRecieve(NBTTagCompound compound); + String getName(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java new file mode 100644 index 00000000..d7056dbf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java @@ -0,0 +1,32 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; + +public class DummyDefuseChamberProcessor extends GeneralDefuseChamberProcessor { + public DummyDefuseChamberProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + } + + @Override + public String getName() { + return "dummy"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java new file mode 100644 index 00000000..0040bc4f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java @@ -0,0 +1,137 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers; + +import kr.syeyoung.dungeonsguide.mod.events.impl.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +@Getter +public abstract class GeneralDefuseChamberProcessor implements ChamberProcessor{ + private final RoomProcessorBombDefuseSolver solver; + private final BDChamber chamber; + + public GeneralDefuseChamberProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + this.solver = solver; + this.chamber = chamber; + } + + + @Override + public void onDataRecieve(NBTTagCompound compound) { + + } + + @Override + public void tick() { + + } + + @Override + public void drawScreen(float partialTicks) { + + } + + @Override + public void drawWorld(float partialTicks) { + + } + + @Override + public void chatReceived(IChatComponent chat) { + + } + + @Override + public void onEntityDeath(LivingDeathEvent deathEvent) { + + } + + @Override + public void actionbarReceived(IChatComponent chat) { + + } + @Override + public void onBlockUpdate(BlockUpdateEvent blockUpdateEvent) { + + } + + @Override + public boolean readGlobalChat() { + return false; + } + + @Override + public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { + + } + + @Override + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + + } + + protected void drawPressKey() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + String str = "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.getParameter("key").getValue()) + " to save and send solution"; + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(str, (sr.getScaledWidth() - fr.getStringWidth(str)) / 2, (sr.getScaledHeight() - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + } + + @Override + public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { + if (keyInputEvent.getKey() == FeatureRegistry.SOLVER_BOMBDEFUSE.getParameter("key").getValue()) { + if (!getChamber().isWithinAbsolute(Minecraft.getMinecraft().thePlayer.getPosition())) { + return; + } + onSendData(); + } + } + + @Override + public void onInteract(PlayerInteractEntityEvent event) { + + } + + @Override + public void onInteractBlock(PlayerInteractEvent event) { + + } + + public void onSendData() {} +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java new file mode 100644 index 00000000..94b4f78d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java @@ -0,0 +1,138 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.arrow; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; + +import java.util.HashMap; +import java.util.Map; + +public class ArrowLeftProcessor extends GeneralDefuseChamberProcessor { + public ArrowLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + for (int i = 0; i < 9; i++) { + grid[i] = chamber.getBlockPos(7,1 + (i / 3),1 + (i % 3)); + } + } + + @Override + public String getName() { + return "arrowLeft"; + } + + + private int answer = -1; + private final int[] answers = new int[9]; + private final BlockPos[] grid = new BlockPos[9]; + @Override + public void tick() { + super.tick(); + if (answer != -1) return; + for (int i = 0; i < 9; i++) + answers[i] = match(getChamber().getEntityAt(EntityArmorStand.class, grid[i].add(0, -1, 0))); + + answer = 0; + for (int i =0; i < 9; i++) { + answer = answer * 10 + answers[i]; + } + } + + @Override + public void drawScreen(float partialTicks) { + if (answer == -1) return; + drawPressKey(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + + if (answer == -1) return; + for (int i = 0; i < 9; i++) { + BlockPos pos = grid[i]; + int direction = answers[i]; + String charac = arrows.get(direction); + + RenderUtils.drawTextAtWorld(charac, pos.getX()+ 0.5f, pos.getY()+ 0.5f, pos.getZ()+ 0.5f, 0xFFFFFFFF, 0.05F, false, false, partialTicks); + } + } + + @Override + public void onSendData() { + if (answer == -1) return; + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setByte("a", (byte) 3); + nbt.setInteger("b", answer); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (3 == compound.getByte("a")) { + answer = compound.getInteger("b"); + for (int i = 8; i >= 0; i--) { + answers[i] = answer % 10; + answer = answer / 10; + } + answer = compound.getInteger("b"); + } + } + + private int match(EntityArmorStand armorStand) { + if (armorStand == null) return -1; + ItemStack item = armorStand.getInventory()[4]; + NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); + String str = ((NBTTagCompound)list.get(0)).getString("Value"); + return !integers.containsKey(str) ? -1 : integers.get(str); + } + + private static final BiMap integers = HashBiMap.create(8); + private static final Map arrows = new HashMap(); + { + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDczZTFmZTBmZmNkNTQ2YzIxYjYzZWFhOTEwYWI1YzkzMTMyYTY0ZTY0NDE3OWZjY2FhMjFkYzhiYzY2MCJ9fX0=", 1); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThmZTI1MWE0MGU0MTY3ZDM1ZDA4MWMyNzg2OWFjMTUxYWY5NmI2YmQxNmRkMjgzNGQ1ZGM3MjM1ZjQ3NzkxZCJ9fX0=", 2); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTc3ZWM0NGZiNzUwM2RlNmFmZTNiZGQ3ZTU4M2M3YjkzOTc5ZjU5ZjZkNjM0YjZiNmE1YWY3ZjNhMWM1ODUxNSJ9fX0=", 3); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjJmM2EyZGZjZTBjM2RhYjdlZTEwZGIzODVlNTIyOWYxYTM5NTM0YThiYTI2NDYxNzhlMzdjNGZhOTNiIn19fQ==", 4); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGUxY2U5YzBkMzMyMzZmOTkyMWQyMmM0ZWM0YmY1MDkyMzdhZWY2NzZiNWQxZDJiYWNjOTNmNWE4MTk0ODAifX19", 5); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWI3Y2U2ODNkMDg2OGFhNDM3OGFlYjYwY2FhNWVhODA1OTZiY2ZmZGFiNmI1YWYyZDEyNTk1ODM3YTg0ODUzIn19fQ==", 6); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTI2NTFlY2QzNzgwY2Y2ZTQ1MWVjYWNjZGVlNjk3MTVjMDhjYWU3Y2Q0NTA5MDg0NDYyY2RjZDk2M2E2YjMyMiJ9fX0=", 7); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmIwZjZlOGFmNDZhYzZmYWY4ODkxNDE5MWFiNjZmMjYxZDY3MjZhNzk5OWM2MzdjZjJlNDE1OWZlMWZjNDc3In19fQ==", 8); + + arrows.put(0, "?"); + arrows.put(1, "โ†–"); + arrows.put(2, "โ†‘"); + arrows.put(3, "โ†—"); + arrows.put(4, "โ†’"); + arrows.put(5, "โ†˜"); + arrows.put(6, "โ†“"); + arrows.put(7, "โ†™"); + arrows.put(8, "โ†"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java new file mode 100644 index 00000000..82a972b2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.arrow; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import net.minecraft.init.Blocks; + +public class ArrowProcessorMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return left.getBlock(8,1,1).getBlock() == Blocks.planks && + left.getBlock(8,1,2).getBlock() == Blocks.planks && + left.getBlock(8,1,3).getBlock() == Blocks.planks && + right.getBlock(0,1,1).getBlock() == Blocks.planks && + right.getBlock(0,1,2).getBlock() == Blocks.planks && + right.getBlock(0,1,3).getBlock() == Blocks.planks; + } + + @Override + public String getName() { + return "arrowMatch"; + } + + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return new ArrowLeftProcessor(solver, left); + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return new ArrowRightProcessor(solver, right); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java new file mode 100644 index 00000000..9c293bc7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java @@ -0,0 +1,126 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.arrow; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; + +import java.util.HashMap; +import java.util.Map; + +public class ArrowRightProcessor extends GeneralDefuseChamberProcessor { + public ArrowRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + for (int i = 0; i < 9; i++) { + grid[i] = chamber.getBlockPos(1,1 + (i / 3),1 + (2 - (i % 3))); + } + + center = chamber.getBlockPos(4,4,4); + } + + @Override + public String getName() { + return "arrowRight"; + } + + + private int answer = -1; + private final int[] correctAnswers = new int[9]; + private final int[] currentAnswers = new int[9]; + private final BlockPos[] grid = new BlockPos[9]; + private final BlockPos center; + @Override + public void tick() { + super.tick(); + for (int i = 0; i < 9; i++) + currentAnswers[i] = match(getChamber().getEntityAt(EntityArmorStand.class, grid[i].add(0, -1, 0))); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + + RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + + for (int i = 0; i < 9; i++) { + BlockPos pos = grid[i]; + int direction = correctAnswers[i]; + int direction2 = currentAnswers[i]; + String charac = arrows.get(direction); + String car2 = arrows.get(direction2); + + RenderUtils.drawTextAtWorld(car2, pos.getX()+ 0.5f, pos.getY()+ 0.6f, pos.getZ()+ 0.5f, direction == direction2 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(charac, pos.getX()+ 0.5f, pos.getY()+ 0.2f, pos.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + } + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (3 == compound.getByte("a")) { + answer = compound.getInteger("b"); + for (int i = 8; i >= 0; i--) { + correctAnswers[i] = answer % 10; + answer = answer / 10; + } + answer = compound.getInteger("b"); + } + } + + private int match(EntityArmorStand armorStand) { + if (armorStand == null) return -1; + ItemStack item = armorStand.getInventory()[4]; + NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); + String str = ((NBTTagCompound)list.get(0)).getString("Value"); + return !integers.containsKey(str) ? -1 : integers.get(str); + } + + private static final BiMap integers = HashBiMap.create(8); + private static final Map arrows = new HashMap(); + { + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY1NDI2YTMzZGY1OGI0NjVmMDYwMWRkOGI5YmVjMzY5MGIyMTkzZDFmOTUwM2MyY2FhYjc4ZjZjMjQzOCJ9fX0=", 1); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzA0MGZlODM2YTZjMmZiZDJjN2E5YzhlYzZiZTUxNzRmZGRmMWFjMjBmNTVlMzY2MTU2ZmE1ZjcxMmUxMCJ9fX0=", 2); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTBlMGE0ZDQ4Y2Q4MjlhNmQ1ODY4OTA5ZDY0M2ZhNGFmZmQzOWU4YWU2Y2FhZjZlYzc5NjA5Y2Y3NjQ5YjFjIn19fQ==", 3); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19", 4); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzVjYmRiMjg5OTFhMTZlYjJjNzkzNDc0ZWY3ZDBmNDU4YTVkMTNmZmZjMjgzYzRkNzRkOTI5OTQxYmIxOTg5In19fQ==", 5); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzQzNzM0NmQ4YmRhNzhkNTI1ZDE5ZjU0MGE5NWU0ZTc5ZGFlZGE3OTVjYmM1YTEzMjU2MjM2MzEyY2YifX19", 6); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzU0Y2U4MTU3ZTcxZGNkNWI2YjE2NzRhYzViZDU1NDkwNzAyMDI3YzY3NWU1Y2RjZWFjNTVkMmZiYmQ1YSJ9fX0=", 7); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==", 8); + + + arrows.put(0, "?"); + arrows.put(1, "โ†–"); + arrows.put(2, "โ†‘"); + arrows.put(3, "โ†—"); + arrows.put(4, "โ†’"); + arrows.put(5, "โ†˜"); + arrows.put(6, "โ†“"); + arrows.put(7, "โ†™"); + arrows.put(8, "โ†"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java new file mode 100644 index 00000000..42a00119 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java @@ -0,0 +1,47 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.bugged; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import net.minecraft.init.Blocks; + +public class ImpossibleMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return left.getBlock(1,1,1).getBlock() == Blocks.barrier; + } + + @Override + public String getName() { + return "buggedMazeMatcher"; + } + + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return null; + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return null; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorLeftProcessor.java new file mode 100644 index 00000000..e0291d00 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorLeftProcessor.java @@ -0,0 +1,230 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.color; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import java.util.HashMap; +import java.util.Map; + +public class ColorLeftProcessor extends GeneralDefuseChamberProcessor { + public ColorLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + center = chamber.getBlockPos(4,6,4); + b1p = chamber.getBlockPos(1,1,4); + b2p = chamber.getBlockPos(4,1,4); + b3p = chamber.getBlockPos(7,1,4); + } + + private final BlockPos center; + + private Block w1, w2, w3, c1, c2, c3; + private final BlockPos b1p; + private final BlockPos b2p; + private final BlockPos b3p; + private int s1, s2, s3; + private int s1t, s2t, s3t; + private boolean solutionBuilt; + + @Override + public String getName() { + return "colorRight"; + } + + @Override + public void tick() { + super.tick(); + if (solutionBuilt) return; + World w = getChamber().getRoom().getContext().getWorld(); + if ((c1 = w.getBlockState(b1p).getBlock()) == w1 && s1t < 7) { + int semi = match(getChamber().getEntityAt(EntityArmorStand.class,b1p.add(0, 1, 0))); + if (s1 == semi) { + s1t++; + } else { + s1 = semi; + s1t = 0; + } + } + if ((c2 = w.getBlockState(b2p).getBlock()) == w2 && s2t < 7) { + int semi = match(getChamber().getEntityAt(EntityArmorStand.class,b2p.add(0, 2, 0))); + if (s2 == semi) { + s2t++; + } else { + s2 = semi; + s2t = 0; + } + } + if ((c3 =w.getBlockState(b3p).getBlock()) == w3 && s3t < 7) { + int semi = match(getChamber().getEntityAt(EntityArmorStand.class,b3p.add(0, 1, 0))); + if (s3== semi) { + s3t++; + } else { + s3 = semi; + s3t = 0; + } + } + + if (s1t > 5 && s2t > 5 && s3t > 5) { + solutionBuilt = true; + } + } + + @Override + public void drawScreen(float partialTicks) { + super.drawScreen(partialTicks); + if (solutionBuilt) + drawPressKey(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(w1 == null ? "Request Not Received Yet" : "Building- "+w1.getLocalizedName() +" / "+w2.getLocalizedName() +" / "+w3.getLocalizedName() , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + + RenderUtils.drawTextAtWorld(w1 == null ? "null" : w1.getLocalizedName(), b1p.getX()+ 0.5f, b1p.getY() + 0.2f, b1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(w2 == null ? "null" : w2.getLocalizedName(), b2p.getX()+ 0.5f, b2p.getY() + 0.2f, b2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(w3 == null ? "null" : w3.getLocalizedName(), b3p.getX()+ 0.5f, b3p.getY() + 0.2f, b3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(c1 == null ? "null" : c1.getLocalizedName(), b1p.getX()+ 0.5f, b1p.getY() + 0.6f, b1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(c2 == null ? "null" : c2.getLocalizedName(), b2p.getX()+ 0.5f, b2p.getY() + 0.6f, b2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(c3 == null ? "null" : c3.getLocalizedName(), b3p.getX()+ 0.5f, b3p.getY() + 0.6f, b3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + + if (FeatureRegistry.DEBUG.isEnabled()) { + RenderUtils.drawTextAtWorld(s1 + "", b1p.getX() + 0.5f, b1p.getY() + 2.6f, b1p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(s2 + "", b2p.getX() + 0.5f, b2p.getY() + 3.6f, b2p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(s3 + "", b3p.getX() + 0.5f, b3p.getY() + 2.6f, b3p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + } + + RenderUtils.drawTextAtWorld(colors.get(s1), b1p.getX()+ 0.5f, b1p.getY() + 2.2f, b1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(colors.get(s2), b2p.getX()+ 0.5f, b2p.getY() + 3.2f, b2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(colors.get(s3), b3p.getX()+ 0.5f, b3p.getY() + 2.2f, b3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + + if (FeatureRegistry.DEBUG.isEnabled()) { + RenderUtils.drawTextAtWorld(s1t + "", b1p.getX() + 0.5f, b1p.getY() + 1.5f, b1p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(s2t + "", b2p.getX() + 0.5f, b2p.getY() + 2f, b2p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(s3t + "", b3p.getX() + 0.5f, b3p.getY() + 1.5f, b3p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + } + } + + @Override + public void onSendData() { + super.onSendData(); + if (!solutionBuilt) return; + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setByte("a", (byte) 7); + int answer = s1 * 10000 + s2 * 100 + s3; + nbt.setInteger("b", answer); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (6 == compound.getByte("a")) { + w1 = Block.getBlockById(compound.getByte("f")); + w2 = Block.getBlockById(compound.getByte("s")); + w3 = Block.getBlockById(compound.getByte("t")); + solutionBuilt = false; + s1 = s2 = s3 = s1t = s2t = s3t =0; + } + } + + private byte match(EntityArmorStand armorStand) { + if (armorStand == null) { + return 0; + } + ItemStack item = armorStand.getInventory()[4]; + NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); + String str = ((NBTTagCompound)list.get(0)).getString("Value"); + return (byte) (!integers.containsKey(str) ? 0 : integers.get(str)); + } + + private static final Map integers = new HashMap(); + private static final BiMap colors = HashBiMap.create(); + static { + colors.put(0, "?"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2YzZTQwNjI5MTE3NGQyNGNkZjBmOTUzZjhhMTc0YTgyYmIzNDg5ZGNlOGY2NzlhNDQzZWYxYWFlMDE2OTA2MSJ9fX0=", 1); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWE4MWZjYjUxYmUyYTlmODliMWFkYzlkODcyMzliYTQyOWQ2MzVmYmUwMWIzN2VjMzI5MTY0ODg3YmY2NjViIn19fQ==", 1); + colors.put(1, "blue"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2FiMDI2M2JkZDc2ZjNlNDE4ZGJhNWJmNDgxYjkyMWNlZDM5N2Q4YjhhMzRhNTU2MWZiN2JlYWE0NmVjZTEifX19", 2); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2ZhNGRkYTZkMTlhMWZlMmQ5ODhkNjVkZWM1MzQyOTUwNTMwODE2NmM5MDY3YjY4YTQ3NzBjYTVjNDM2Y2Y5NCJ9fX0=", 2); + colors.put(2, "black"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDg0Njg0MzQ0YWUwOTg1MjlmYzk0MWFhODRlMTk1YmRjYTM3NDhkNjlhY2ZlZTJiYWMxMzMyMTM1ZWRkOThjIn19fQ==", 3); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTM1ODFjMmY5Y2YzNThkN2VkYzc4ZGQ2ZmQ0YjYyNTc1MDFiYzRlNjQ1NWUzM2ZhMGNhYWUyMDdjZjAzMjFhMiJ9fX0=", 3); + colors.put(3, "green"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTllNjkxN2YyZmI0ZWEwOGU3MTMyZGYzMDk2MWQyYjVjNTIzYWJiYTE5Y2U0M2Y4MzVmYzE0YzU2OGY0In19fQ==", 4); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWRmMjFmNTMyMTIyNTY2YWY4OTNkYTI3ODgwYTFiNjA5NWMzNTcxMmYyOWEzNzhjZmVjYzdmZTJiMTMyOGFiNCJ9fX0=", 4); + colors.put(4, "gray"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODhlZmFkNzRiMjU0ZTU3Yzc5OTc2M2RjZWVlNDUxMWZhMmY4NWFlOWZhNTU2ZWFhOTdkNDViZjY3ZTBiNmIzIn19fQ==", 5); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWZhZGY3NDFhYjc2Y2QzNjIwYWQxNjEzMDAyMDJkN2I1OWEzMzA1MWU1OTY3ZTRiNjE5NGJhYzQwYmIyODBmZiJ9fX0=", 5); + colors.put(5, "cyan"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzJlMzZmNmE2NTRkZTc0NTgzZDgwMzAxNzdhZDZlM2FjNjc1NWQ3NDM1ZDkxMjNlOGViZGZmNzRiMmQ5MGNiIn19fQ==", 6); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjJjYmQ5ZjQzNjE5YWI1Y2IxYjExZjkxY2IwM2U5NTVjNmZjNmM0NThhYmY4OWFiNjEwMzEzNDZhMDkwNjEyZSJ9fX0=", 6); + colors.put(6, "brown"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjFhZjQ2ZmViZDQ1YzBmNGQ4MWU4ZmExYjY2YjI3NWQ4OWUyNzJiMmFkNTVjOTc4NTUzYTk5YzczM2UxZmYifX19", 7); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYzZTY2NDZmMWMwZDQxZmQzYmY1NTg0YTFjZTA0NGY1YzQ2ZDU5ODI1OGRiNDYyMTYxMTc4NTlmNTdhZjE5NyJ9fX0=", 7); + colors.put(7, "light-blue"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDY3NDcwYTBjMThmNjg1MWU5MTQzNTM3MTllNzk1ODc3ZDI5YjMyNTJmN2U2YmQ0YTFiODY1NzY1YmQ3NGZlYiJ9fX0=", 8); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzc0NzJkNjA4ODIxZjQ1YTg4MDUzNzZlYzBjNmZmY2I3ODExNzgyOWVhNWY5NjAwNDFjMmEwOWQxMGUwNGNiNCJ9fX0=", 8); + colors.put(8, "lime"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWJiNDM4NmJjZGE4NGUzNTNjMzFkNzc4ZDNiMTFiY2QyNmZlYTQ5NGRkNjM0OTZiOGE4MmM3Yzc4YTRhZCJ9fX0=", 9); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjk3MDEyZWQ2YTkyYjA1ZWEwZjE5NDk1MDc0ODU0NGUwNzViYWEyODc4MWNhMzczZDFiMjdlMjhjMjY5NTNjIn19fQ==", 9); + colors.put(9, "magenta"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2JmNzc5N2EyNGE2YWY4NzVmNWM4MjcxYzViOGM0MjVlMTlmMzcyYTQxNWUwNTUyZmMyNDc3NjNmMjg1OWQxIn19fQ==", 10); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWRmMmViMjA1YTIzYzExOTZiM2VjZjIxZTY4YzA3NmI2OTZlNzYxNjNhYzhmYzRmYjlmNTMxOGMyYTVlNWIxYSJ9fX0=", 10); + colors.put(10, "orange"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmJlY2ZiMzg3OTkzNmI4OTllNDIwYmZjZDNhNzRmOGExYmY5ZGQ1NGM1OGVjN2ZiOWY4MWQ5YTVkOTg4ZSJ9fX0=", 11); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4ODM2NTBlYTkyOWRiMGVhYmRmNWJjNzU1OTlkOGVmMDBkNzAzNDBjZDFjZTVlMDRhZDk1ZWY4ZWQ4M2I3MyJ9fX0=", 11); + colors.put(11, "pink"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmE5NGNiMjVkZTYyOGNhMzU5YjJmNmVhNWE4ODY4Y2JlMjY1OTVlZWRiMmJmZmI3NTA5NjdhZDFlZTE4NTAifX19", 12); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODllYzVhMzAyMjJkMDY1OWIwZGJlZTg0NGI4ZjUzZWFlNjJmZTk1YjRhMzQ0OGE5ZWY3OTBhN2FlZGIyOTZkOSJ9fX0=", 12); + colors.put(12, "purple"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODZkMzVhOTYzZDU5ODc4OTRiNmJjMjE0ZTMyOGIzOWNkMjM4MjQyNmZmOWM4ZTA4MmIwYjZhNmUwNDRkM2EzIn19fQ==", 13); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjk1M2IxMmEwOTQ2YjYyOWI0YzA4ODlkNDFmZDI2ZWQyNmZiNzI5ZDRkNTE0YjU5NzI3MTI0YzM3YmI3MGQ4ZCJ9fX0=", 13); + colors.put(13, "red"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTk4YmEyYjM3NGNmYzg5NDU0YzFiOGMzMmRiNDU4YTI3MDY3NTQzOWE0OTU0OTZjOTY3NzFjOTg5MTE2MTYyIn19fQ==", 14); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTUyODhkZGM5MTFhNzVmNzdjM2E1ZDMzNjM2NWE4ZjhiMTM5ZmE1MzkzMGI0YjZlZTEzOTg3NWM4MGNlMzY2YyJ9fX0=", 14); + colors.put(14, "light-gray"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2ZhZjRjMjlmMWU3NDA1ZjQ2ODBjNWMyYjAzZWY5Mzg0ZjFhZWNmZTI5ODZhZDUwMTM4YzYwNWZlZmZmMmYxNSJ9fX0=", 15); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4ZGY2MGM1MTA3NGVlZjI1NDRmZjM4Y2VhZDllMTY2NzVhZTQyNTE5MTYxMDUxODBlMWY4Y2UxOTdhYjNiYyJ9fX0=", 15); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTVhZDkzZDU2NTQ2ZjEyZDUzNTZlZmZjYmM2ZWM0Yzg3YmEyNDVkODFlMTY2MmM0YjgzMGY3ZDI5OGU5In19fQ==", 15); + colors.put(15, "white"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDRiMDM3OTRiOWIzZTNiNWQwN2UzYmU2OGI5NmFmODdkZjIxNWMzNzUyZTU0NzM2YzgwZjdkNTBiZDM0MzdhNCJ9fX0=", 16); + colors.put(16, "rainbow"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkxMjdjYjdiZDNhOTg5ZDcyYzJlNWM0MjZlMWNjMTQ0NmI1ZTZkZTc0MTRkNDI3ODNmMmZlNmJhZGIxNzdkNCJ9fX0=", 17); + colors.put(17, "lilac"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkxMjdjYjdiZDNhOTg5ZDcyYzJlNWM0MjZlMWNjMTQ0NmI1ZTZkZTc0MTRkNDI3ODNmMmZlNmJhZGIxNzdkNCJ9fX0=", 18); + colors.put(18, "dark-red"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzM4NmY5YjBiMWQ5ODc5YzNkYTMzYzdhOGNhMjQ0MGMxZTQxMWZlOTNjMjdjOWRiYmZmNTZiZDY5N2JiNzM3NSJ9fX0=", 19); + colors.put(19, "i-rainbow"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjdiYmQwYjI5MTFjOTZiNWQ4N2IyZGY3NjY5MWE1MWI4YjEyYzZmZWZkNTIzMTQ2ZDhhYzVlZjFiOGVlIn19fQ==", 20); + colors.put(20, "yellow"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java new file mode 100644 index 00000000..5505fe9c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java @@ -0,0 +1,49 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.color; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import net.minecraft.init.Blocks; + +public class ColorProcessorMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return + right.getBlock(0,1,1).getBlock() == Blocks.stonebrick && + right.getBlock(0,1,2).getBlock() == Blocks.stonebrick && + right.getBlock(0,1,3).getBlock() == Blocks.stonebrick; + } + + @Override + public String getName() { + return "colorMatch"; + } + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return new ColorLeftProcessor(solver,left); + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return new ColorRightProcessor(solver,right); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java new file mode 100644 index 00000000..5c77abe1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java @@ -0,0 +1,175 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.color; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; + +import java.util.HashMap; +import java.util.Map; + +public class ColorRightProcessor extends GeneralDefuseChamberProcessor { + public ColorRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + center = chamber.getBlockPos(4,4,4); + b1 = chamber.getBlockPos(1,3,3); + b2 = chamber.getBlockPos(1,3,2); + b3 = chamber.getBlockPos(1,3,1); + } + + private final BlockPos center; + + private final BlockPos b1; + private final BlockPos b2; + private final BlockPos b3; + private byte b1b = 0, b2b = 0, b3b = 0, c1b, c2b, c3b; + private int answer = -1; + + @Override + public String getName() { + return "colorRight"; + } + + @Override + public void tick() { + super.tick(); + c1b = match(getChamber().getEntityAt(EntityArmorStand.class,b1.add(0, -1, 0))); + c2b = match(getChamber().getEntityAt(EntityArmorStand.class,b2.add(0, -1, 0))); + c3b = match(getChamber().getEntityAt(EntityArmorStand.class,b3.add(0, -1, 0))); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(answer == -1 ? "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.getParameter("key").getValue()) +" to request solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld( colors.get((int) c1b), b1.getX()+ 0.5f, b1.getY()+0.6f, b1.getZ()+ 0.5f,c1b == b1b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld( colors.get((int) c2b), b2.getX()+ 0.5f, b2.getY()+0.6f, b2.getZ()+ 0.5f,c2b == b2b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld( colors.get((int) c3b), b3.getX()+ 0.5f, b3.getY()+0.6f, b3.getZ()+ 0.5f,c3b == b3b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + + RenderUtils.drawTextAtWorld( colors.get((int) b1b), b1.getX()+ 0.5f, b1.getY()+0.2f, b1.getZ()+ 0.5f,0xFFFFFF00, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld( colors.get((int) b2b), b2.getX()+ 0.5f, b2.getY()+0.2f, b2.getZ()+ 0.5f,0xFFFFFF00, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld( colors.get((int) b3b), b3.getX()+ 0.5f, b3.getY()+0.2f, b3.getZ()+ 0.5f,0xFFFFFF00, 0.03F, false, false, partialTicks); + } + + @Override + public void onSendData() { + super.onSendData(); + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setByte("a", (byte) 6); + nbt.setByte("f", (byte) Block.getIdFromBlock(getChamber().getBlock(0,3,3).getBlock())); + nbt.setByte("s", (byte) Block.getIdFromBlock(getChamber().getBlock(0,3,2).getBlock())); + nbt.setByte("t", (byte) Block.getIdFromBlock(getChamber().getBlock(0,3,1).getBlock())); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (7 == compound.getByte("a")) { + answer = compound.getInteger("b"); + b3b = (byte) (answer / 10000); + b2b = (byte) ((answer % 10000) / 100); + b1b = (byte) (answer % 100); + + } + } + + private byte match(EntityArmorStand armorStand) { + if (armorStand == null) { + return 0; + } + ItemStack item = armorStand.getInventory()[4]; + NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); + String str = ((NBTTagCompound)list.get(0)).getString("Value"); + return (byte) (!integers.containsKey(str) ? 0 : integers.get(str)); + } + + private static final Map integers = new HashMap(); + private static final BiMap colors = HashBiMap.create(); + static { + colors.put(0, "?"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2YzZTQwNjI5MTE3NGQyNGNkZjBmOTUzZjhhMTc0YTgyYmIzNDg5ZGNlOGY2NzlhNDQzZWYxYWFlMDE2OTA2MSJ9fX0=", 1); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWE4MWZjYjUxYmUyYTlmODliMWFkYzlkODcyMzliYTQyOWQ2MzVmYmUwMWIzN2VjMzI5MTY0ODg3YmY2NjViIn19fQ==", 1); + colors.put(1, "blue"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2FiMDI2M2JkZDc2ZjNlNDE4ZGJhNWJmNDgxYjkyMWNlZDM5N2Q4YjhhMzRhNTU2MWZiN2JlYWE0NmVjZTEifX19", 2); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2ZhNGRkYTZkMTlhMWZlMmQ5ODhkNjVkZWM1MzQyOTUwNTMwODE2NmM5MDY3YjY4YTQ3NzBjYTVjNDM2Y2Y5NCJ9fX0=", 2); + colors.put(2, "black"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDg0Njg0MzQ0YWUwOTg1MjlmYzk0MWFhODRlMTk1YmRjYTM3NDhkNjlhY2ZlZTJiYWMxMzMyMTM1ZWRkOThjIn19fQ==", 3); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTM1ODFjMmY5Y2YzNThkN2VkYzc4ZGQ2ZmQ0YjYyNTc1MDFiYzRlNjQ1NWUzM2ZhMGNhYWUyMDdjZjAzMjFhMiJ9fX0=", 3); + colors.put(3, "green"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTllNjkxN2YyZmI0ZWEwOGU3MTMyZGYzMDk2MWQyYjVjNTIzYWJiYTE5Y2U0M2Y4MzVmYzE0YzU2OGY0In19fQ==", 4); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWRmMjFmNTMyMTIyNTY2YWY4OTNkYTI3ODgwYTFiNjA5NWMzNTcxMmYyOWEzNzhjZmVjYzdmZTJiMTMyOGFiNCJ9fX0=", 4); + colors.put(4, "gray"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODhlZmFkNzRiMjU0ZTU3Yzc5OTc2M2RjZWVlNDUxMWZhMmY4NWFlOWZhNTU2ZWFhOTdkNDViZjY3ZTBiNmIzIn19fQ==", 5); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWZhZGY3NDFhYjc2Y2QzNjIwYWQxNjEzMDAyMDJkN2I1OWEzMzA1MWU1OTY3ZTRiNjE5NGJhYzQwYmIyODBmZiJ9fX0=", 5); + colors.put(5, "cyan"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzJlMzZmNmE2NTRkZTc0NTgzZDgwMzAxNzdhZDZlM2FjNjc1NWQ3NDM1ZDkxMjNlOGViZGZmNzRiMmQ5MGNiIn19fQ==", 6); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjJjYmQ5ZjQzNjE5YWI1Y2IxYjExZjkxY2IwM2U5NTVjNmZjNmM0NThhYmY4OWFiNjEwMzEzNDZhMDkwNjEyZSJ9fX0=", 6); + colors.put(6, "brown"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjFhZjQ2ZmViZDQ1YzBmNGQ4MWU4ZmExYjY2YjI3NWQ4OWUyNzJiMmFkNTVjOTc4NTUzYTk5YzczM2UxZmYifX19", 7); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYzZTY2NDZmMWMwZDQxZmQzYmY1NTg0YTFjZTA0NGY1YzQ2ZDU5ODI1OGRiNDYyMTYxMTc4NTlmNTdhZjE5NyJ9fX0=", 7); + colors.put(7, "light-blue"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDY3NDcwYTBjMThmNjg1MWU5MTQzNTM3MTllNzk1ODc3ZDI5YjMyNTJmN2U2YmQ0YTFiODY1NzY1YmQ3NGZlYiJ9fX0=", 8); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzc0NzJkNjA4ODIxZjQ1YTg4MDUzNzZlYzBjNmZmY2I3ODExNzgyOWVhNWY5NjAwNDFjMmEwOWQxMGUwNGNiNCJ9fX0=", 8); + colors.put(8, "lime"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWJiNDM4NmJjZGE4NGUzNTNjMzFkNzc4ZDNiMTFiY2QyNmZlYTQ5NGRkNjM0OTZiOGE4MmM3Yzc4YTRhZCJ9fX0=", 9); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjk3MDEyZWQ2YTkyYjA1ZWEwZjE5NDk1MDc0ODU0NGUwNzViYWEyODc4MWNhMzczZDFiMjdlMjhjMjY5NTNjIn19fQ==", 9); + colors.put(9, "magenta"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2JmNzc5N2EyNGE2YWY4NzVmNWM4MjcxYzViOGM0MjVlMTlmMzcyYTQxNWUwNTUyZmMyNDc3NjNmMjg1OWQxIn19fQ==", 10); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWRmMmViMjA1YTIzYzExOTZiM2VjZjIxZTY4YzA3NmI2OTZlNzYxNjNhYzhmYzRmYjlmNTMxOGMyYTVlNWIxYSJ9fX0=", 10); + colors.put(10, "orange"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmJlY2ZiMzg3OTkzNmI4OTllNDIwYmZjZDNhNzRmOGExYmY5ZGQ1NGM1OGVjN2ZiOWY4MWQ5YTVkOTg4ZSJ9fX0=", 11); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4ODM2NTBlYTkyOWRiMGVhYmRmNWJjNzU1OTlkOGVmMDBkNzAzNDBjZDFjZTVlMDRhZDk1ZWY4ZWQ4M2I3MyJ9fX0=", 11); + colors.put(11, "pink"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmE5NGNiMjVkZTYyOGNhMzU5YjJmNmVhNWE4ODY4Y2JlMjY1OTVlZWRiMmJmZmI3NTA5NjdhZDFlZTE4NTAifX19", 12); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODllYzVhMzAyMjJkMDY1OWIwZGJlZTg0NGI4ZjUzZWFlNjJmZTk1YjRhMzQ0OGE5ZWY3OTBhN2FlZGIyOTZkOSJ9fX0=", 12); + colors.put(12, "purple"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODZkMzVhOTYzZDU5ODc4OTRiNmJjMjE0ZTMyOGIzOWNkMjM4MjQyNmZmOWM4ZTA4MmIwYjZhNmUwNDRkM2EzIn19fQ==", 13); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjk1M2IxMmEwOTQ2YjYyOWI0YzA4ODlkNDFmZDI2ZWQyNmZiNzI5ZDRkNTE0YjU5NzI3MTI0YzM3YmI3MGQ4ZCJ9fX0=", 13); + colors.put(13, "red"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTk4YmEyYjM3NGNmYzg5NDU0YzFiOGMzMmRiNDU4YTI3MDY3NTQzOWE0OTU0OTZjOTY3NzFjOTg5MTE2MTYyIn19fQ==", 14); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTUyODhkZGM5MTFhNzVmNzdjM2E1ZDMzNjM2NWE4ZjhiMTM5ZmE1MzkzMGI0YjZlZTEzOTg3NWM4MGNlMzY2YyJ9fX0=", 14); + colors.put(14, "light-gray"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2ZhZjRjMjlmMWU3NDA1ZjQ2ODBjNWMyYjAzZWY5Mzg0ZjFhZWNmZTI5ODZhZDUwMTM4YzYwNWZlZmZmMmYxNSJ9fX0=", 15); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4ZGY2MGM1MTA3NGVlZjI1NDRmZjM4Y2VhZDllMTY2NzVhZTQyNTE5MTYxMDUxODBlMWY4Y2UxOTdhYjNiYyJ9fX0=", 15); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTVhZDkzZDU2NTQ2ZjEyZDUzNTZlZmZjYmM2ZWM0Yzg3YmEyNDVkODFlMTY2MmM0YjgzMGY3ZDI5OGU5In19fQ==", 15); + colors.put(15, "white"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDRiMDM3OTRiOWIzZTNiNWQwN2UzYmU2OGI5NmFmODdkZjIxNWMzNzUyZTU0NzM2YzgwZjdkNTBiZDM0MzdhNCJ9fX0=", 16); + colors.put(16, "rainbow"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkxMjdjYjdiZDNhOTg5ZDcyYzJlNWM0MjZlMWNjMTQ0NmI1ZTZkZTc0MTRkNDI3ODNmMmZlNmJhZGIxNzdkNCJ9fX0=", 17); + colors.put(17, "lilac"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkxMjdjYjdiZDNhOTg5ZDcyYzJlNWM0MjZlMWNjMTQ0NmI1ZTZkZTc0MTRkNDI3ODNmMmZlNmJhZGIxNzdkNCJ9fX0=", 18); + colors.put(18, "dark-red"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzM4NmY5YjBiMWQ5ODc5YzNkYTMzYzdhOGNhMjQ0MGMxZTQxMWZlOTNjMjdjOWRiYmZmNTZiZDY5N2JiNzM3NSJ9fX0=", 19); + colors.put(19, "i-rainbow"); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjdiYmQwYjI5MTFjOTZiNWQ4N2IyZGY3NjY5MWE1MWI4YjEyYzZmZWZkNTIzMTQ2ZDhhYzVlZjFiOGVlIn19fQ==", 20); + colors.put(20, "yellow"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java new file mode 100644 index 00000000..f651a780 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java @@ -0,0 +1,95 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.creeper; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; + +import java.awt.*; + +public class CreeperLeftProcessor extends GeneralDefuseChamberProcessor { + public CreeperLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + poses = new BlockPos[9]; + for (int i = 0; i < 9; i++) { + poses[i] = chamber.getBlockPos(3+(i%3), 1, 1+(i/3)); + } + } + + @Override + public String getName() { + return "creeperLeft"; + } + + + private int answer = -1; + private final BlockPos[] poses; + @Override + public void tick() { + super.tick(); + if (answer != -1) return; + answer = 0; + for (int i = 0; i < poses.length; i++) { + BlockPos pos = poses[i]; + if (getChamber().getRoom().getContext().getWorld().getBlockState(pos).getBlock() == Blocks.air) { + answer |= (1 << i); + } + } + } + + @Override + public void drawScreen(float partialTicks) { + if (answer == -1) return; + drawPressKey(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + for (int i = 0; i < 9; i++) { + if (((answer >> i) & 0x01) != 0) { + RenderUtils.highlightBlock(poses[i], new Color(255,0,0,100), partialTicks, false); + } else { + RenderUtils.highlightBlock(poses[i], new Color(0,255,0,100), partialTicks, false); + } + } + } + + @Override + public void onSendData() { + if (answer == -1) return; + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setByte("a", (byte) 2); + nbt.setInteger("b", answer); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (2 == compound.getByte("a")) { + answer = compound.getInteger("b"); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java new file mode 100644 index 00000000..f2ad23b6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.creeper; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import net.minecraft.init.Blocks; + +public class CreeperProcessorMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + int airs = 0; + for (int x = 0; x < 3; x ++) { + for (int y = 0; y < 3; y++) { + if (right.getBlock(3 + x, 1, y + 1).getBlock() != Blocks.stone) return false; + } + } + return true; + } + + @Override + public String getName() { + return "creeperMatch"; + } + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return new CreeperLeftProcessor(solver, left); + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return new CreeperRightProcessor(solver, right); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java new file mode 100644 index 00000000..258c0e8f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java @@ -0,0 +1,73 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.creeper; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; + +import java.awt.*; + +public class CreeperRightProcessor extends GeneralDefuseChamberProcessor { + public CreeperRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + poses = new BlockPos[9]; + for (int i = 0; i < 9; i++) { + poses[i] = chamber.getBlockPos(3+(i%3), 1, 1+(i/3)); + } + center = chamber.getBlockPos(4,4,4); + } + + @Override + public String getName() { + return "creeperRight"; + } + + + private int answer = -1; + private final BlockPos[] poses; + private final BlockPos center; + @Override + public void tick() { + super.tick(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + if (answer != -1) { + for (int i = 0; i < 9; i++) { + if (((answer >> i) & 0x01) == 0) { + RenderUtils.highlightBlock(poses[i], new Color(0,255,0, 50), partialTicks, false); + } + } + } + } + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (2 == compound.getByte("a")) { + answer = compound.getInteger("b"); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java new file mode 100644 index 00000000..6a531aed --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java @@ -0,0 +1,141 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.goldenpath; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class GoldenPathLeftProcessor extends GeneralDefuseChamberProcessor { + public GoldenPathLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + } + + @Override + public String getName() { + return "goldenPathLeft"; + } + + + // 1 up 2 right 3 down 4 left + private static final Point[] vectors = new Point[] { + new Point(0,1), + new Point(-1,0), + new Point(0, -1), + new Point(1, 0) + }; + + private final LinkedList blocksolution = new LinkedList(); + private String goldenPathsolution; + @Override + public void tick() { + super.tick(); + if (goldenPathsolution != null) return; + + List solution = new ArrayList(); + Set visited = new HashSet(); + BlockPos lastLoc = new BlockPos(4,0,0); + visited.add(lastLoc); + blocksolution.add(getChamber().getBlockPos(4,1,0)); + BlockPos target = new BlockPos(4,0,5); + while (!lastLoc.equals(target)) { + boolean solution2 = false; + for (int i =0; i 8 || target2.getZ() > 5) continue; + + visited.add(target2); + if (getChamber().getBlock(target2.getX(), 0, target2.getZ()).getBlock() == Blocks.hardened_clay + || getChamber().getBlock(target2.getX(), 0, target2.getZ()).getBlock() == Blocks.stained_hardened_clay) { + lastLoc = target2; + + blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); + solution.add(i); + solution2 = true; + break; + } + } + if (!solution2){ + return; + } + } + + goldenPathsolution = ""; + for (Integer i:solution) + goldenPathsolution += i; + } + + @Override + public void drawScreen(float partialTicks) { + if (goldenPathsolution == null) return; + drawPressKey(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawLines(blocksolution, new AColor(0,0,255,0), 1,partialTicks, false); + } + + @Override + public void onSendData() { + if (goldenPathsolution == null) return; + Minecraft.getMinecraft().thePlayer.sendChatMessage("/pc $DG-BDGP "+goldenPathsolution); + + ChatComponentText text = new ChatComponentText("$DG-BDGP "+goldenPathsolution); + for (RoomProcessorBombDefuseSolver.ChamberSet ch: getSolver().getChambers()) { + if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) + ch.getLeft().getProcessor().chatReceived(text); + if (ch.getRight() != null && ch.getRight().getProcessor() != null) + ch.getRight().getProcessor().chatReceived(text); + } + } + + @Override + public void chatReceived(IChatComponent chat) { + super.chatReceived(chat); + if (chat.getFormattedText().contains("$DG-BDGP ")) { + String data = chat.getFormattedText().substring(chat.getFormattedText().indexOf("$DG-BDGP ")); + String actual = TextUtils.stripColor(data).trim().split(" ")[1].trim(); + + blocksolution.clear(); + BlockPos lastLoc = new BlockPos(4,0,0); + blocksolution.addFirst(getChamber().getBlockPos(4,1,0)); + for (Character c:actual.toCharArray()) { + int dir = Integer.parseInt(c+"") % 4; + lastLoc = lastLoc.add(vectors[dir].x, 0, vectors[dir].y); + blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java new file mode 100644 index 00000000..5f5ac89b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java @@ -0,0 +1,47 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.goldenpath; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import net.minecraft.init.Blocks; + +public class GoldenPathProcessorMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return left.getBlock(4,0,0).getBlock() == Blocks.hardened_clay + || left.getBlock(4,0,0).getBlock() == Blocks.stained_hardened_clay; + } + + @Override + public String getName() { + return "goldPath"; + } + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return new GoldenPathLeftProcessor(solver, left); + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return new GoldenPathRightProcessor(solver, right); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java new file mode 100644 index 00000000..d432da80 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java @@ -0,0 +1,97 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.goldenpath; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; + +import java.awt.*; +import java.util.*; + +public class GoldenPathRightProcessor extends GeneralDefuseChamberProcessor { + public GoldenPathRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + center = chamber.getBlockPos(4,4,4); + } + + @Override + public String getName() { + return "goldenPathRight"; + } + + + private final BlockPos center; + // 1 up 2 right 3 down 4 left + private static final Point[] vectors = new Point[] { + new Point(0,1), + new Point(-1,0), + new Point(0, -1), + new Point(1, 0) + }; + + private final LinkedList blocksolution = new LinkedList(); + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(blocksolution.size() == 0 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + + RenderUtils.drawLines(blocksolution, new AColor(0,0,255,0),1, partialTicks, false); + + } + + @Override + public void chatReceived(IChatComponent chat) { + super.chatReceived(chat); + if (chat.getFormattedText().contains("$DG-BDGP ")) { + String data = chat.getFormattedText().substring(chat.getFormattedText().indexOf("$DG-BDGP")); + String actual = TextUtils.stripColor(data).trim().split(" ")[1].trim(); + + blocksolution.clear(); + BlockPos lastLoc = new BlockPos(4,0,0); + blocksolution.addFirst(getChamber().getBlockPos(4,1,0)); + for (Character c:actual.toCharArray()) { + int dir = Integer.parseInt(c+"") % 4; + lastLoc = lastLoc.add(vectors[dir].x, 0, vectors[dir].y); + blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); + } + + World w = getChamber().getRoom().getContext().getWorld(); + for (int x = 0; x <9; x++) { + for (int z =0; z < 6; z++) { + BlockPos pos = getChamber().getBlockPos(x,1,z); + if (blocksolution.contains(pos)) { + w.setBlockState(pos, Blocks.light_weighted_pressure_plate.getDefaultState()); + } else { + w.setBlockState(pos, Blocks.wooden_pressure_plate.getDefaultState()); + } + } + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java new file mode 100644 index 00000000..d2b9927c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java @@ -0,0 +1,80 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.maze; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +public class MazeLeftProcessor extends GeneralDefuseChamberProcessor { + public MazeLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + } + + @Override + public String getName() { + return "mazeLeft"; + } + + + @Override + public void drawScreen(float partialTicks) { + if (Minecraft.getMinecraft().objectMouseOver == null ) return; + MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; + if (pos.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return; + + Block b = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos.getBlockPos()).getBlock(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + String str = "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.getParameter("key").getValue()) + " to request open "+b.getLocalizedName(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(str, (sr.getScaledWidth() - fr.getStringWidth(str)) / 2, (sr.getScaledHeight() - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + } + + @Override + public void onSendData() { + if (Minecraft.getMinecraft().objectMouseOver == null ) return; + MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; + if (pos.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return; + + BlockPos block = pos.getBlockPos(); + Block b = getChamber().getRoom().getContext().getWorld().getBlockState(block).getBlock(); + + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setByte("a", (byte) 5); + nbt.setInteger("b", Block.getIdFromBlock(b)); + getSolver().communicate(nbt); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java new file mode 100644 index 00000000..1429d302 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java @@ -0,0 +1,47 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.maze; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import net.minecraft.init.Blocks; + +public class MazeProcessorMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return right.getBlock(1,0,1).getBlock() != Blocks.double_stone_slab && + left.getBlock(1,1,1).getBlock() != Blocks.barrier; + } + + @Override + public String getName() { + return "mazeMatch"; + } + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return new MazeLeftProcessor(solver, left); + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return new MazeRightProcessor(solver, right); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java new file mode 100644 index 00000000..df9f8f93 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java @@ -0,0 +1,73 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.maze; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +public class MazeRightProcessor extends GeneralDefuseChamberProcessor { + public MazeRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + center = chamber.getBlockPos(4,4,4); + + for (int x = 0; x < 9; x++) { + for (int y =0; y< 6; y++) { + Block b = chamber.getBlock(x,0,y).getBlock(); + BlockPos pos = chamber.getBlockPos(x,0,y); + blockToBlockPosMap.put(b, pos); + } + } + } + + private final BlockPos center; + private final Map blockToBlockPosMap = new HashMap(); + @Override + public String getName() { + return "mazeRight"; + } + + + private Block latestRequest = null; + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(latestRequest == null ? "Request not received yet" : "Requested received "+latestRequest.getLocalizedName() , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + BlockPos pos = blockToBlockPosMap.get(latestRequest); + if (pos == null) return; + RenderUtils.highlightBlock(pos, new Color(0,255,0,100), partialTicks, false); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (5 == compound.getByte("a")) { + int latestRequestid = compound.getInteger("b"); + latestRequest = Block.getBlockById(latestRequestid); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java new file mode 100644 index 00000000..11c7fefd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java @@ -0,0 +1,125 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.number; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; + +public class NumberLeftProcessor extends GeneralDefuseChamberProcessor { + public NumberLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + d1p = chamber.getBlockPos(1,1,4); + d2p = chamber.getBlockPos(2,1,4); + d3p = chamber.getBlockPos(6,1,4); + d4p = chamber.getBlockPos(7,1,4); + } + + @Override + public String getName() { + return "numberLeft"; + } + + + private int answer = -1, d1, d2, d3 ,d4; + private final BlockPos d1p; + private final BlockPos d2p; + private final BlockPos d3p; + private final BlockPos d4p; + @Override + public void tick() { + super.tick(); + if (answer != -1) return; + d1 = match(getChamber().getEntityAt(EntityArmorStand.class,d1p)); + d2 = match(getChamber().getEntityAt(EntityArmorStand.class,d2p)); + d3 = match(getChamber().getEntityAt(EntityArmorStand.class,d3p)); + d4 = match(getChamber().getEntityAt(EntityArmorStand.class,d4p)); + if (d1 == -1 || d2 == -1 || d3 == -1 || d4 == -1) return; + + answer = d1 * 1000 + d2 * 100 + d3 * 10 + d4; + } + + @Override + public void drawScreen(float partialTicks) { + if (answer == -1) return; + drawPressKey(); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(d1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.5f, d1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.5f, d2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.5f, d3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.5f, d4p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + + } + + @Override + public void onSendData() { + if (answer == -1) return; + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setByte("a", (byte) 1); + nbt.setInteger("b", answer); + getSolver().communicate(nbt); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (1 == compound.getByte("a")) { + answer = compound.getInteger("b"); + d1 = answer / 1000; + d2 = (answer % 1000) / 100; + d3 = (answer % 100) / 10; + d4 = (answer % 10); + answer = d1 * 1000 + d2 * 100 + d3 * 10 + d4; + } + } + + private int match(EntityArmorStand armorStand) { + if (armorStand == null) return -1; + ItemStack item = armorStand.getInventory()[4]; + NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); + String str = ((NBTTagCompound)list.get(0)).getString("Value"); + return !integers.containsKey(str) ? -1 : integers.get(str); + } + + private static final BiMap integers = HashBiMap.create(10); + { + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzFhOTQ2M2ZkM2M0MzNkNWUxZDlmZWM2ZDVkNGIwOWE4M2E5NzBiMGI3NGRkNTQ2Y2U2N2E3MzM0OGNhYWIifX19", 1); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWNiNDE5ZDk4NGQ4Nzk2MzczYzk2NDYyMzNjN2EwMjY2NGJkMmNlM2ExZDM0NzZkZDliMWM1NDYzYjE0ZWJlIn19fQ==", 2); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjhlYmFiNTdiNzYxNGJiMjJhMTE3YmU0M2U4NDhiY2QxNGRhZWNiNTBlOGY1ZDA5MjZlNDg2NGRmZjQ3MCJ9fX0=", 3); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjJiZmNmYjQ4OWRhODY3ZGNlOTZlM2MzYzE3YTNkYjdjNzljYWU4YWMxZjlhNWE4YzhhYzk1ZTRiYTMifX19", 4); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWY0ZWNmMTEwYjBhY2VlNGFmMWRhMzQzZmIxMzZmMWYyYzIxNjg1N2RmZGE2OTYxZGVmZGJlZTdiOTUyOCJ9fX0=", 5); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMzMWE2YTZmY2Q2OTk1YjYyMDg4ZDM1M2JmYjY4ZDliODlhZTI1ODMyNWNhZjNmMjg4NjQ2NGY1NGE3MzI5In19fQ==", 6); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDRiYTZhYzA3ZDQyMjM3N2E4NTU3OTNmMzZkZWEyZWQyNDAyMjNmNTJmZDE2NDgxODE2MTJlY2QxYTBjZmQ1In19fQ==", 7); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzYxYThhNjQxNDM3YmU5YWVhMjA3MjUzZGQzZjI1NDQwZDk1NGVhMmI1ODY2YzU1MmYzODZiMjlhYzRkMDQ5In19fQ==", 8); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTE5MjhlMWJmZDg2YTliNzkzOTdjNGNiNGI2NWVmOTlhZjQ5YjdkNWY3OTU3YWQ2MmMwYzY5OWE2MjJjZmJlIn19fQ==", 9); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTVhMjI0ODA3NjkzOTc4ZWQ4MzQzNTVmOWU1MTQ1ZjljNTZlZjY4Y2Y2ZjJjOWUxNzM0YTQ2ZTI0NmFhZTEifX19", 0); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java new file mode 100644 index 00000000..488583ff --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java @@ -0,0 +1,53 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.number; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.ChamberProcessor; +import net.minecraft.init.Blocks; + +public class NumberProcessorMatcher implements BombDefuseChamberGenerator { + @Override + public boolean match(BDChamber left, BDChamber right) { + return left.getBlock(1,1,4).getBlock() == Blocks.stone && + left.getBlock(2,1,4).getBlock() == Blocks.stone && + left.getBlock(6,1,4).getBlock() == Blocks.stone && + left.getBlock(7,1,4).getBlock() == Blocks.stone && + right.getBlock(1,1,4).getBlock() == Blocks.stone && + right.getBlock(2,1,4).getBlock() == Blocks.stone && + right.getBlock(6,1,4).getBlock() == Blocks.stone && + right.getBlock(7,1,4).getBlock() == Blocks.stone; + } + + @Override + public String getName() { + return "numberMatch"; + } + @Override + public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { + return new NumberLeftProcessor(solver, left); + } + + @Override + public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { + return new NumberRightProcessor(solver, right); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java new file mode 100644 index 00000000..66ba993a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java @@ -0,0 +1,114 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.number; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.BDChamber; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; + +public class NumberRightProcessor extends GeneralDefuseChamberProcessor { + public NumberRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { + super(solver, chamber); + + d1p = chamber.getBlockPos(1,1,4); + d2p = chamber.getBlockPos(2,1,4); + d3p = chamber.getBlockPos(6,1,4); + d4p = chamber.getBlockPos(7,1,4); + center = chamber.getBlockPos(4,4,4); + } + + @Override + public String getName() { + return "numberRight"; + } + + + private int answer = -1, d1, d2, d3 ,d4, a1, a2, a3, a4; + private final BlockPos d1p; + private final BlockPos d2p; + private final BlockPos d3p; + private final BlockPos d4p; + private final BlockPos center; + @Override + public void tick() { + super.tick(); + a1 = match(getChamber().getEntityAt(EntityArmorStand.class,d1p)); + a2 = match(getChamber().getEntityAt(EntityArmorStand.class,d2p)); + a3 = match(getChamber().getEntityAt(EntityArmorStand.class,d3p)); + a4 = match(getChamber().getEntityAt(EntityArmorStand.class,d4p)); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + RenderUtils.drawTextAtWorld(a1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.6f, d1p.getZ()+ 0.5f, a1 == d1 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(a2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.6f, d2p.getZ()+ 0.5f, a2 == d2 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(a3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.6f, d3p.getZ()+ 0.5f, a3 == d3 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(a4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.6f, d4p.getZ()+ 0.5f, a4 == d4 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : ("Solution: "+answer) , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.2f, d1p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.2f, d2p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.2f, d3p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + RenderUtils.drawTextAtWorld(d4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.2f, d4p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); + } + + @Override + public void onDataRecieve(NBTTagCompound compound) { + if (1 == compound.getByte("a")) { + answer = compound.getInteger("b"); + d1 = answer / 1000; + d2 = (answer % 1000) / 100; + d3 = (answer % 100) / 10; + d4 = (answer % 10); + answer = d4 * 1000 + d3 * 100 + d2 * 10 + d1; + } + } + + private int match(EntityArmorStand armorStand) { + if (armorStand == null) { + return -1; + } + ItemStack item = armorStand.getInventory()[4]; + NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); + String str = ((NBTTagCompound)list.get(0)).getString("Value"); + return !integers.containsKey(str) ? -1 : integers.get(str); + } + + private static final BiMap integers = HashBiMap.create(10); + { + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzFiYzJiY2ZiMmJkMzc1OWU2YjFlODZmYzdhNzk1ODVlMTEyN2RkMzU3ZmMyMDI4OTNmOWRlMjQxYmM5ZTUzMCJ9fX0=", 1); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGNkOWVlZWU4ODM0Njg4ODFkODM4NDhhNDZiZjMwMTI0ODVjMjNmNzU3NTNiOGZiZTg0ODczNDE0MTk4NDcifX19", 2); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWQ0ZWFlMTM5MzM4NjBhNmRmNWU4ZTk1NTY5M2I5NWE4YzNiMTVjMzZiOGI1ODc1MzJhYzA5OTZiYzM3ZTUifX19", 3); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDJlNzhmYjIyNDI0MjMyZGMyN2I4MWZiY2I0N2ZkMjRjMWFjZjc2MDk4NzUzZjJkOWMyODU5ODI4N2RiNSJ9fX0=", 4); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmQ1N2UzYmM4OGE2NTczMGUzMWExNGUzZjQxZTAzOGE1ZWNmMDg5MWE2YzI0MzY0M2I4ZTU0NzZhZTIifX19", 5); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzM0YjM2ZGU3ZDY3OWI4YmJjNzI1NDk5YWRhZWYyNGRjNTE4ZjVhZTIzZTcxNjk4MWUxZGNjNmIyNzIwYWIifX19", 6); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRiNmViMjVkMWZhYWJlMzBjZjQ0NGRjNjMzYjU4MzI0NzVlMzgwOTZiN2UyNDAyYTNlYzQ3NmRkN2I5In19fQ==", 7); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTkxOTQ5NzNhM2YxN2JkYTk5NzhlZDYyNzMzODM5OTcyMjI3NzRiNDU0Mzg2YzgzMTljMDRmMWY0Zjc0YzJiNSJ9fX0=", 8); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTY3Y2FmNzU5MWIzOGUxMjVhODAxN2Q1OGNmYzY0MzNiZmFmODRjZDQ5OWQ3OTRmNDFkMTBiZmYyZTViODQwIn19fQ==", 9); + integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMGViZTdlNTIxNTE2OWE2OTlhY2M2Y2VmYTdiNzNmZGIxMDhkYjg3YmI2ZGFlMjg0OWZiZTI0NzE0YjI3In19fQ==", 0); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessor.java new file mode 100644 index 00000000..12ef6bdf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessor.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessor; + +import java.util.List; + +public interface BossfightProcessor extends RoomProcessor { + List getPhases(); + String getCurrentPhase(); + List getNextPhases(); + + List getHealths(); + + String getBossName(); +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorBonzo.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorBonzo.java new file mode 100644 index 00000000..3380a447 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorBonzo.java @@ -0,0 +1,85 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraftforge.event.entity.living.LivingEvent; + +import java.util.ArrayList; +import java.util.List; + +public class BossfightProcessorBonzo extends GeneralBossfightProcessor { + public BossfightProcessorBonzo() { + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("start") + .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Gratz for making it this far, but Iโ€™m basically unbeatable.ยงr") + .nextPhase("fight-1").build() + ); + + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("fight-1") + .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: I can summon lots of undead! Check this out.ยงr") + .nextPhase("first-defeat").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("first-defeat") + .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Oh I'm dead!ยงr").signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Hoho, looks like you killed me!ยงr") + .nextPhase("fight-2").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("fight-2") + .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Sikeยงr").signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: I can revive myself and become much stronger!ยงr") + .nextPhase("final-defeat").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("final-defeat") + .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Alright, maybe I'm just weak after all..ยงr").build() + ); + } + + + @Override + public List getHealths() { + List healths = new ArrayList(); + long health = 0; + if (bonzoStand != null) { + String name = TextUtils.stripColor(bonzoStand.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Bonzo", (int) health,250000 , this.getCurrentPhase().startsWith("fight-"))); + return healths; + } + + @Override + public String getBossName() { + return "Bonzo"; + } + + private EntityArmorStand bonzoStand; + @Override + // ยงe๏ดพ ยงcยงlBonzoยงr ยงe71kยงcโค ยงe๏ดฟ + // ยงe๏ดพ ยงcยงlBonzoยงr ยงa250kยงcโค ยงe๏ดฟ + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + if (updateEvent.entityLiving.getName().startsWith("ยงe๏ดพ ยงcยงlBonzoยงr ") && updateEvent.entityLiving instanceof EntityArmorStand) { + bonzoStand = (EntityArmorStand) updateEvent.entityLiving; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorLivid.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorLivid.java new file mode 100644 index 00000000..f75226b6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorLivid.java @@ -0,0 +1,90 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.Getter; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraftforge.event.entity.living.LivingEvent; + +import java.util.*; + +@Getter +public class BossfightProcessorLivid extends GeneralBossfightProcessor { + private String realLividName; + private String prefix; + private EntityOtherPlayerMP realLivid; + + private final Set knownLivids = new HashSet(); + + private boolean isMasterMode; + + public BossfightProcessorLivid(boolean isMasterMode) { + addPhase(PhaseData.builder().phase("start").build()); + this.isMasterMode = isMasterMode; + } + private static final Map lividColorPrefix = new HashMap() {{ + put("Vendetta", "ยงf"); + put("Crossed", "ยงd"); + put("Hockey", "ยงc"); + put("Doctor", "ยง7"); + put("Frog", "ยง2"); + put("Smile", "ยงa"); + put("Scream", "ยง1"); + put("Purple", "ยง5"); + put("Arcade", "ยงe"); + }}; + @Override + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + if (updateEvent.entityLiving.getName().endsWith("Livid") && updateEvent.entityLiving instanceof EntityOtherPlayerMP) { + if (!knownLivids.contains(updateEvent.entityLiving.getName())) { + knownLivids.add(updateEvent.entityLiving.getName()); + realLividName = updateEvent.entityLiving.getName(); + realLivid = (EntityOtherPlayerMP) updateEvent.entityLiving; + prefix = lividColorPrefix.get(realLividName.split(" ")[0]); + } else if (realLividName.equalsIgnoreCase(updateEvent.entityLiving.getName())) { + realLivid = (EntityOtherPlayerMP) updateEvent.entityLiving; + } + } else if (updateEvent.entityLiving.getName().startsWith(prefix+"๏ดพ ") && updateEvent.entityLiving instanceof EntityArmorStand) { + lividStand = (EntityArmorStand) updateEvent.entityLiving; + } + } + private EntityArmorStand lividStand; + + @Override + public List getHealths() { + List healths = new ArrayList(); + long health = 0; + if (lividStand != null) { + try { + String name = TextUtils.stripColor(lividStand.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } catch (Exception e) {e.printStackTrace();} + } + healths.add(new HealthData(realLividName == null ? "unknown" : realLividName, (int) health,isMasterMode ? 600000000 : 7000000 , true)); + return healths; + } + + @Override + public String getBossName() { + return realLividName == null ? "Livid" : realLividName; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorNecron.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorNecron.java new file mode 100644 index 00000000..49b572fe --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorNecron.java @@ -0,0 +1,77 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import net.minecraft.entity.boss.BossStatus; + +import java.util.ArrayList; +import java.util.List; + +public class BossfightProcessorNecron extends GeneralBossfightProcessor { + // \A7 to ยง + public BossfightProcessorNecron() { + addPhase(PhaseData.builder() + .phase("crystals") + .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcFinally, I heard so much about you. The Eye likes you very much.ยงr") + .nextPhase("laser-attack").nextPhase("lost").build() + ); + addPhase(PhaseData.builder() + .phase("laser-attack") + .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcYou tricked me!ยงr") + .nextPhase("fight-1").nextPhase("lost").build() + ); + addPhase(PhaseData.builder() + .phase("fight-1") + .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcFINE! LET'S MOVE TO SOMEWHERE ELSE!!ยงr") + .nextPhase("terminals").nextPhase("lost").build() + ); + addPhase(PhaseData.builder() + .phase("terminals") + .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcCRAP!! IT BROKE THE FLOOR!ยงr") + .nextPhase("fight-2").nextPhase("lost").build() + ); + addPhase(PhaseData.builder() + .phase("fight-2") + .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcTHAT'S IT YOU HAVE DONE IT!ยงr") + .nextPhase("won").nextPhase("lost").build() + ); + addPhase(PhaseData.builder() + .phase("won") + .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcAll this, for nothing...ยงr").build() + ); + addPhase(PhaseData.builder() + .phase("lost") + .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcFINALLY! This took way too long.ยงr").build() + ); + } + + + @Override + public List getHealths() { + List healths = new ArrayList(); + int maxHealth = 1_000_000_000; + healths.add(new HealthData("Necron", (int) (BossStatus.healthScale * maxHealth),maxHealth , this.getCurrentPhase().startsWith("fight-"))); + return healths; + } + + @Override + public String getBossName() { + return "Necron"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorProf.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorProf.java new file mode 100644 index 00000000..169b9773 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorProf.java @@ -0,0 +1,144 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraftforge.event.entity.living.LivingEvent; + +import java.util.ArrayList; +import java.util.List; + +public class BossfightProcessorProf extends GeneralBossfightProcessor { + public BossfightProcessorProf() { + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("start") + .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: I was burdened with terrible news recently...ยงr") + .nextPhase("fight-1").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("fight-1") + .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: I'll show you real power!ยงr") + .nextPhase("first-defeat").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("first-defeat") + .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: Oh? You found my Guardians one weakness?ยงr") + .nextPhase("fight-2").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("fight-2") + .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: This time I'll be your opponent!ยงr") + .nextPhase("second-defeat").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("second-defeat") + .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: I see. You have forced me to use my ultimate technique.ยงr") + .nextPhase("fight-3").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("fight-3") + .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: The process is irreversible, but I'll be stronger than a Wither now!ยงr") + .nextPhase("final-defeat").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("final-defeat") + .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: What?! My Guardian power is unbeatable!ยงr").build() + ); + } + + @Override + public List getHealths() { + List healths = new ArrayList(); + { + long health = 0; + if (profStand != null) { + String name = TextUtils.stripColor(profStand.getName()); + String healthPart = name.split(" ")[3]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("The Professor", (int) health, 3000000, this.getCurrentPhase().startsWith("fight-") && !this.getCurrentPhase().equals("fight-1"))); + } + if (!getCurrentPhase().equals("second-defeat") && !getCurrentPhase().equals("fight-3") && !getCurrentPhase().equals("final-defeat")) { + { + long health = 0; + if (healthyGuard != null) { + String name = TextUtils.stripColor(healthyGuard.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Healthy Guardian", (int) health, 1000000, this.getCurrentPhase().equals("fight-1"))); + } + { + long health = 0; + if (chaosGuard != null) { + String name = TextUtils.stripColor(chaosGuard.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Chaos Guardian", (int) health, 1000000, this.getCurrentPhase().equals("fight-1"))); + } + { + long health = 0; + if (laserGuard != null) { + String name = TextUtils.stripColor(laserGuard.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Laser Guardian", (int) health, 1000000, this.getCurrentPhase().equals("fight-1"))); + } + { + long health = 0; + if (reinforcedGuard != null) { + String name = TextUtils.stripColor(reinforcedGuard.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Reinforced Guardian", (int) health, 1000000, this.getCurrentPhase().equals("fight-1"))); + } + } + return healths; + } + + @Override + public String getBossName() { + return "The Professor"; + } + + private EntityArmorStand profStand; + private EntityArmorStand laserGuard; + private EntityArmorStand chaosGuard; + private EntityArmorStand reinforcedGuard; + private EntityArmorStand healthyGuard; + @Override + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + if (updateEvent.entityLiving instanceof EntityArmorStand) { + if (updateEvent.entityLiving.getName().startsWith("ยงe๏ดพ ยงcยงlThe Professorยงr ")) + profStand = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยงcHealthy Guardian ")) + healthyGuard = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยงcChaos Guardian ")) + chaosGuard = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยงcLaser Guardian ")) + laserGuard = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยงcReinforced Guardian ")) + reinforcedGuard = (EntityArmorStand) updateEvent.entityLiving; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorSadan.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorSadan.java new file mode 100644 index 00000000..0de8aa56 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorSadan.java @@ -0,0 +1,144 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraftforge.event.entity.living.LivingEvent; + +import java.util.ArrayList; +import java.util.List; + +public class BossfightProcessorSadan extends GeneralBossfightProcessor { + public BossfightProcessorSadan() { + addPhase(PhaseData.builder() + .phase("start") + .signatureMsg("So you made it all the way ยงrยงfhere...andยงrยงf you wish to defy me? Sadan?!ยงr") + .nextPhase("fight-1").build() + ); + addPhase(PhaseData.builder() + .phase("fight-1") + .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: I am the bridge between this realm and the world below! You shall not pass!ยงr") + .nextPhase("first-defeat").build() + ); + addPhase(PhaseData.builder() + .phase("first-defeat") + .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: ENOUGH!ยงr") + .nextPhase("fight-2").build() + ); + addPhase(PhaseData.builder() + .phase("fight-2") + .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: My giants! Unleashed!ยงr") + .nextPhase("second-defeat").build() + ); + addPhase(PhaseData.builder() + .phase("second-defeat") + .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: You did it. I understand now, you have earned my respect.ยงr") + .nextPhase("fight-3").build() + ); + addPhase(PhaseData.builder() + .phase("fight-3") + .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: I'm sorry but I need to concentrate. I wish it didn't have to come to this.ยงr") + .nextPhase("final-defeat").build() + ); + addPhase(PhaseData.builder() + .phase("final-defeat") + .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: NOOOOOOOOO!!! THIS IS IMPOSSIBLE!!ยงr").build() + ); + } + + @Override + public List getHealths() { + List healths = new ArrayList(); + { + long health = 0; + if (sadanStand != null) { + String name = TextUtils.stripColor(sadanStand.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Sadan", (int) health, 40000000, this.getCurrentPhase().equals("fight-3"))); + } + if (getCurrentPhase().equals("fight-2")) { + { + long health = 0; + if (diamondGiant != null) { + String name = TextUtils.stripColor(diamondGiant.getName()); + String healthPart = name.split(" ")[3]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("The Diamond Giant", (int) health, 25000000, this.getCurrentPhase().startsWith("fight-"))); + } + { + long health = 0; + if (bigfootGiant != null) { + String name = TextUtils.stripColor(bigfootGiant.getName()); + String healthPart = name.split(" ")[1]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Bigfoot", (int) health, 25000000, this.getCurrentPhase().startsWith("fight-"))); + } + { + long health = 0; + if (laserGiant != null) { + String name = TextUtils.stripColor(laserGiant.getName()); + String healthPart = name.split(" ")[1]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("L.A.S.R.", (int) health, 25000000, this.getCurrentPhase().startsWith("fight-"))); + } + { + long health = 0; + if (boulderGiant != null) { + String name = TextUtils.stripColor(boulderGiant.getName()); + String healthPart = name.split(" ")[3]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Jolly Pink Giant", (int) health, 25000000, this.getCurrentPhase().startsWith("fight-"))); + } + } + return healths; + } + + @Override + public String getBossName() { + return "Sadan"; + } + + private EntityArmorStand sadanStand; + private EntityArmorStand diamondGiant; + private EntityArmorStand laserGiant; + private EntityArmorStand bigfootGiant; + private EntityArmorStand boulderGiant; + @Override + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + if (updateEvent.entityLiving instanceof EntityArmorStand) { + if (updateEvent.entityLiving.getName().startsWith("ยงe๏ดพ ยงcยงlSadanยงr ")) + sadanStand = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยงcยงdยงlJolly Pink Giant ")) + boulderGiant = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยงcยง4ยงlL.A.S.R. ")) + laserGiant = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยงcยง3ยงlThe Diamond Giant ")) + diamondGiant = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยงcยงcยงlBigfoot ")) + bigfootGiant = (EntityArmorStand) updateEvent.entityLiving; + } + } +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorScarf.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorScarf.java new file mode 100644 index 00000000..44fdea1b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorScarf.java @@ -0,0 +1,134 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraftforge.event.entity.living.LivingEvent; + +import java.util.ArrayList; +import java.util.List; + +public class BossfightProcessorScarf extends GeneralBossfightProcessor { + public BossfightProcessorScarf() { + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("start") + .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: This is where the journey ends for you, Adventurers.ยงr") + .nextPhase("fight-1").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("fight-1") + .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: ARISE, MY CREATIONS!ยงr") + .nextPhase("first-defeat").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("first-defeat") + .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: Those toys are not strong enough I see.ยงr") + .nextPhase("fight-2").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("fight-2") + .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: Did you forget? I was taught by the best! Let's dance.ยงr") + .nextPhase("final-defeat").build() + ); + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("final-defeat") + .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: Whatever...ยงr").build() + ); + } + + @Override + public List getHealths() { + List healths = new ArrayList(); + { + long health = 0; + if (scarfStand != null) { + String name = TextUtils.stripColor(scarfStand.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Scarf", (int) health, 1000000, this.getCurrentPhase().equals("fight-2"))); + } + if (!getCurrentPhase().equals("start") && !getCurrentPhase().equals("final-defeat")) { + { + long health = 0; + if (priestStand != null) { + String name = TextUtils.stripColor(priestStand.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Undead Priest", (int) health, 600000, this.getCurrentPhase().startsWith("fight-"))); + } + { + long health = 0; + if (berserkStand != null) { + String name = TextUtils.stripColor(berserkStand.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Undead Warrior", (int) health, 500000, this.getCurrentPhase().startsWith("fight-"))); + } + { + long health = 0; + if (mageStand != null) { + String name = TextUtils.stripColor(mageStand.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Undead Mage", (int) health, 400000, this.getCurrentPhase().startsWith("fight-"))); + } + { + long health = 0; + if (archerStand != null) { + String name = TextUtils.stripColor(archerStand.getName()); + String healthPart = name.split(" ")[2]; + health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); + } + healths.add(new HealthData("Undead Archer", (int) health, 400000, this.getCurrentPhase().startsWith("fight-"))); + } + } + return healths; + } + + @Override + public String getBossName() { + return "Scarf"; + } + + private EntityArmorStand scarfStand; + private EntityArmorStand priestStand; + private EntityArmorStand mageStand; + private EntityArmorStand berserkStand; + private EntityArmorStand archerStand; + @Override + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + if (updateEvent.entityLiving instanceof EntityArmorStand) { + if (updateEvent.entityLiving.getName().startsWith("ยงe๏ดพ ยงcยงlScarfยงr ")) + scarfStand = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยง6ยง4ยงlUndead Archer ")) + archerStand = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยง6ยง4ยงlUndead Mage ")) + mageStand = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยง6ยง4ยงlUndead Priest ")) + priestStand = (EntityArmorStand) updateEvent.entityLiving; + else if (updateEvent.entityLiving.getName().startsWith("ยง6ยง4ยงlUndead Warrior ")) + berserkStand = (EntityArmorStand) updateEvent.entityLiving; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorThorn.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorThorn.java new file mode 100644 index 00000000..eb5a71d6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/BossfightProcessorThorn.java @@ -0,0 +1,103 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.boss.BossStatus; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class BossfightProcessorThorn extends GeneralBossfightProcessor { + + + public BossfightProcessorThorn() { + addPhase(GeneralBossfightProcessor.PhaseData.builder() + .phase("fight").build() + ); + w= DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getWorld(); + } + private final Set progressBar = new HashSet(); + private final World w; + + private int ticksPassed = 0; + + @Override + public void tick() { + ticksPassed ++; + if (ticksPassed == 20) { + progressBar.clear(); + for (int x = -30; x <= 30; x++) { + for (int y = -30; y <= 30; y++) { + BlockPos newPos = new BlockPos(5 + x, 77, 5 + y); + Block b = w.getBlockState(newPos).getBlock(); + if ((b == Blocks.coal_block || b == Blocks.sea_lantern) && w.getBlockState(newPos.add(0, 1, 0)).getBlock() != Blocks.carpet) + progressBar.add(newPos); + } + } + } + } + + @Override + public List getHealths() { + List healths = new ArrayList(); + healths.add(new HealthData("Thorn", Math.round(BossStatus.healthScale * 4),4, true)); + return healths; + } + + @Override + public String getBossName() { + return "Thorn"; + } + + public double calculatePercentage() { + int total = progressBar.size(), lit = 0; + if (total == 0) return 0; + for (BlockPos pos : progressBar) { + if (w.getBlockState(pos).getBlock() == Blocks.sea_lantern ) lit++; + } + + return lit / (double)total; + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.DEBUG.isEnabled()) return; + try { + BlockPos pos = new BlockPos(205,77, 205); + RenderUtils.highlightBlock(pos, new Color(0, 255, 255, 50), partialTicks, false); + for (BlockPos pos2 : progressBar) { + RenderUtils.highlightBlock(pos2, w.getBlockState(pos2).getBlock() == Blocks.sea_lantern ? + new Color(0, 255, 0, 50) : new Color(255,0,0, 50), partialTicks, false); + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/GeneralBossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/GeneralBossfightProcessor.java new file mode 100644 index 00000000..50fd9868 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/GeneralBossfightProcessor.java @@ -0,0 +1,155 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.mod.events.impl.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import lombok.*; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.util.*; + +public abstract class GeneralBossfightProcessor implements BossfightProcessor { + private final Map phases = new HashMap(); + private PhaseData currentPhase = null; + + @Getter + @Setter + private String name; + + private World world; + + public void addPhase(PhaseData phaseData) { + if (phaseData == null) return; + if (currentPhase == null) currentPhase = phaseData; + phases.put(phaseData.getPhase(), phaseData); + } + + @Override + public List getPhases() { + List phases = new ArrayList(); + for (PhaseData pd:this.phases.values()) + phases.add(pd.getPhase()); + return phases; + } + + @Override + public List getNextPhases() { + if (currentPhase == null) return Collections.emptyList(); + List phases = new ArrayList(this.currentPhase.getNextPhases()); + return phases; + } + + + @Override + public String getCurrentPhase() { + return currentPhase == null ? "unknown" : currentPhase.getPhase(); + } + + @Override + public void chatReceived(IChatComponent chat) { + if (currentPhase == null) return; + + for (String nextPhase : currentPhase.getNextPhases()) { + PhaseData phaseData = phases.get(nextPhase); + if (phaseData == null) continue; + if (phaseData.signatureMsgs.contains(chat.getFormattedText().replace(" ", ""))) { + currentPhase = phaseData; + onPhaseChange(); + return; + } + } + } + + @Override + public void actionbarReceived(IChatComponent chat) {} + + @Override + public void tick() {} + + @Override + public void drawScreen(float partialTicks) {} + + @Override + public void drawWorld(float partialTicks) {} + + @Override + public boolean readGlobalChat() {return true;} + + @Override + public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { + + } + + @Override + public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { + + } + + @Override + public void onInteract(PlayerInteractEntityEvent event) { + + } + + @Override + public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { + + } + + @Override + public void onInteractBlock(PlayerInteractEvent event) { + + } + @Override + public void onEntityDeath(LivingDeathEvent deathEvent) { + + } + @Override + public void onBlockUpdate(BlockUpdateEvent blockUpdateEvent) { + + } + + public void onPhaseChange() {} + + @Data + @Builder + public static class PhaseData { + private PhaseData(String phase, Set signatureMsgs, Set nextPhase) { + this.phase = phase; + this.nextPhases = new HashSet<>(nextPhase); + this.signatureMsgs = new HashSet<>(); + for (String signatureMsg : signatureMsgs) { + this.signatureMsgs.add(signatureMsg.replace(" ", "")); + } + } + + private String phase; + @Singular + private Set signatureMsgs; + @Singular + private Set nextPhases; + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/HealthData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/HealthData.java new file mode 100644 index 00000000..ace9b39b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/bossfight/HealthData.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class HealthData { + private String name; + private int health; + private int maxHealth; + private boolean attackable; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/boxpuzzle/BoxPuzzleSolvingThread.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/boxpuzzle/BoxPuzzleSolvingThread.java new file mode 100755 index 00000000..feeb7228 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/boxpuzzle/BoxPuzzleSolvingThread.java @@ -0,0 +1,182 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.boxpuzzle; + +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; +import java.util.*; +import java.util.List; + +@Getter +@Setter +public class BoxPuzzleSolvingThread extends Thread { + private byte[][] data; + private int playerX; + private int playerY; + private Runnable callback; + + + public BoxPuzzleSolvingThread(byte[][] data, int playerX, int playerY, Runnable onDone) { + this.data = data; + this.playerX = playerX; + this.playerY = playerY; + this.callback = onDone; + } + + Route solution = null; + + private boolean solved = false; + + @Override + public void run() { + solved = false; + solution = solve(data,playerX,playerY, 20); + solved = true; + callback.run(); + } + + + public static String stateString(byte[][] array) { + StringBuilder sb = new StringBuilder(); + for (int y = 0; y < array.length; y++) + for(int x = 0; x < array[y].length; x++) + sb.append(array[y][x]); + + return sb.toString(); + } + + + private static final List directions = Arrays.asList(new Point(-1,0), new Point(1,0), new Point(0,1), new Point(0,-1)); + private static Route solve(byte[][] boardStart, int playerX, int playerY, int maxRecursion) { // result:: playerY == 0 + Queue routes = new LinkedList(); + Set globalStatesBeen = new HashSet(); + + Route r = new Route(); + r.currentState = boardStart; + routes.add(r); + + while (!routes.isEmpty()) { + Route route = routes.poll(); + + if (routes.size() > 3000000) return null; + + String stateId = stateString(route.currentState); + if (maxRecursion < route.boxMoves.size()) continue; + if (globalStatesBeen.contains(stateId)) continue; + + Queue points = new LinkedList(); + Set reached= new HashSet(); + List possibleBoxMoves = new ArrayList(); + points.add(new Point(playerX, playerY)); + + while (!points.isEmpty()) { + Point pt = points.poll(); + if (pt.y == 0) { + return route; + } + if (reached.contains(pt)) continue; + reached.add(pt); + for (Point dir:directions) { + int resX= pt.x + dir.x; + int resY = pt.y + dir.y; + if (resX < 0 || resY < 0 || resX >= route.currentState[0].length || resY >= route.currentState.length) { + continue; + } + if (route.currentState[resY][resX] > 0) { + possibleBoxMoves.add(new BoxMove(resX, resY, dir.x, dir.y)); + continue; + } + points.add(new Point(resX, resY)); + } + } + + globalStatesBeen.add(stateId); + for (BoxMove possibleBoxMove : possibleBoxMoves) { + byte[][] copied = new byte[route.currentState.length][]; + for (int y = 0; y < copied.length; y++) + copied[y] = route.currentState[y].clone(); + + if (push(copied, possibleBoxMove.x, possibleBoxMove.y, possibleBoxMove.dx, possibleBoxMove.dy)){ + String stateId2 = stateString(copied); + if (globalStatesBeen.contains(stateId2)) continue; + + Route route2 = new Route(); + route2.boxMoves = new ArrayList(route.boxMoves); + route2.boxMoves.add(possibleBoxMove); + route2.currentState = copied; + + routes.add(route2); + } + } + } + + + return null; + } + + + public static boolean push(byte[][] board, int x,int y,int dx,int dy) { + if (board[y][x] != 1) return false; + int resultingX= x + dx; + int resultingY = y +dy; + if (resultingX < 0 || resultingY < 0 || resultingX >= board[0].length || resultingY >= board.length) return false; + if (board[resultingY][resultingX] == 1 || resultingY == 6) return false; + + board[resultingY][resultingX] = 1; + board[y][x] = 0; + return true; + } + + public static class BoxMove { + int x; + int y; + int dx; + int dy; + + public BoxMove(int x, int y, int dx, int dy) { + this.x = x; + this.y = y; + this.dx = dx; + this.dy = dy; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public int getDx() { + return dx; + } + + public int getDy() { + return dy; + } + } + + public static class Route { + List boxMoves = new LinkedList(); + byte[][] currentState; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java new file mode 100755 index 00000000..f4c80a57 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java @@ -0,0 +1,392 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.boxpuzzle; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessorGenerator; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Blocks; +import net.minecraft.util.*; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class RoomProcessorBoxSolver extends GeneralRoomProcessor { + + + private BlockPos[][] poses = new BlockPos[7][7]; + private boolean bugged= true; + + private BoxPuzzleSolvingThread puzzleSolvingThread; + + public RoomProcessorBoxSolver(DungeonRoom dungeonRoom) { + super(dungeonRoom); + + OffsetPointSet ops = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("board"); + try { + if (ops != null) { + for (int y = 0; y < 7; y++) { + for (int x = 0; x < 7; x++) { + poses[y][x] = ops.getOffsetPointList().get(y * 7 + x).getBlockPos(dungeonRoom); + } + } + bugged = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private byte[][] buildCurrentState() { + World w = getDungeonRoom().getContext().getWorld(); + byte[][] board = new byte[poses.length][poses[0].length]; + for (int y = 0; y < poses.length; y++) { + for (int x = 0; x < poses[0].length; x++) { + if (y == 6) { + board[y][x] = -1; + continue; + } + BlockPos pos = poses[y][x]; + Block b = w.getChunkFromBlockCoords(pos).getBlock(pos); + if (b == Blocks.air) + board[y][x] = 0; + else + board[y][x] = 1; + } + } + return board; + } + + private boolean calcReq = true; + + private boolean calcDone= false; + private boolean calcDone2 = false; + private int step = 0; + private byte[][] lastState; + + @Override + public void tick() { + super.tick(); + if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; + if (bugged) return; + byte[][] currboard = buildCurrentState(); + if (puzzleSolvingThread == null) { + calcDone = false; + puzzleSolvingThread = new BoxPuzzleSolvingThread(currboard, 0, 6, new Runnable() { + @Override + public void run() { + calcDone = true; + calcDone2 = true; + } + }); + puzzleSolvingThread.start(); + } + if (calcReq) { + OffsetPointSet ops = (OffsetPointSet) getDungeonRoom().getDungeonRoomInfo().getProperties().get("board"); + if (ops != null) { + poses = new BlockPos[7][7]; + for (int y = 0; y < 7; y++) { + for (int x = 0; x < 7; x++) { + poses[y][x] = ops.getOffsetPointList().get(y * 7 + x).getBlockPos(getDungeonRoom()); + } + } + bugged = false; + } + + calcDone = false; + if (puzzleSolvingThread != null) + puzzleSolvingThread.stop(); + puzzleSolvingThread = new BoxPuzzleSolvingThread(currboard, 0, 6, new Runnable() { + @Override + public void run() { + calcDone = true; + calcDone2 = true; + } + }); + puzzleSolvingThread.start(); + calcReq = false; + } + + boolean pathFindReq = false; + if (calcDone2) { + BoxPuzzleSolvingThread.Route semi_solution = puzzleSolvingThread.solution; + if (semi_solution == null) { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeBox Solver ยง7:: ยงcCouldn't find solution involving less than 20 box moves within 3m concurrent possibility")); + step = 0; + calcDone2 = false; + pathFindReq = true; + totalPath = new LinkedList(); + totalPushedBlocks = new LinkedList(); + solution = new LinkedList(); + return; + } else{ + solution = semi_solution.boxMoves; + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeBox Solver ยง7:: Solution Found!")); + } + step = 0; + lastState = currboard; + calcDone2 = false; + pathFindReq = true; + + calcTotalPath(); + } + + if (lastState == null) return; + boolean moved = false; + label: + for (int y = 0 ; y < currboard.length; y++) { + for (int x = 0; x < currboard[y].length; x++) { + if (lastState[y][x] != currboard[y][x]) { + moved = true; + lastState = currboard; + break label; + } + } + } + + if (moved) { + step++; + } + + Point player = getPlayerPos(currboard); + boolean currYState = Minecraft.getMinecraft().thePlayer.getPosition().getY() < 68; + if (((currYState && !player.equals(lastPlayer)) || (currYState != yState) || (moved) || pathFindReq) && solution != null) { + Point target = null; + if (step < solution.size()) { + BoxPuzzleSolvingThread.BoxMove boxMove = solution.get(step); + target = new Point(boxMove.x - boxMove.dx, boxMove.y - boxMove.dy); + } + List semi_pathFound = pathfind(currboard, player, target); + pathFound = new LinkedList(); + for (Point point : semi_pathFound) { + pathFound.add(poses[point.y][point.x].add(0,-1,0)); + } + + lastPlayer = player; + yState = currYState; + } + + } + + public void calcTotalPath() { + Point player = new Point(0,6); + totalPath = new LinkedList(); + totalPushedBlocks = new LinkedList(); + byte[][] currboard = buildCurrentState(); + for (int i = 0; i <= solution.size(); i++) { + Point target = null; + BoxPuzzleSolvingThread.BoxMove boxMove = null; + if (i < solution.size()) { + boxMove = solution.get(i); + target = new Point(boxMove.x - boxMove.dx, boxMove.y - boxMove.dy); + } + List semi_pathFound = pathfind(currboard, player, target); + for (int i1 = semi_pathFound.size() - 1; i1 >= 0; i1--) { + Point point = semi_pathFound.get(i1); + totalPath.add(poses[point.y][point.x].add(0, -1, 0)); + } + + player = target; + if (boxMove != null) { + BoxPuzzleSolvingThread.push(currboard, boxMove.x, boxMove.y, boxMove.dx, boxMove.dy); + int fromX = boxMove.x - boxMove.dx; + int fromY = boxMove.y - boxMove.dy; + + BlockPos pos = poses[fromY][fromX]; + BlockPos pos2 = poses[boxMove.y][boxMove.x]; + BlockPos dir = pos.subtract(pos2); + dir = new BlockPos(MathHelper.clamp_int(dir.getX(), -1,1), 0, MathHelper.clamp_double(dir.getZ(), -1, 1)); + + BlockPos highlight = pos2.add(dir); + totalPushedBlocks.add(highlight); + } + } + } + + private boolean yState = true; + public Point getPlayerPos(byte[][] map) { + BlockPos playerPos = Minecraft.getMinecraft().thePlayer.getPosition(); + int minDir = Integer.MAX_VALUE; + Point pt = null; + for (int y = 0; y < poses.length; y++) { + for (int x = 0; x < poses[0].length; x++) { + if (map[y][x] == 1) continue; + int dir = (int) poses[y][x].distanceSq(playerPos); + if (dir < minDir) { + minDir = dir; + pt = new Point(x,y); + } + } + } + return pt; + } + + private List solution; + private List pathFound; + private List totalPath; + private List totalPushedBlocks; + private Point lastPlayer; + + private static final java.util.List directions = Arrays.asList(new Point(-1,0), new Point(1,0), new Point(0,1), new Point(0,-1)); + public List pathfind(byte[][] map, Point start, Point target2) { + int[][] distances = new int[map.length][map[0].length]; + + Queue evalulate = new LinkedList(); + evalulate.add(start); + Point target = null; + while (!evalulate.isEmpty()) { + Point p = evalulate.poll(); + if (p.equals(target2) || (target2 == null &&p.y == 0)) { + target = p; + break; + } + int max = 0; + for (Point dir:directions) { + int resX= p.x + dir.x; + int resY = p.y + dir.y; + if (resX < 0 || resY < 0 || resX >= distances[0].length || resY >= distances.length) { + continue; + } + + if (max < distances[resY][resX]) { + max = distances[resY][resX]; + } + if (distances[resY][resX] == 0 && (map[resY][resX] == 0 ||map[resY][resX] == -1)) { + evalulate.add(new Point(resX, resY)); + } + } + distances[p.y][p.x] = max + 1; + } + if (target == null) return Collections.emptyList(); + + List route = new LinkedList(); + while(!target.equals(start)) { + route.add(target); + int min = Integer.MAX_VALUE; + Point minPoint = null; + for (Point dir:directions) { + int resX= target.x + dir.x; + int resY = target.y + dir.y; + if (resX < 0 || resY < 0 || resX >= distances[0].length || resY >= distances.length) { + continue; + } + + if (min > distances[resY][resX] && distances[resY][resX] != 0) { + min = distances[resY][resX]; + minPoint = new Point(resX, resY); + } + } + target = minPoint; + } + route.add(start); + return route; + } + + @Override + public void chatReceived(IChatComponent chat) { + if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; + if (chat.getFormattedText().toLowerCase().contains("recalc")) { + if (calcDone) { + calcReq = true; + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide :::: Recalculating Route...")); + } else { + calcReq = true; + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide :::: Currently Calculating Route...")); + } + } + } + + @Override + public void drawScreen(float partialTicks) { + super.drawScreen(partialTicks); + if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; + if (FeatureRegistry.SOLVER_BOX.disableText()) return; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Type \"recalc\" in chat to recalculate the solution", 0, 0, 0xFFFFFFFF); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; + if (bugged) return; + if (!calcDone) return; + if (solution == null) return; + if (Minecraft.getMinecraft().thePlayer.getPosition().getY() < 68) { + if (step < solution.size()) { + BoxPuzzleSolvingThread.BoxMove boxMove = solution.get(step); + int fromX = boxMove.x - boxMove.dx; + int fromY = boxMove.y - boxMove.dy; + + BlockPos pos = poses[fromY][fromX]; + BlockPos pos2 = poses[boxMove.y][boxMove.x]; + BlockPos dir = pos.subtract(pos2); + dir = new BlockPos(MathHelper.clamp_int(dir.getX(), -1, 1), 0, MathHelper.clamp_double(dir.getZ(), -1, 1)); + + BlockPos highlight = pos2.add(dir); + AColor color = FeatureRegistry.SOLVER_BOX.getTargetColor().multiplyAlpha(MathHelper.clamp_double(Minecraft.getMinecraft().thePlayer.getPosition().distanceSq(highlight), 100, 255) / 255); + RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(highlight.getX(), highlight.getY(), highlight.getZ(), highlight.getX()+1, highlight.getY() + 1, highlight.getZ() + 1), color, partialTicks, false); + } + + if (pathFound != null) { + RenderUtils.drawLines(pathFound, FeatureRegistry.SOLVER_BOX.getLineColor(),FeatureRegistry.SOLVER_BOX.getLineWidth(), partialTicks, true); + } + } else { + if (totalPath != null) { + RenderUtils.drawLines(totalPath, FeatureRegistry.SOLVER_BOX.getLineColor(),FeatureRegistry.SOLVER_BOX.getLineWidth(), partialTicks, false); + } + if (totalPushedBlocks != null) { + for (int i = 0; i < totalPushedBlocks.size(); i++) { + BlockPos pos = totalPushedBlocks.get(i); + RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1, pos.getY() + 1, pos.getZ() + 1), FeatureRegistry.SOLVER_BOX.getTargetColor(), partialTicks, false); + RenderUtils.drawTextAtWorld("#"+i, pos.getX()+0.5f, pos.getY() +0.5f, pos.getZ() + 0.5f, i != step ? + RenderUtils.getColorAt(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SOLVER_BOX.getTextColor2()) : RenderUtils.getColorAt(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SOLVER_BOX.getTextColor()), 0.1f, false, false, partialTicks); + } + } + } + + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorBoxSolver createNew(DungeonRoom dungeonRoom) { + RoomProcessorBoxSolver defaultRoomProcessor = new RoomProcessorBoxSolver(dungeonRoom); + return defaultRoomProcessor; + } + } + + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/icefill/RoomProcessorIcePath2.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/icefill/RoomProcessorIcePath2.java new file mode 100755 index 00000000..94732dc9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/icefill/RoomProcessorIcePath2.java @@ -0,0 +1,151 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.icefill; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessorGenerator; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +public class RoomProcessorIcePath2 extends GeneralRoomProcessor { + private final List> solution = new CopyOnWriteArrayList>(); + + + public RoomProcessorIcePath2(DungeonRoom dungeonRoom) { + + super(dungeonRoom); + + String levels = (String) dungeonRoom.getDungeonRoomInfo().getProperties().get("levels"); + if (levels == null) { + return; + } + + for (final String s : levels.split(",")) { + try { + OffsetPointSet level = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get(s + "-board"); + String data = (String) dungeonRoom.getDungeonRoomInfo().getProperties().get(s + "-level"); + final int width = Integer.parseInt(data.split(":")[0]); + final int height = Integer.parseInt(data.split(":")[1]); + final int startX = Integer.parseInt(data.split(":")[2]); + final int startY = Integer.parseInt(data.split(":")[3]); + final int endX = Integer.parseInt(data.split(":")[4]); + final int endY = Integer.parseInt(data.split(":")[5]); + + final int[][] map = new int[height][width]; + final BlockPos[][] map2 = new BlockPos[height][width]; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + map2[y][x] = level.getOffsetPointList().get(y * width + x).getBlockPos(dungeonRoom); + map[y][x] = level.getOffsetPointList().get(y * width + x).getBlock(dungeonRoom) == Blocks.air ? 0 : 1; + } + } + + new Thread() { + public void run() { + List hamiltonianPath = findFirstHamiltonianPath(map, startX, startY, endX, endY); + if (hamiltonianPath == null) { + ChatTransmitter.addToQueue("ยงeDungeons Guide ยง7:: ยงeIcePath ยง7:: ยงcCouldn't find solution for floor "+s); + return; + } + hamiltonianPath.add(0,new Point(startX, startY)); + List poses = new LinkedList(); + for (int i = 0; i < hamiltonianPath.size(); i++) { + Point p = hamiltonianPath.get(i); + poses.add(map2[p.y][p.x]); + } + solution.add(poses); + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @Override + public void tick() { + super.tick(); + if (!FeatureRegistry.SOLVER_ICEPATH.isEnabled()) return; + } + + @Override + public void drawWorld(float partialTicks) { + if (!FeatureRegistry.SOLVER_ICEPATH.isEnabled()) return; + for (List solution:this.solution) + RenderUtils.drawLines(solution, FeatureRegistry.SOLVER_ICEPATH.getLineColor(),FeatureRegistry.SOLVER_ICEPATH.getLineWidth(), partialTicks, true); + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorIcePath2 createNew(DungeonRoom dungeonRoom) { + RoomProcessorIcePath2 defaultRoomProcessor = new RoomProcessorIcePath2(dungeonRoom); + return defaultRoomProcessor; + } + } + + private static List findFirstHamiltonianPath(int[][] map, int startX, int startY, int endX, int endY) { + int emptySpace =0; + for (int y = 0; y < map.length; y++) + for (int x = 0; x < map[y].length; x++) + if (map[y][x] == 0) emptySpace++; + + map[startY][startX] = 2; + + return findHamiltonianPath(map, startX, startY, endX, endY, 0, emptySpace-1); + } + + + private static final List directions = Arrays.asList(new Point(0,-1), new Point(-1,0), new Point(1,0), new Point(0,1)); + private static LinkedList findHamiltonianPath(int[][] map, int startX, int startY, int endX, int endY, int depth, int reqDepth) { + if (endX == startX && endY == startY) { + if (depth != reqDepth) return null; + LinkedList path = new LinkedList(); + path.add(new Point(startX, startY)); + return path; + } + + for (Point p : directions) { + int y = p.y +startY,x=p.x + startX; + if (y <0 || y >= map.length || x <0 || x >= map[0].length || map[y][x] != 0) continue; + + int[][] copiedMap = new int[map.length][map[0].length]; + for (int y2 = 0; y2 < copiedMap.length; y2++) + copiedMap[y2] = map[y2].clone(); + copiedMap[y][x] = 2; + + LinkedList potentialRoute = findHamiltonianPath(copiedMap, x,y,endX,endY, depth +1, reqDepth); + if (potentialRoute != null) { + potentialRoute.addFirst(new Point(x,y)); + return potentialRoute; + } + } + return null; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/LeverState.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/LeverState.java new file mode 100755 index 00000000..e86fdd5c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/LeverState.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class LeverState { + private String blockId; + private boolean requiredState; + + public LeverState invert() { + return new LeverState(blockId, !requiredState); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/LeverStateContradict.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/LeverStateContradict.java new file mode 100755 index 00000000..a574d6bf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/LeverStateContradict.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle; + +public class LeverStateContradict extends LeverState { + public LeverStateContradict() { + super("contradict", true); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java new file mode 100755 index 00000000..d4b05bc9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java @@ -0,0 +1,124 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessorGenerator; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.List; + +public class RoomProcessorWaterPuzzle extends GeneralRoomProcessor { + + private boolean argumentsFulfilled = false; + + private WaterBoard waterBoard; + private final OffsetPointSet doorsClosed; + private final OffsetPointSet levers; + private final OffsetPointSet frontBoard; + private final OffsetPointSet backBoard; + private final OffsetPoint water_lever; + + public RoomProcessorWaterPuzzle(DungeonRoom dungeonRoom) { + super(dungeonRoom); + frontBoard = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("front"); + backBoard = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("back"); + levers = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("levers"); + doorsClosed = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("doors"); + water_lever = (OffsetPoint) dungeonRoom.getDungeonRoomInfo().getProperties().get("water-lever"); + + if (frontBoard == null || backBoard == null || levers == null || doorsClosed == null ||water_lever == null) { + argumentsFulfilled = false; + } else { + argumentsFulfilled = true; + + try { + waterBoard = new WaterBoard(this, frontBoard, backBoard, levers, doorsClosed, water_lever); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @Override + public void tick() { + super.tick(); + if (!FeatureRegistry.SOLVER_WATERPUZZLE.isEnabled()) return; + if (!argumentsFulfilled) return; + try { + waterBoard.tick(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void drawScreen(float partialTicks) { + super.drawScreen(partialTicks); + } + + @Override + public void drawWorld(float partialTicks) { + super.drawWorld(partialTicks); + if (!FeatureRegistry.SOLVER_WATERPUZZLE.isEnabled()) return; + if (!argumentsFulfilled) return; + if (waterBoard == null) return; + + Route route = waterBoard.getCurrentRoute(); + if (route != null) { + int j = 1; + for (int i = 0; i < route.getConditionList().size(); i++) { + LeverState condition = route.getConditionList().get(i); + if (condition == null) continue; + SwitchData switchData = waterBoard.getValidSwitches().get(condition.getBlockId()); + if (switchData.getCurrentState(getDungeonRoom().getContext().getWorld()) != condition.isRequiredState()) { + + RenderUtils.highlightBlock(switchData.getSwitchLoc(), new Color(0,255,0,50), partialTicks, true); + RenderUtils.drawTextAtWorld("#"+j,switchData.getSwitchLoc().getX(), switchData.getSwitchLoc().getY()+1, switchData.getSwitchLoc().getZ(), 0xFF000000,0.1f, false, false, partialTicks); + RenderUtils.drawTextAtWorld(condition.isRequiredState() ? "on":"off",switchData.getSwitchLoc().getX(), switchData.getSwitchLoc().getY(), switchData.getSwitchLoc().getZ(), 0xFF000000,0.1f, false, false, partialTicks); + j++; + } + } + for (WaterNode node : route.getNodes()) { + RenderUtils.highlightBlock(node.getBlockPos(), new Color(0,255,255,50), partialTicks, true); + } + } + List targets = waterBoard.getTarget(); + if (targets != null) { + for (BlockPos target : targets) { + RenderUtils.highlightBlock(target, new Color(0,255,255,100), partialTicks, true); + } + RenderUtils.highlightBlock(waterBoard.getToggleableMap().get("mainStream").getBlockPos(), new Color(0,255,0,255), partialTicks, true); + } + } + + public static class Generator implements RoomProcessorGenerator { + @Override + public RoomProcessorWaterPuzzle createNew(DungeonRoom dungeonRoom) { + RoomProcessorWaterPuzzle defaultRoomProcessor = new RoomProcessorWaterPuzzle(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/Route.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/Route.java new file mode 100755 index 00000000..a122d83f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/Route.java @@ -0,0 +1,60 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes.WaterNodeEnd; +import lombok.Data; +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +@Data +public class Route implements Cloneable, Comparable { + private Set nodes = new LinkedHashSet(); + private List conditionList = new ArrayList(); + private Set endingNodes = new HashSet(); + + + private int matches = 0; + private int stateFlops = 0; + private int notMatches = 0; + + public double calculateCost() { + return (1.0/matches) * 50 + stateFlops * 20 + notMatches * 10000; + } + + @Override + protected Route clone() { + Route r = new Route(); + r.getNodes().addAll(nodes); + r.getConditionList().addAll(conditionList); + r.getEndingNodes().addAll(endingNodes); + return r; + } + + @Override + public int compareTo(@NotNull Object o) { + if (o instanceof Route) { + double var0 = calculateCost(); + double var1 = ((Route)o).calculateCost(); + return Double.compare(var0, var1); + } + return 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/SwitchData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/SwitchData.java new file mode 100755 index 00000000..1b43448f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/SwitchData.java @@ -0,0 +1,46 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes.WaterNodeStart; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes.WaterNodeToggleable; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +@Data +@AllArgsConstructor +public class SwitchData { + private WaterBoard waterBoard; + + private BlockPos switchLoc; + private BlockPos blockLoc; + + private String blockId; + + public boolean getCurrentState(World w) { + WaterNode waterNode = waterBoard.getToggleableMap().get(blockId); + if (waterNode instanceof WaterNodeStart) + return ((WaterNodeStart) waterNode).isTriggered(w); + else if (waterNode instanceof WaterNodeToggleable) + return ((WaterNodeToggleable) waterNode).isTriggered(w); + return false; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/WaterBoard.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/WaterBoard.java new file mode 100755 index 00000000..56b372e4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/WaterBoard.java @@ -0,0 +1,424 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes.*; +import lombok.Getter; +import net.minecraft.block.Block; +import net.minecraft.block.BlockLever; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Tuple; +import net.minecraft.world.World; + +import java.util.*; +import java.util.List; + +public class WaterBoard { + @Getter + WaterNode[][] board; + RoomProcessorWaterPuzzle waterPuzzle; + + private final OffsetPointSet frontPlate; + private final OffsetPointSet backPlate; + private final OffsetPointSet levers; + private final OffsetPointSet doors; + private final OffsetPoint lever; + + @Getter + private final List switchData = new ArrayList(); + @Getter + private final Map validSwitches = new HashMap(); + + private WaterNodeStart waterNodeStart; + private final Map waterNodeEndMap = new HashMap(); + + @Getter + private final Map toggleableMap = new HashMap(); + + @Getter + private Set reqOpen = new HashSet(); + @Getter + private Route currentRoute; + @Getter + private List target; + @Getter + private List target2; + + public WaterBoard(RoomProcessorWaterPuzzle roomProcessorWaterPuzzle, OffsetPointSet frontPlate, OffsetPointSet backPlate, OffsetPointSet levers, OffsetPointSet doors, OffsetPoint leverMain) { + this.waterPuzzle = roomProcessorWaterPuzzle; + this.frontPlate = frontPlate; + this.backPlate = backPlate; + this.levers = levers; + this.doors = doors; + this.lever = leverMain; + + buildLeverStates(); + buildNodes(); + } + + private void buildLeverStates(){ + for (OffsetPoint offsetPoint : levers.getOffsetPointList()) { + if (offsetPoint.getBlock(waterPuzzle.getDungeonRoom()) == Blocks.lever){ + BlockPos pos = offsetPoint.getBlockPos(waterPuzzle.getDungeonRoom()); + World w= waterPuzzle.getDungeonRoom().getContext().getWorld(); + BlockLever.EnumOrientation enumOrientation = w.getBlockState(pos).getValue(BlockLever.FACING); + EnumFacing enumFacing = enumOrientation.getFacing(); + BlockPos newPos = pos.add(-enumFacing.getDirectionVec().getX(),0,-enumFacing.getDirectionVec().getZ()); + + int id = Block.getIdFromBlock(w.getChunkFromBlockCoords(newPos).getBlock(newPos)); + int data = w.getChunkFromBlockCoords(newPos).getBlockMetadata(newPos); + + SwitchData sw; + switchData.add(sw = new SwitchData(this, pos,newPos,id+":"+data)); + validSwitches.put(id+":"+data, sw); + } + } + SwitchData sw; + switchData.add(sw = new SwitchData(this, lever.getBlockPos(waterPuzzle.getDungeonRoom()),lever.getBlockPos(waterPuzzle.getDungeonRoom()).add(0,-1,0),"mainStream")); + validSwitches.put("mainStream", sw); + } + + public void tick() { + Set doorsToOpen = new HashSet(); + for (OffsetPoint offsetPoint : doors.getOffsetPointList()) { + Block b =offsetPoint.getBlock(waterPuzzle.getDungeonRoom()); + if (b != Blocks.air) { + doorsToOpen.add(Block.getIdFromBlock(b)+":"+offsetPoint.getData(waterPuzzle.getDungeonRoom())); + } + } +// if (!(reqOpen.containsAll(doorsToOpen) && doorsToOpen.containsAll(reqOpen))) { + reqOpen = doorsToOpen; + if (doorsToOpen.size() != 0) { + Set ends = new HashSet(); + for (String s : doorsToOpen) { + ends.add(waterNodeEndMap.get(s)); + } + currentRoute = getBestRoute(ends); +// { +// +// Set currentState = new HashSet(); +// World w = waterPuzzle.getDungeonRoom().getContext().getWorld(); +// for (SwitchData switchDatum : this.switchData) { +// currentState.add(new LeverState(switchDatum.getBlockId(), switchDatum.getCurrentState(w))); +// } +// currentRoute = simulate(currentState); +// } + + target = new ArrayList(); + target2 = new ArrayList(); + if (currentRoute != null) { + for (WaterNodeEnd endingNode : currentRoute.getEndingNodes()) { + target.add(endingNode.getBlockPos()); + target2.add(endingNode.getResultId()); + } + } + } +// } + } + + public Route getBestRoute(Set potentialEnds) { + int totalStates = (int) Math.pow(2, validSwitches.size() - 1); + List switchData = new ArrayList(); + Set currentState = new HashSet(); + World w = waterPuzzle.getDungeonRoom().getContext().getWorld(); + for (SwitchData switchDatum : this.switchData) { + if (!switchDatum.getBlockId().equals("mainStream")) { + switchData.add(switchDatum); + } + currentState.add(new LeverState(switchDatum.getBlockId(), switchDatum.getCurrentState(w))); + } + PriorityQueue routes = new PriorityQueue(); + + for (int i = 0; i < totalStates; i++) { + Set states = new HashSet(); + for (int i1 = 0; i1 < switchData.size(); i1++) { + states.add(new LeverState(switchData.get(i1).getBlockId(), ((i >> i1) & 0x1) > 0)); + } + states.add(new LeverState("mainStream", true)); + + Route r = simulate(states); + + for (LeverState leverState : currentState) { + if (!states.contains(leverState)) + r.setStateFlops(r.getStateFlops() + 1); + } + for (WaterNodeEnd potentialEnd : r.getEndingNodes()) { + if (potentialEnds.contains(potentialEnd)) { + r.setMatches(r.getMatches() + 1); + } else { + r.setNotMatches(r.getNotMatches() + 1); + } + } + if (r.getMatches() > 0) + routes.add(r); + } + + + return routes.peek(); + } + + public Route simulate(Set leverStates) { + leverStates.add(null); + Route r = new Route(); + final Queue toGoDownTo = new LinkedList(); + Set searched = new HashSet(); + Set waterBlockingStates = new HashSet(); + World w = waterPuzzle.getDungeonRoom().getContext().getWorld(); +// toGoDownTo.add(getNodeAt(waterNodeStart.getX(), waterNodeStart.getY() + 1)); + { + Queue> toGo = new LinkedList<>(); + toGo.add(new Tuple<>(waterNodeStart, true)); + toGoDownTo.add(getNodeAt(waterNodeStart.getX(), waterNodeStart.getY() + 1)); + Set visited = new HashSet<>(); + while (!toGo.isEmpty()) { + Tuple waterNode = toGo.poll(); + if (waterNode.getFirst() == null) continue; + if (visited.contains(waterNode.getFirst())) continue; + if (!waterNode.getFirst().canWaterGoThrough()) continue; + if (waterNode.getFirst() instanceof WaterNodeEnd) continue; + visited.add(waterNode.getFirst()); + + boolean water = waterNode.getFirst().isWaterFilled(w); + if (water && !waterNode.getSecond()) { + toGoDownTo.add(getNodeAt(waterNode.getFirst().getX(), waterNode.getFirst().getY())); + } + + int x = waterNode.getFirst().getX(), y = waterNode.getFirst().getY(); + toGo.add(new Tuple<>(getNodeAt(x+1, y), water)); + toGo.add(new Tuple<>(getNodeAt(x-1, y), water)); + toGo.add(new Tuple<>(getNodeAt(x, y+1), water)); + } + } + while (!toGoDownTo.isEmpty()) { + WaterNode asd = toGoDownTo.poll(); + if (asd == null) continue; + if (searched.contains(asd)) continue; + searched.add(asd); + + if (asd instanceof WaterNodeEnd) { + if (!asd.isWaterFilled(w)) + r.getEndingNodes().add((WaterNodeEnd) asd); + continue; + } + + r.getNodes().add(asd); + + if (asd.isWaterFilled(w) && ( + (getNodeAt(asd.getX() + 1, asd.getY()) != null && getNodeAt(asd.getX() + 1, asd.getY()).isWaterFilled(w)) + || (getNodeAt(asd.getX() - 1, asd.getY()) != null && getNodeAt(asd.getX() - 1, asd.getY()).isWaterFilled(w)))) { + boolean followWater = getNodeAt(asd.getX() - 1, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() - 1, asd.getY()).getCondition()) + && getNodeAt(asd.getX() - 2, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() - 2, asd.getY()).getCondition()); + for (int i = asd.getX(); i < asd.getX() + 8; i++) { + WaterNode nodehere = getNodeAt(i, asd.getY()); + if (nodehere == null) break; + if (followWater && !nodehere.isWaterFilled(w)) break; + if (!nodehere.canWaterGoThrough()) break; + if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break; + if (nodehere.getCondition() != null && leverStates.contains(nodehere.getCondition().invert()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition().invert()); + WaterNode down = getNodeAt(i, asd.getY() + 1); + if (i != asd.getX()) + followWater = nodehere.isWaterFilled(w) && (down == null || (down.canWaterGoThrough() && leverStates.contains(down.getCondition()))); + r.getNodes().add(nodehere); + if (down != null && down.canWaterGoThrough() && down.getCondition() != null && leverStates.contains(down.getCondition().invert())) { + waterBlockingStates.add(down.getCondition().invert()); + } + if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) { + toGoDownTo.add(down); + if (!followWater) break; + } + } + followWater = getNodeAt(asd.getX() +1, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() + 1, asd.getY()).getCondition()) + && getNodeAt(asd.getX() +2, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() + 2, asd.getY()).getCondition()); + for (int i = asd.getX(); i > asd.getX() - 8; i--) { + WaterNode nodehere = getNodeAt(i, asd.getY()); + if (nodehere == null) break; + if (followWater && !nodehere.isWaterFilled(w)) break; + if (!nodehere.canWaterGoThrough()) break; + if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break; + if (nodehere.getCondition() != null && leverStates.contains(nodehere.getCondition().invert()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition().invert()); + WaterNode down = getNodeAt(i, asd.getY() + 1); + if (i != asd.getX()) + followWater = nodehere.isWaterFilled(w) && (down == null || (down.canWaterGoThrough() && leverStates.contains(down.getCondition()))); + r.getNodes().add(nodehere); + if (down != null && down.canWaterGoThrough() && down.getCondition() != null && leverStates.contains(down.getCondition().invert())) { + waterBlockingStates.add(down.getCondition().invert()); + } + if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) { + toGoDownTo.add(down); + if (!followWater) break; + } + } + } else { + int minDistToDropRight = 9999; + for (int i = asd.getX(); i < asd.getX() + 8; i++) { + WaterNode nodehere = getNodeAt(i, asd.getY()); + if (nodehere == null) break; + if (!nodehere.canWaterGoThrough()) break; + if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break; + WaterNode down = getNodeAt(i, asd.getY() + 1); + if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())))) { + int dist = i - asd.getX(); + if (dist < minDistToDropRight) + minDistToDropRight = dist; + break; + } + } + int minDistToDropLeft = 9999; + for (int i = asd.getX(); i > asd.getX() - 8; i--) { + WaterNode nodehere = getNodeAt(i, asd.getY()); + if (nodehere == null) break; + if (!nodehere.canWaterGoThrough()) break; + if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break; + WaterNode down = getNodeAt(i, asd.getY() + 1); + if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())))) { + int dist = asd.getX() - i; + if (dist < minDistToDropLeft) + minDistToDropLeft = dist; + break; + } + } + + int min = Math.min(minDistToDropRight, minDistToDropLeft); + if (min == 9999) continue; + if (minDistToDropRight == min) { + for (int i = asd.getX(); i <= asd.getX() + minDistToDropRight; i++) { + WaterNode nodehere = getNodeAt(i, asd.getY()); + if (nodehere.getCondition() != null && leverStates.contains(nodehere.getCondition().invert()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition().invert()); + r.getNodes().add(nodehere); + WaterNode down = getNodeAt(i, asd.getY() + 1); + if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) { + toGoDownTo.add(down); + } + if (down != null && down.canWaterGoThrough() && down.getCondition() != null && leverStates.contains(down.getCondition().invert())) { + waterBlockingStates.add(down.getCondition().invert()); + } + } + } + if (minDistToDropLeft == min) { + for (int i = asd.getX(); i >= asd.getX() - minDistToDropLeft; i--) { + WaterNode nodehere = getNodeAt(i, asd.getY()); + if (nodehere.getCondition() != null && leverStates.contains(nodehere.getCondition().invert()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition().invert()); + r.getNodes().add(nodehere); + WaterNode down = getNodeAt(i, asd.getY() + 1); + if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) { + toGoDownTo.add(down); + } + if (down != null && down.canWaterGoThrough() && down.getCondition() != null && leverStates.contains(down.getCondition().invert())) { + waterBlockingStates.add(down.getCondition().invert()); + } + } + } + } + } + ArrayList state = new ArrayList(waterBlockingStates); + state.remove(null); + Collections.sort(state, new Comparator() { + @Override + public int compare(LeverState leverState, LeverState t1) { + int var0 = toggleableMap.get(leverState.getBlockId()).getY(); + int var1 = toggleableMap.get(t1.getBlockId()).getY(); + return var0 < var1 ? -1 : (var0 == var1 ? 0 : 1); + } + }); + LinkedList states = new LinkedList(state); + for (LeverState ls : leverStates) { + if (!states.contains(ls)) { + states.add(ls); + } + } + states.remove(null); + + + r.setConditionList(states); + return r; + } + + + public WaterNode getNodeAt(int x, int y) { + if (x < 0 || y < 0) return null; + if (x >= board[0].length || y >= board.length) return null; + return board[y][x]; + } + + private void buildNodes() { + List frontPoints = frontPlate.getOffsetPointList(); + List backPoints = backPlate.getOffsetPointList(); + + board = new WaterNode[25][19]; + for (int x = 0; x < 19; x++) { + for (int y = 0; y < 25; y++) { + OffsetPoint front = frontPoints.get(x *25 +y); + OffsetPoint back = backPoints.get(x * 25 +y); + int frontId = Block.getIdFromBlock(front.getBlock(waterPuzzle.getDungeonRoom())); + int backId = Block.getIdFromBlock(back.getBlock(waterPuzzle.getDungeonRoom())); + int frontData = front.getData(waterPuzzle.getDungeonRoom()); + int backData = back.getData(waterPuzzle.getDungeonRoom()); + WaterNode node; + if (validSwitches.containsKey(backId +":"+backData)) { + String resId = backId + ":"+backData; + node = new WaterNodeToggleable(resId, isSwitchActive(validSwitches.get(resId)), front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); + + toggleableMap.put(resId, node); + } else if (validSwitches.containsKey(frontId +":"+frontData)) { + String resId = frontId +":"+frontData; + node = new WaterNodeToggleable(resId, !isSwitchActive(validSwitches.get(resId)), front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); + + toggleableMap.put(resId, node); + } else if (frontId == 0 || frontId == 8 || frontId == 9) { + if (y == 24) { + OffsetPoint pos; + if (x != 0) { + pos = frontPoints.get((x-1)*25+y); + } else { + pos = frontPoints.get((x+1) * 25 +y); + } + + int id = Block.getIdFromBlock(pos.getBlock(waterPuzzle.getDungeonRoom())); + int data= pos.getData(waterPuzzle.getDungeonRoom()); + node = new WaterNodeEnd(id+":"+data, front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); + waterNodeEndMap.put(id+":"+data, (WaterNodeEnd) node); + } else if (y == 2 && x == 9) { + waterNodeStart = (WaterNodeStart) (node = new WaterNodeStart(front.getBlockPos(waterPuzzle.getDungeonRoom()), + frontId != 0 ^ isSwitchActive(validSwitches.get("mainStream")),x,y)); + } else { + node = new WaterNodeAir(front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); + } + } else { + node = new WaterNodeWall(front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); + } + board[y][x] =node; + } + } + toggleableMap.put("mainStream", waterNodeStart); + } + + private boolean isSwitchActive(SwitchData switchData) { + BlockPos switch2 = switchData.getSwitchLoc(); + World w= waterPuzzle.getDungeonRoom().getContext().getWorld(); + boolean bool = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(switch2).getValue(BlockLever.POWERED); + return bool; + } + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/WaterNode.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/WaterNode.java new file mode 100755 index 00000000..cbcb1cb0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/WaterNode.java @@ -0,0 +1,36 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface WaterNode { + boolean canWaterGoThrough(); + + // condition for water go + LeverState getCondition(); + + boolean isWaterFilled(World w); + + BlockPos getBlockPos(); + + int getX(); + int getY(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java new file mode 100755 index 00000000..274a232b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java @@ -0,0 +1,59 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.LeverState; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.WaterNode; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +@Data +@AllArgsConstructor +public class WaterNodeAir implements WaterNode { + BlockPos blockPos; + @Override + public boolean canWaterGoThrough() { + return true; + } + + @Override + public LeverState getCondition() { + return null; + } + + @Override + public boolean isWaterFilled(World w) { + Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); + return b == Blocks.water || b == Blocks.flowing_water; + } + + public BlockPos getBlockPos() { + return blockPos; + } + + private int x,y; + + public String toString() { + return "A"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java new file mode 100755 index 00000000..3ca59934 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java @@ -0,0 +1,60 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.LeverState; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.WaterNode; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +@Data +@AllArgsConstructor +public class WaterNodeEnd implements WaterNode { + private String resultId; + BlockPos blockPos; + + @Override + public boolean canWaterGoThrough() { + return true; + } + + @Override + public LeverState getCondition() { + return null; + } + + @Override + public boolean isWaterFilled(World w) { + Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); + return b == Blocks.water || b == Blocks.flowing_water; + } + + public BlockPos getBlockPos() { + return blockPos; + } + private int x,y; + + public String toString() { + return "E"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java new file mode 100755 index 00000000..09ec7070 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java @@ -0,0 +1,66 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.LeverState; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.WaterNode; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +@Data +@AllArgsConstructor +public class WaterNodeStart implements WaterNode { + + private BlockPos blockPos; + private boolean isReversed; + + @Override + public boolean canWaterGoThrough() { + return true; + } + + @Override + public LeverState getCondition() { + return new LeverState("mainStream", !isReversed); + } + + @Override + public boolean isWaterFilled(World w) { + Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); + return b == Blocks.water || b == Blocks.flowing_water; + } + + public boolean isTriggered(World w) { + return isWaterFilled(w); + } + + + public BlockPos getBlockPos() { + return blockPos; + } + private int x,y; + + public String toString() { + return "S"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java new file mode 100755 index 00000000..039c1cf9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java @@ -0,0 +1,71 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.LeverState; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.WaterNode; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +@Data +@AllArgsConstructor +public class WaterNodeToggleable implements WaterNode { + private String blockId; + private boolean invert; + + BlockPos blockPos; + + @Override + public boolean canWaterGoThrough() { + return true; + } + + @Override + public LeverState getCondition() { + return new LeverState(blockId, invert); + } + + + @Override + public boolean isWaterFilled(World w) { + Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); + return b == Blocks.water || b == Blocks.flowing_water; + } + private int x,y; + + public boolean isTriggered(World w) { + Block b= w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); + + return !(b == Blocks.air || b == Blocks.water || b == Blocks.flowing_water) ^ invert; + } + + + public BlockPos getBlockPos() { + return blockPos; + } + + + public String toString() { + return "T:"+blockId+(invert ? ":Y":":N"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java new file mode 100755 index 00000000..b09750f2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java @@ -0,0 +1,62 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.nodes; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.LeverState; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.waterpuzzle.WaterNode; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +@Data +@AllArgsConstructor +public class WaterNodeWall implements WaterNode { + + BlockPos blockPos; + @Override + public boolean canWaterGoThrough() { + return false; + } + + @Override + public LeverState getCondition() { + return null; + } + + + @Override + public boolean isWaterFilled(World w) { + Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); + return b == Blocks.water || b == Blocks.flowing_water; + } + + private int x,y; + + public BlockPos getBlockPos() { + return blockPos; + } + + + public String toString() { + return "W"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/AuthChangedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/AuthChangedEvent.java new file mode 100644 index 00000000..f0fd11ee --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/AuthChangedEvent.java @@ -0,0 +1,6 @@ +package kr.syeyoung.dungeonsguide.mod.events.impl; + + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class AuthChangedEvent extends Event { } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/BlockUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/BlockUpdateEvent.java new file mode 100644 index 00000000..41b9cace --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/BlockUpdateEvent.java @@ -0,0 +1,37 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import lombok.Getter; +import lombok.Setter; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Tuple; +import net.minecraftforge.fml.common.eventhandler.Event; + +import java.util.HashSet; +import java.util.Set; + +public abstract class BlockUpdateEvent extends Event { + @Getter @Setter + private Set> updatedBlocks = new HashSet<>(); + + public static class Pre extends BlockUpdateEvent {}; + public static class Post extends BlockUpdateEvent {}; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/BossroomEnterEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/BossroomEnterEvent.java new file mode 100644 index 00000000..aeab26d9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/BossroomEnterEvent.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class BossroomEnterEvent extends Event { +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DiscordUserJoinRequestEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DiscordUserJoinRequestEvent.java new file mode 100644 index 00000000..28452eed --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DiscordUserJoinRequestEvent.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordUser; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@EqualsAndHashCode(callSuper=false) +@AllArgsConstructor +public class DiscordUserJoinRequestEvent extends Event { + private DiscordUser discordUser; + private boolean isInvite; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DiscordUserUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DiscordUserUpdateEvent.java new file mode 100644 index 00000000..0a6e4385 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DiscordUserUpdateEvent.java @@ -0,0 +1,32 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import kr.syeyoung.dungeonsguide.mod.discord.rpc.JDiscordRelation; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@EqualsAndHashCode(callSuper=false) +@AllArgsConstructor +public class DiscordUserUpdateEvent extends Event { + private JDiscordRelation prev, current; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonContextInitializationEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonContextInitializationEvent.java new file mode 100644 index 00000000..5d53dc5a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonContextInitializationEvent.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class DungeonContextInitializationEvent extends Event { +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonEndedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonEndedEvent.java new file mode 100644 index 00000000..8bfe89d0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonEndedEvent.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class DungeonEndedEvent extends Event { +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonLeftEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonLeftEvent.java new file mode 100644 index 00000000..c43fa94f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonLeftEvent.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class DungeonLeftEvent extends Event { +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonStartedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonStartedEvent.java new file mode 100644 index 00000000..3807524c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/DungeonStartedEvent.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class DungeonStartedEvent extends Event { +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/HypixelJoinedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/HypixelJoinedEvent.java new file mode 100644 index 00000000..bab30968 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/HypixelJoinedEvent.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class HypixelJoinedEvent extends Event { +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/KeyBindPressedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/KeyBindPressedEvent.java new file mode 100644 index 00000000..bdb5a41a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/KeyBindPressedEvent.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@EqualsAndHashCode(callSuper=false) +@AllArgsConstructor +public class KeyBindPressedEvent extends Event { + private int key; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/PlayerInteractEntityEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/PlayerInteractEntityEvent.java new file mode 100644 index 00000000..6f549bcb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/PlayerInteractEntityEvent.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.entity.Entity; +import net.minecraftforge.fml.common.eventhandler.Event; + +@AllArgsConstructor +public class PlayerInteractEntityEvent extends Event { + + @Getter @Setter + private boolean attack; + @Getter @Setter + private Entity entity; + + @Override + public boolean isCancelable() { + return true; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/PlayerListItemPacketEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/PlayerListItemPacketEvent.java new file mode 100644 index 00000000..e0f7b2c3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/PlayerListItemPacketEvent.java @@ -0,0 +1,32 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.network.play.server.S38PacketPlayerListItem; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@EqualsAndHashCode(callSuper=false) +@AllArgsConstructor +public class PlayerListItemPacketEvent extends Event { + private S38PacketPlayerListItem packetPlayerListItem; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/SkyblockJoinedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/SkyblockJoinedEvent.java new file mode 100644 index 00000000..27cb10c4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/SkyblockJoinedEvent.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class SkyblockJoinedEvent extends Event { +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/SkyblockLeftEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/SkyblockLeftEvent.java new file mode 100644 index 00000000..529e251c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/SkyblockLeftEvent.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class SkyblockLeftEvent extends Event { +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/StompConnectedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/StompConnectedEvent.java new file mode 100644 index 00000000..554197bb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/StompConnectedEvent.java @@ -0,0 +1,32 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import kr.syeyoung.dungeonsguide.mod.stomp.StompClient; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@EqualsAndHashCode(callSuper=false) +@AllArgsConstructor +public class StompConnectedEvent extends Event { + private StompClient stompInterface; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/TitleEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/TitleEvent.java new file mode 100644 index 00000000..7450dcdc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/TitleEvent.java @@ -0,0 +1,32 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.network.play.server.S45PacketTitle; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@EqualsAndHashCode(callSuper=false) +@AllArgsConstructor +public class TitleEvent extends Event { + S45PacketTitle packetTitle; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/WindowUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/WindowUpdateEvent.java new file mode 100644 index 00000000..412b4d82 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/impl/WindowUpdateEvent.java @@ -0,0 +1,34 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.impl; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.network.play.server.S2FPacketSetSlot; +import net.minecraft.network.play.server.S30PacketWindowItems; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@EqualsAndHashCode(callSuper=false) +@AllArgsConstructor +public class WindowUpdateEvent extends Event { + S30PacketWindowItems windowItems; + S2FPacketSetSlot packetSetSlot; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/DungeonListener.java new file mode 100755 index 00000000..247a9284 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/DungeonListener.java @@ -0,0 +1,513 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.listener; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.config.Config; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonActionContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonAddSet; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonParameterEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonRoomEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.RoomProcessor; +import kr.syeyoung.dungeonsguide.mod.events.impl.*; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.utils.MapUtils; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.relauncher.Side; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class DungeonListener { + + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Unload event) { + try { + Config.saveConfig(); + } catch (IOException e) { + e.printStackTrace(); + } + DungeonActionContext.getSpawnLocation().clear(); + DungeonActionContext.getKilleds().clear(); + } + + @SubscribeEvent + public void onPostDraw(GuiScreenEvent.DrawScreenEvent.Post e) { + if (!SkyblockStatus.isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + if (context != null) { + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + if (thePlayer == null) { + return; + } + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().onPostGuiRender(e); + } + + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null && dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().onPostGuiRender(e); + } + } + + GlStateManager.enableBlend(); + GlStateManager.color(1, 1, 1, 1); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.enableAlpha(); + } + + @SubscribeEvent + public void onEntityUpdate(LivingEvent.LivingUpdateEvent e) { + if (!SkyblockStatus.isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context != null) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + if (thePlayer == null) return; + if (context.getBossfightProcessor() != null) context.getBossfightProcessor().onEntityUpdate(e); + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null && dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().onEntityUpdate(e); + } + } + } + + @SubscribeEvent + public void onDungeonLeave(DungeonLeftEvent ev) { + DungeonsGuide.getDungeonsGuide().getDungeonFacade().setContext(null); + if (!FeatureRegistry.ADVANCED_DEBUGGABLE_MAP.isEnabled()) { + MapUtils.clearMap(); + } + } + + + + + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent ev) { + if (ev.side == Side.SERVER || ev.phase != TickEvent.Phase.START) return; + + + if (SkyblockStatus.isOnSkyblock()) { + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context != null) { + context.getMapProcessor().tick(); + context.tick(); + } else { + if (SkyblockStatus.isOnDungeon()) { + DungeonsGuide.getDungeonsGuide().getDungeonFacade().setContext(new DungeonContext(Minecraft.getMinecraft().thePlayer.worldObj)); + MinecraftForge.EVENT_BUS.post(new DungeonStartedEvent()); + } + } + } + + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (SkyblockStatus.isOnDungeon() && context != null) { + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + if (thePlayer == null) { + return; + } + + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().tick(); + } + + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + + if (dungeonRoom != null && dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().tick(); + } + + } + + } + + + @SubscribeEvent + public void onRender(RenderGameOverlayEvent.Post postRender) { + if (!(postRender.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || postRender.type == RenderGameOverlayEvent.ElementType.JUMPBAR)) + return; + + if (!SkyblockStatus.isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context != null) { + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + if (context.getBossfightProcessor() != null) + context.getBossfightProcessor().drawScreen(postRender.partialTicks); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().drawScreen(postRender.partialTicks); + } + } + + } + GlStateManager.enableBlend(); + GlStateManager.color(1, 1, 1, 1); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + Minecraft.getMinecraft().entityRenderer.setupOverlayRendering(); + GlStateManager.enableAlpha(); + } + + @SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGHEST) + public void onChatReceived(ClientChatReceivedEvent clientChatReceivedEvent) { + if (!SkyblockStatus.isOnDungeon()) return; + + if (clientChatReceivedEvent.type != 2 && clientChatReceivedEvent.message.getFormattedText().contains("ยง6> ยงeยงlEXTRA STATS ยง6<")) { + MinecraftForge.EVENT_BUS.post(new DungeonEndedEvent()); + } + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + if (context != null) { + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + context.onChat(clientChatReceivedEvent); + + if (context.getBossfightProcessor() != null) { + if (clientChatReceivedEvent.type == 2) { + context.getBossfightProcessor().actionbarReceived(clientChatReceivedEvent.message); + } else { + context.getBossfightProcessor().chatReceived(clientChatReceivedEvent.message); + } + } + + RoomProcessor roomProcessor = null; + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + if (clientChatReceivedEvent.type == 2) { + dungeonRoom.getRoomProcessor().actionbarReceived(clientChatReceivedEvent.message); + roomProcessor = dungeonRoom.getRoomProcessor(); + } else { + dungeonRoom.getRoomProcessor().chatReceived(clientChatReceivedEvent.message); + roomProcessor = dungeonRoom.getRoomProcessor(); + } + } + } + if (clientChatReceivedEvent.type == 2) { + return; + } + for (RoomProcessor globalRoomProcessor : context.getGlobalRoomProcessors()) { + if (globalRoomProcessor != roomProcessor) { + globalRoomProcessor.chatReceived(clientChatReceivedEvent.message); + } + } + } + } + + + @SubscribeEvent + public void onWorldRender(RenderWorldLastEvent renderWorldLastEvent) { + if (!SkyblockStatus.isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) { + return; + } + + if (FeatureRegistry.DEBUG.isEnabled()) { + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + for (DungeonDoor door : dungeonRoom.getDoors()) { + RenderUtils.renderDoor(door, renderWorldLastEvent.partialTicks); + } + } + } + + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().drawWorld(renderWorldLastEvent.partialTicks); + } + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().drawWorld(renderWorldLastEvent.partialTicks); + } + } + + if (FeatureRegistry.DEBUG.isEnabled() && dungeonRoom != null) { + + Vec3 player = Minecraft.getMinecraft().thePlayer.getPositionVector(); + BlockPos real = new BlockPos(player.xCoord * 2, player.yCoord * 2, player.zCoord * 2); + for (BlockPos allInBox : BlockPos.getAllInBox(real.add(-1, -1, -1), real.add(1, 1, 1))) { + boolean blocked = dungeonRoom.isBlocked(allInBox.getX(), allInBox.getY(), allInBox.getZ()); + + RenderUtils.highlightBox( + AxisAlignedBB.fromBounds( + allInBox.getX() / 2.0 - 0.1, allInBox.getY() / 2.0 - 0.1, allInBox.getZ() / 2.0 - 0.1, + allInBox.getX() / 2.0 + 0.1, allInBox.getY() / 2.0 + 0.1, allInBox.getZ() / 2.0 + 0.1 + ), blocked ? new Color(0x55FF0000, true) : new Color(0x3300FF00, true), renderWorldLastEvent.partialTicks, false); + + } + } + + if (EditingContext.getEditingContext() != null) { + GuiScreen guiScreen = EditingContext.getEditingContext().getCurrent(); + if (guiScreen instanceof GuiDungeonParameterEdit) { + ValueEdit valueEdit = ((GuiDungeonParameterEdit) guiScreen).getValueEdit(); + if (valueEdit != null) { + valueEdit.renderWorld(renderWorldLastEvent.partialTicks); + } + } else if (guiScreen instanceof GuiDungeonValueEdit) { + ValueEdit valueEdit = ((GuiDungeonValueEdit) guiScreen).getValueEdit(); + if (valueEdit != null) { + valueEdit.renderWorld(renderWorldLastEvent.partialTicks); + } + } else if (guiScreen instanceof GuiDungeonAddSet) { + ((GuiDungeonAddSet) guiScreen).onWorldRender(renderWorldLastEvent.partialTicks); + } + } + } + + @SubscribeEvent() + public void onKey2(KeyBindPressedEvent keyInputEvent) { + if (!SkyblockStatus.isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().onKeybindPress(keyInputEvent); + } + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().onKeybindPress(keyInputEvent); + } + } + } + } + + @SubscribeEvent() + public void onInteract(PlayerInteractEntityEvent interact) { + if (!SkyblockStatus.isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().onInteract(interact); + } + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().onInteract(interact); + } + } + } + } + + + String getCurrentRoomName(){ + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(player.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + String in = "unknown"; + if (dungeonRoom != null){ + in = dungeonRoom.getDungeonRoomInfo().getName(); + } + + return in; + } + + @SubscribeEvent + public void onBlockChange(BlockUpdateEvent.Post postInteract) { + if (!SkyblockStatus.isOnDungeon()) return; + + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null) { + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().onBlockUpdate(postInteract); + } + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().onBlockUpdate(postInteract); + } + } + } + } + + @SubscribeEvent + public void onKeyInput(KeyBindPressedEvent keyInputEvent) { + if (FeatureRegistry.DEBUG.isEnabled() && FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && keyInputEvent.getKey() == FeatureRegistry.ADVANCED_ROOMEDIT.getParameter("key").getValue()) { + EditingContext ec = EditingContext.getEditingContext(); + if (ec == null) { + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) { + ChatTransmitter.addToQueue(new ChatComponentText("Not in dungeons")); + return; + } + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + + if (dungeonRoom == null) { + ChatTransmitter.addToQueue(new ChatComponentText("Can't determine the dungeon room you're in")); + return; + } + + if (EditingContext.getEditingContext() != null) { + ChatTransmitter.addToQueue(new ChatComponentText("There is an editing session currently open.")); + return; + } + + EditingContext.createEditingContext(dungeonRoom); + EditingContext.getEditingContext().openGui(new GuiDungeonRoomEdit(dungeonRoom)); + } else ec.reopen(); + } + } + + @SubscribeEvent + public void onInteract(PlayerInteractEvent keyInputEvent) { + if (!keyInputEvent.world.isRemote) return; + if (!SkyblockStatus.isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + if (context != null) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().onInteractBlock(keyInputEvent); + } + + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().onInteractBlock(keyInputEvent); + } + } + } + } + + @Getter + private final Map entityIdToPosMap = new HashMap<>(); + + @SubscribeEvent + public void onEntitySpawn(EntityJoinWorldEvent spawn) { + DungeonActionContext.getSpawnLocation().put(spawn.entity.getEntityId(), new Vec3(spawn.entity.posX, spawn.entity.posY, spawn.entity.posZ)); + } + + + @SubscribeEvent + public void onEntityDeSpawn(LivingDeathEvent deathEvent) { + if (deathEvent.entityLiving instanceof EntityBat) + DungeonActionContext.getKilleds().add(deathEvent.entity.getEntityId()); + + if (!SkyblockStatus.isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade() != null) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().onEntityDeath(deathEvent); + } + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().onEntityDeath(deathEvent); + } + } + } + + if (!(deathEvent.entityLiving instanceof EntityBat)) + DungeonActionContext.getSpawnLocation().remove(deathEvent.entity.getEntityId()); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FeatureListener.java new file mode 100644 index 00000000..c15d107c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FeatureListener.java @@ -0,0 +1,512 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.listener; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.mod.events.impl.*; +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.client.event.*; +import net.minecraftforge.client.event.sound.PlaySoundEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +public class FeatureListener { + @SubscribeEvent + public void onRender(RenderGameOverlayEvent.Post postRender) { + try { + boolean isLocConfig = Minecraft.getMinecraft().currentScreen instanceof GuiGuiLocationConfig; + + if (!(postRender.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || postRender.type == RenderGameOverlayEvent.ElementType.JUMPBAR)) return; + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof ScreenRenderListener && (!isLocConfig || !(abstractFeature instanceof GuiFeature))) { + ((ScreenRenderListener) abstractFeature).drawScreen(postRender.partialTicks); + } + } + GlStateManager.enableBlend(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @SubscribeEvent + public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof KeybindPressedListener) { + ((KeybindPressedListener) abstractFeature).onKeybindPress(keyBindPressedEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @SubscribeEvent + public void onStomp(StompConnectedEvent stompConnectedEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof StompConnectedListener) { + ((StompConnectedListener) abstractFeature).onStompConnected(stompConnectedEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onStomp(TextureStitchEvent.Pre textureStitchEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof TextureStichListener) { + ((TextureStichListener) abstractFeature).onTextureStitch(textureStitchEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onStomp(TextureStitchEvent.Post textureStitchEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof TextureStichListener) { + ((TextureStichListener) abstractFeature).onTextureStitch(textureStitchEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onDiscordUserUpdate(DiscordUserUpdateEvent discordUserUpdateEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof DiscordUserUpdateListener) { + ((DiscordUserUpdateListener) abstractFeature).onDiscordUserUpdate(discordUserUpdateEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onDiscordUserUpdate(DiscordUserJoinRequestEvent discordUserUpdateEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof DiscordUserJoinRequestListener) { + ((DiscordUserJoinRequestListener) abstractFeature).onDiscordUserJoinRequest(discordUserUpdateEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onWindowUpdate(WindowUpdateEvent windowUpdateEvent) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof GuiUpdateListener) { + ((GuiUpdateListener) abstractFeature).onGuiUpdate(windowUpdateEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onRender(RenderLivingEvent.Pre preRender) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof EntityLivingRenderListener) { + ((EntityLivingRenderListener) abstractFeature).onEntityRenderPre(preRender); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @SubscribeEvent + public void onSound(PlaySoundEvent soundEvent) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof SoundListener) { + ((SoundListener) abstractFeature).onSound(soundEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @SubscribeEvent + public void onRender(RenderLivingEvent.Post preRender) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof EntityLivingRenderListener) { + ((EntityLivingRenderListener) abstractFeature).onEntityRenderPost(preRender); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onRender(TitleEvent titleEvent) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof TitleListener) { + ((TitleListener) abstractFeature).onTitle(titleEvent.getPacketTitle()); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onRender(RenderPlayerEvent.Pre preRender) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof PlayerRenderListener) { + ((PlayerRenderListener) abstractFeature).onEntityRenderPre(preRender); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onRender(RenderPlayerEvent.Post preRender) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof PlayerRenderListener) { + ((PlayerRenderListener) abstractFeature).onEntityRenderPost(preRender); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + + @SubscribeEvent + public void onRenderWorld(RenderWorldLastEvent postRender) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof WorldRenderListener) { + ((WorldRenderListener) abstractFeature).drawWorld(postRender.partialTicks); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onInteract(PlayerInteractEvent postRender) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof InteractListener) { + ((InteractListener) abstractFeature).onInteract(postRender); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + + @SubscribeEvent + public void onRenderWorld(ClientChatReceivedEvent postRender) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof ChatListener) { + ((ChatListener) abstractFeature).onChat(postRender); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @SubscribeEvent + public void onChatGlobal(ClientChatReceivedEvent postRender) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof ChatListenerGlobal) { + ((ChatListenerGlobal) abstractFeature).onChat(postRender); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @SubscribeEvent + public void dungeonTooltip(ItemTooltipEvent event) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof TooltipListener) { + ((TooltipListener) abstractFeature).onTooltip(event); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent tick) { + if (tick.phase == TickEvent.Phase.END && tick.type == TickEvent.Type.CLIENT ) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof TickListener) { + ((TickListener) abstractFeature).onTick(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + @SubscribeEvent + public void onGuiOpen(GuiOpenEvent tick) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof GuiOpenListener) { + ((GuiOpenListener) abstractFeature).onGuiOpen(tick); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onGuiRender(GuiScreenEvent.DrawScreenEvent.Post render) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof GuiPostRenderListener) { + ((GuiPostRenderListener) abstractFeature).onGuiPostRender(render); + } + } + GlStateManager.enableBlend(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onGuiRender(GuiScreenEvent.DrawScreenEvent.Pre render) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof GuiPreRenderListener) { + ((GuiPreRenderListener) abstractFeature).onGuiPreRender(render); + } + } + GlStateManager.enableBlend(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onGuiRender(GuiScreenEvent.BackgroundDrawnEvent render) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof GuiBackgroundRenderListener) { + ((GuiBackgroundRenderListener) abstractFeature).onGuiBGRender(render); + } + } + GlStateManager.enableBlend(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGH) + public void onGuiEvent(GuiScreenEvent.MouseInputEvent.Pre input) { + try { + + if (!SkyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof GuiClickListener) { + ((GuiClickListener) abstractFeature).onMouseInput(input); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onSkyblockJoin(SkyblockJoinedEvent joinedEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof SkyblockJoinListener) { + ((SkyblockJoinListener) abstractFeature).onSkyblockJoin(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onSkyblockQuit(SkyblockLeftEvent leftEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof SkyblockLeaveListener) { + ((SkyblockLeaveListener) abstractFeature).onSkyblockQuit(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onKey(GuiScreenEvent.KeyboardInputEvent event) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof KeyInputListener) { + ((KeyInputListener) abstractFeature).onKeyInput(event); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onDungeonStart(DungeonStartedEvent leftEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof DungeonStartListener) { + ((DungeonStartListener) abstractFeature).onDungeonStart(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onDungeonLeft(DungeonLeftEvent leftEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof DungeonQuitListener) { + ((DungeonQuitListener) abstractFeature).onDungeonQuit(); + } + if (abstractFeature instanceof DungeonEndListener) { + ((DungeonEndListener) abstractFeature).onDungeonEnd(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onDungeonInitialize(DungeonContextInitializationEvent leftEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof DungeonContextInitializationListener) { + ((DungeonContextInitializationListener) abstractFeature).onDungeonInitialize(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onDungeonInitialize(BossroomEnterEvent enterEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof BossroomEnterListener) { + ((BossroomEnterListener) abstractFeature).onBossroomEnter(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent + public void onDungeonInitialize(DungeonEndedEvent endedEvent) { + try { + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof DungeonEndListener) { + ((DungeonEndListener) abstractFeature).onDungeonEnd(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketListener.java new file mode 100644 index 00000000..3a622dcf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketListener.java @@ -0,0 +1,191 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.events.listener; + +import io.netty.channel.ChannelDuplexHandler; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CustomPacketPlayerListItem; +import kr.syeyoung.dungeonsguide.mod.events.impl.BlockUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.TitleEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.WindowUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.network.Packet; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.server.*; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Tuple; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.network.FMLNetworkEvent; + +import java.util.Arrays; + +@ChannelHandler.Sharable +public class PacketListener extends ChannelDuplexHandler { + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Packet packet = (Packet) msg; + if (skyblockStatus.isOnSkyblock() + && msg instanceof S04PacketEntityEquipment + && FeatureRegistry.FIX_SPIRIT_BOOTS.isEnabled()) { // Inventory packet name + S04PacketEntityEquipment packet2 = (S04PacketEntityEquipment) msg; + if (packet2.getEntityID() == Minecraft.getMinecraft().thePlayer.getEntityId()) { + packet2 = new S04PacketEntityEquipment(packet2.getEntityID(), packet2.getEquipmentSlot() + 1, packet2.getItemStack()); + packet = packet2; + } + } + if (packet instanceof S45PacketTitle) { + MinecraftForge.EVENT_BUS.post(new TitleEvent((S45PacketTitle) packet)); + } + if (packet instanceof S38PacketPlayerListItem) { + packet = new CustomPacketPlayerListItem((S38PacketPlayerListItem) packet); + } + if (packet instanceof S30PacketWindowItems) { + packet = new CustomWindowItems((S30PacketWindowItems) packet); + } + if (packet instanceof S2FPacketSetSlot) { + packet = new CustomSetSlot((S2FPacketSetSlot) packet); + } + if (packet instanceof S23PacketBlockChange) { + packet = new SingleBlockChange((S23PacketBlockChange) packet); + } else if (packet instanceof S22PacketMultiBlockChange) { + packet = new MultiBlockChange((S22PacketMultiBlockChange) packet); + } + super.channelRead(ctx, packet); + } + + private static class CustomWindowItems extends S30PacketWindowItems { + public CustomWindowItems(S30PacketWindowItems parent) { + super(parent.func_148911_c(), Arrays.asList(parent.getItemStacks())); + } + + @Override + public void processPacket(INetHandlerPlayClient handler) { + super.processPacket(handler); + MinecraftForge.EVENT_BUS.post(new WindowUpdateEvent(this, null)); + } + } + private static class CustomSetSlot extends S2FPacketSetSlot { + public CustomSetSlot(S2FPacketSetSlot parent) { + super(parent.func_149175_c(), parent.func_149173_d(), parent.func_149174_e()); + } + @Override + public void processPacket(INetHandlerPlayClient handler) { + super.processPacket(handler); + MinecraftForge.EVENT_BUS.post(new WindowUpdateEvent(null, this)); + } + } + + private static class SingleBlockChange extends S23PacketBlockChange { + private S23PacketBlockChange old; + public SingleBlockChange(S23PacketBlockChange blockChange) { + this.old = blockChange; + } + + @Override + public void processPacket(INetHandlerPlayClient handler) { + + BlockUpdateEvent blockUpdateEvent = new BlockUpdateEvent.Pre(); + blockUpdateEvent.getUpdatedBlocks().add(new Tuple<>(getBlockPosition(),getBlockState())); + + + MinecraftForge.EVENT_BUS.post(blockUpdateEvent); + super.processPacket(handler); + blockUpdateEvent = new BlockUpdateEvent.Post(); + blockUpdateEvent.getUpdatedBlocks().add(new Tuple<>(getBlockPosition(), getBlockState())); + MinecraftForge.EVENT_BUS.post(blockUpdateEvent); + + + + + } + + @Override + public BlockPos getBlockPosition() { + return old.getBlockPosition(); + } + + @Override + public IBlockState getBlockState() { + return old.getBlockState(); + } + } + + + private static class MultiBlockChange extends S22PacketMultiBlockChange { + private S22PacketMultiBlockChange old; + public MultiBlockChange(S22PacketMultiBlockChange blockChange) { + this.old = blockChange; + } + @Override + public void processPacket(INetHandlerPlayClient handler) { + + + BlockUpdateEvent blockUpdateEvent = new BlockUpdateEvent.Pre(); + for (S22PacketMultiBlockChange.BlockUpdateData changedBlock : getChangedBlocks()) { + blockUpdateEvent.getUpdatedBlocks().add(new Tuple<>(changedBlock.getPos(), changedBlock.getBlockState())); + } + MinecraftForge.EVENT_BUS.post(blockUpdateEvent); + super.processPacket(handler); + blockUpdateEvent = new BlockUpdateEvent.Post(); + for (S22PacketMultiBlockChange.BlockUpdateData changedBlock : getChangedBlocks()) { + blockUpdateEvent.getUpdatedBlocks().add(new Tuple<>(changedBlock.getPos(), changedBlock.getBlockState())); + } + MinecraftForge.EVENT_BUS.post(blockUpdateEvent); + + + } + + @Override + public BlockUpdateData[] getChangedBlocks() { + return old.getChangedBlocks(); + } + } + + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + Packet packet = (Packet) msg; + if (packet instanceof C02PacketUseEntity) { + C02PacketUseEntity packet2 = (C02PacketUseEntity) packet; + PlayerInteractEntityEvent piee; + if (packet2.getAction() == C02PacketUseEntity.Action.ATTACK) + piee = new PlayerInteractEntityEvent(true, packet2.getEntityFromWorld(Minecraft.getMinecraft().theWorld)); + else + piee = new PlayerInteractEntityEvent(false, ((C02PacketUseEntity) packet).getEntityFromWorld(Minecraft.getMinecraft().theWorld)); + + if (MinecraftForge.EVENT_BUS.post(piee)) return; + } + super.write(ctx, msg, promise); + } + + @SubscribeEvent + public void onServerConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { + event.manager.channel().pipeline().addBefore("packet_handler", "dg_packet_handler", this); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java new file mode 100644 index 00000000..92d0bde3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractFeature.java @@ -0,0 +1,114 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features; + +import com.google.common.base.Supplier; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.config.types.TypeConverter; +import kr.syeyoung.dungeonsguide.mod.config.types.TypeConverterRegistry; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.util.*; + +public abstract class AbstractFeature { + @Getter + private final String category; + @Getter + private final String name; + + @Getter + private final String description; + + @Getter + private final String key; + + protected Map parameters = new HashMap(); + + protected void addParameter(String name, FeatureParameter f){ + parameters.put(name, f); + } + + + protected AbstractFeature(String category, String name, String description, String key) { + this.category = category; + this.name = name; + this.description = description; + this.key = key; + } + + @Getter + @Setter + private boolean enabled = true; + + public List getParameters() { return new ArrayList(parameters.values()); } + + public FeatureParameter getParameter(String key) { + return parameters.get(key); + } + + public void loadConfig(JsonObject jsonObject) { // gets key, calls it + enabled = jsonObject.get("$enabled").getAsBoolean(); + + for (Map.Entry parameterEntry : parameters.entrySet()) { + parameterEntry.getValue().setToDefault(); + JsonElement element = jsonObject.get(parameterEntry.getKey()); + if (element == null) continue; + TypeConverter typeConverter = TypeConverterRegistry.getTypeConverter(parameterEntry.getValue().getValue_type()); + parameterEntry.getValue().setValue(typeConverter.deserialize(element)); + } + } + + public JsonObject saveConfig() { + JsonObject object = new JsonObject(); + for (Map.Entry parameterEntry : parameters.entrySet()) { + TypeConverter typeConverter = TypeConverterRegistry.getTypeConverter(parameterEntry.getValue().getValue_type()); + JsonElement obj = typeConverter.serialize(parameterEntry.getValue().getValue()); + object.add(parameterEntry.getKey(), obj); + } + object.addProperty("$enabled", isEnabled()); + return object; + } + + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + key , new Supplier() { + @Override + public MPanel get() { + MFeatureEdit featureEdit = new MFeatureEdit(AbstractFeature.this, rootConfigPanel); + for (FeatureParameter parameter: getParameters()) { + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(AbstractFeature.this, parameter, rootConfigPanel)); + } + return featureEdit; + } + }); + return "base." + key ; + } + + public void onParameterReset() {} + + public boolean isDisyllable() { + return true; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureParameter.java new file mode 100644 index 00000000..30559d8a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureParameter.java @@ -0,0 +1,72 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features; + +import kr.syeyoung.dungeonsguide.mod.config.types.TypeConverter; +import kr.syeyoung.dungeonsguide.mod.config.types.TypeConverterRegistry; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.function.Consumer; + +@Data +@AllArgsConstructor +public class FeatureParameter { + private String key; + private String name; + private String description; + private T value; + + + private T default_value; + private String value_type; + private Consumer changedCallback; + + public FeatureParameter(String key, String name, String description, T default_value, String value_type) { + this(key, name, description,default_value, value_type, null); + } + + public FeatureParameter(String key, String name, String description, T default_value, String value_type, Consumer changedCallback) { + this.key = key; + this.name = name; + this.default_value = default_value; + this.description = description; + this.value_type = value_type; + if(changedCallback != null){ + this.changedCallback = changedCallback; + changedCallback.accept(default_value); + } + } + + public void setToDefault() { + TypeConverter typeConverter = TypeConverterRegistry.getTypeConverter(getValue_type()); + value = (T) typeConverter.deserialize(typeConverter.serialize(default_value)); + } + + public T getValue() { + return value == null ? default_value : value; + } + + public void setValue(T newValue){ + value = newValue; + if(changedCallback != null){ + changedCallback.accept(value); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java new file mode 100644 index 00000000..b8ff6bbc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java @@ -0,0 +1,337 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features; + +import kr.syeyoung.dungeonsguide.mod.features.impl.advanced.*; +import kr.syeyoung.dungeonsguide.mod.features.impl.boss.*; +import kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal.FeatureSimonSaysSolver; +import kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal.FeatureTerminalSolvers; +import kr.syeyoung.dungeonsguide.mod.features.impl.cosmetics.FeatureNicknameColor; +import kr.syeyoung.dungeonsguide.mod.features.impl.cosmetics.FeatureNicknamePrefix; +import kr.syeyoung.dungeonsguide.mod.features.impl.discord.inviteViewer.PartyInviteViewer; +import kr.syeyoung.dungeonsguide.mod.features.impl.discord.onlinealarm.PlayingDGAlarm; +import kr.syeyoung.dungeonsguide.mod.features.impl.dungeon.*; +import kr.syeyoung.dungeonsguide.mod.features.impl.etc.*; +import kr.syeyoung.dungeonsguide.mod.features.impl.etc.ability.FeatureAbilityCooldown; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.APIKey; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.FeaturePartyList; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.FeaturePartyReady; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.customgui.FeatureCustomPartyFinder; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.FeatureViewPlayerStatsOnJoin; +import kr.syeyoung.dungeonsguide.mod.features.impl.secret.*; +import kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser.FeatureMechanicBrowse; +import kr.syeyoung.dungeonsguide.mod.features.impl.solvers.*; +import lombok.Getter; +import org.lwjgl.input.Keyboard; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class FeatureRegistry { + @Getter + private static final List featureList = new ArrayList(); + private static final Map featureByKey = new HashMap(); + @Getter + private static final Map> featuresByCategory = new HashMap>(); + @Getter + private static final Map categoryDescription = new HashMap<>(); + + public static AbstractFeature getFeatureByKey(String key) { + return featureByKey.get(key); + } + + public static T register(T abstractFeature) { + if (featureByKey.containsKey(abstractFeature.getKey())) throw new IllegalArgumentException("DUPLICATE FEATURE DEFINITION"); + featureList.add(abstractFeature); + featureByKey.put(abstractFeature.getKey(), abstractFeature); + List features = featuresByCategory.get(abstractFeature.getCategory()); + if (features == null) + features = new ArrayList(); + features.add(abstractFeature); + featuresByCategory.put(abstractFeature.getCategory(), features); + + return abstractFeature; + } + + + + public static PathfindLineProperties SECRET_LINE_PROPERTIES_GLOBAL; + + public static FeatureMechanicBrowse SECRET_BROWSE; + public static PathfindLineProperties SECRET_LINE_PROPERTIES_SECRET_BROWSER; + public static FeatureActions SECRET_ACTIONS; + + public static FeaturePathfindStrategy SECRET_PATHFIND_STRATEGY; + public static FeatureTogglePathfind SECRET_TOGGLE_KEY; + public static FeatureFreezePathfind SECRET_FREEZE_LINES; + public static FeatureCreateRefreshLine SECRET_CREATE_REFRESH_LINE; + + public static SimpleFeature SECRET_AUTO_BROWSE_NEXT; + public static SimpleFeature SECRET_AUTO_START; + public static SimpleFeature SECRET_NEXT_KEY; + + public static SimpleFeature SECRET_BLOOD_RUSH; + public static PathfindLineProperties SECRET_BLOOD_RUSH_LINE_PROPERTIES; + + + public static PathfindLineProperties SECRET_LINE_PROPERTIES_AUTOPATHFIND; + + public static FeaturePathfindToAll SECRET_PATHFIND_ALL; + public static PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT; + + public static PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_BAT; + public static PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_CHEST; + public static PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_ESSENCE; + public static PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_ITEM_DROP; + + public static FeatureSolverRiddle SOLVER_RIDDLE; + public static FeatureSolverTictactoe SOLVER_TICTACTOE; + public static SimpleFeature SOLVER_WATERPUZZLE; + public static SimpleFeature SOLVER_CREEPER; + public static FeatureSolverTeleport SOLVER_TELEPORT; + public static FeatureSolverBlaze SOLVER_BLAZE; + public static FeatureSolverIcefill SOLVER_ICEPATH; + public static FeatureSolverSilverfish SOLVER_SILVERFISH; + public static FeatureSolverBox SOLVER_BOX; + public static FeatureSolverKahoot SOLVER_KAHOOT; + public static FeatureSolverBombdefuse SOLVER_BOMBDEFUSE; + + + public static FeatureDungeonMap DUNGEON_MAP; + public static FeatureTestPepole TEST_PEPOLE; + public static FeatureDungeonRoomName DUNGEON_ROOMNAME; + public static FeaturePressAnyKeyToCloseChest DUNGEON_CLOSECHEST; + public static FeatureBoxSkelemaster DUNGEON_BOXSKELEMASTER; + public static FeatureBoxBats DUNGEON_BOXBAT; + public static FeatureBoxStarMobs DUNGEON_BOXSTARMOBS; + public static FeatureWatcherWarning DUNGEON_WATCHERWARNING; + public static FeatureDungeonDeaths DUNGEON_DEATHS; + public static FeatureDungeonMilestone DUNGEON_MILESTONE; + public static FeatureDungeonRealTime DUNGEON_REALTIME; + public static FeatureDungeonSBTime DUNGEON_SBTIME; + public static FeatureDungeonSecrets DUNGEON_SECRETS; + public static FeatureDungeonCurrentRoomSecrets DUNGEON_SECRETS_ROOM; + public static FeatureDungeonTombs DUNGEON_TOMBS; + public static FeatureDungeonScore DUNGEON_SCORE; + public static FeatureWarnLowHealth DUNGEON_LOWHEALTH_WARN; + public static SimpleFeature DUNGEON_INTERMODCOMM; + public static FeaturePlayerESP DUNGEON_PLAYERESP; + public static FeatureHideNameTags DUNGEON_HIDENAMETAGS; + public static FeatureSoulRoomWarning DUNGEON_FAIRYSOUL; + + public static FeatureWarningOnPortal BOSSFIGHT_WARNING_ON_PORTAL; + public static SimpleFeature BOSSFIGHT_CHESTPRICE; + public static FeatureAutoReparty BOSSFIGHT_AUTOREPARTY; + public static FeatureBossHealth BOSSFIGHT_HEALTH; + public static FeatureHideAnimals BOSSFIGHT_HIDE_ANIMALS; + public static FeatureThornBearPercentage BOSSFIGHT_BEAR_PERCENT; + public static FeatureThornSpiritBowTimer BOSSFIGHT_BOW_TIMER; + public static FeatureBoxRealLivid BOSSFIGHT_BOX_REALLIVID; + public static FeatureTerracotaTimer BOSSFIGHT_TERRACOTTA_TIMER; + public static FeatureCurrentPhase BOSSFIGHT_CURRENT_PHASE; + public static FeatureTerminalSolvers BOSSFIGHT_TERMINAL_SOLVERS; + public static FeatureSimonSaysSolver BOSSFIGHT_SIMONSAYS_SOLVER; + + public static APIKey PARTYKICKER_APIKEY; + public static FeatureViewPlayerStatsOnJoin PARTYKICKER_VIEWPLAYER; + public static FeatureCustomPartyFinder PARTYKICKER_CUSTOM; + public static FeaturePartyList PARTY_LIST; + public static FeaturePartyReady PARTY_READY; + + public static FeatureTooltipDungeonStat ETC_DUNGEONSTAT; + public static FeatureTooltipPrice ETC_PRICE; + public static FeatureAbilityCooldown ETC_ABILITY_COOLDOWN; + public static FeatureCooldownCounter ETC_COOLDOWN; + public static FeatureRepartyCommand ETC_REPARTY; + public static FeatureDecreaseExplosionSound ETC_EXPLOSION_SOUND; + public static FeatureAutoAcceptReparty ETC_AUTO_ACCEPT_REPARTY; + public static FeatureUpdateAlarm ETC_TEST; + + public static SimpleFeature FIX_SPIRIT_BOOTS; + public static FeatureDisableMessage FIX_MESSAGES; + + public static FeatureCopyMessages ETC_COPY_MSG; + + public static FeatureEpicCountdown EPIC_COUNTDOWN; + + public static FeaturePenguins ETC_PENGUIN; + + public static FeatureCollectScore ETC_COLLECT_SCORE; + + + + + + public static FeatureNicknamePrefix COSMETIC_PREFIX; + public static FeatureNicknameColor COSMETIC_NICKNAMECOLOR; + + + + public static SimpleFeature DISCORD_RICHPRESENCE; + public static PartyInviteViewer DISCORD_ASKTOJOIN; + public static PlayingDGAlarm DISCORD_ONLINEALARM; + public static SimpleFeature DISCORD_DONOTUSE; + + + public static SimpleFeature DEBUG; + public static SimpleFeature ADVANCED_ROOMEDIT; + + public static FeatureRoomDebugInfo ADVANCED_DEBUG_ROOM; + + public static FeatureDebuggableMap ADVANCED_DEBUGGABLE_MAP; + + public static FeatureRoomCoordDisplay ADVANCED_COORDS; + + private static FeatureDebugTrap ADVANCED_BAT; + + public static SimpleFeature RENDER_BREACONS; + + public static SimpleFeature RENDER_DESTENATION_TEXT; + + public static SimpleFeature DEBUG_BLOCK_CACHING; + + public void init(){ + try { + SECRET_LINE_PROPERTIES_GLOBAL = register(new PathfindLineProperties("Dungeon.Secrets.Preferences", "Global Line Settings", "Global Line Settings", "secret.lineproperties.global", true, null)); + SECRET_CREATE_REFRESH_LINE = register(new FeatureCreateRefreshLine()); + SECRET_FREEZE_LINES = register(new FeatureFreezePathfind()); + SECRET_TOGGLE_KEY = register(new FeatureTogglePathfind()); + SECRET_PATHFIND_STRATEGY = register(new FeaturePathfindStrategy()); + SECRET_ACTIONS = register(new FeatureActions()); + SECRET_LINE_PROPERTIES_SECRET_BROWSER = register(new PathfindLineProperties("Dungeon.Secrets.Secret Browser", "Line Settings", "Line Settings when pathfinding using Secret Browser", "secret.lineproperties.secretbrowser", true, SECRET_LINE_PROPERTIES_GLOBAL)); + SECRET_BROWSE = register(new FeatureMechanicBrowse()); + categoryDescription.put("ROOT.Secrets.Keybinds", "Useful keybinds / Toggle Pathfind lines, Freeze Pathfind lines, Refresh pathfind line or Trigger pathfind (you would want to use it, if you're using Pathfind to All)"); + SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT = register(new PathfindLineProperties("Dungeon.Secrets.Pathfind To All", "Parent Line Settings", "Line Settings to be used by default", "secret.lineproperties.apf.parent", false, SECRET_LINE_PROPERTIES_GLOBAL)); + DUNGEON_FAIRYSOUL = register(new FeatureSoulRoomWarning()); + DUNGEON_HIDENAMETAGS = register(new FeatureHideNameTags()); + DUNGEON_PLAYERESP = register(new FeaturePlayerESP()); + DUNGEON_INTERMODCOMM = register(new SimpleFeature("Dungeon.Teammates", "Communicate With Other's Dungeons Guide", "Sends total secret in the room to others\nSo that they can use the data to calculate total secret in dungeon run\n\nThis automates player chatting action, (chatting data) Thus it might be against hypixel's rules.\nBut mods like auto-gg which also automate player action and is kinda allowed mod exist so I'm leaving this feature.\nThis option is use-at-your-risk and you'll be responsible for ban if you somehow get banned because of this feature\n(Although it is not likely to happen)\nDefaults to off", "dungeon.intermodcomm", false)); + DUNGEON_LOWHEALTH_WARN = register(new FeatureWarnLowHealth()); + DUNGEON_SCORE = register(new FeatureDungeonScore()); + DUNGEON_TOMBS = register(new FeatureDungeonTombs()); + DUNGEON_SECRETS_ROOM = register(new FeatureDungeonCurrentRoomSecrets()); + DUNGEON_SECRETS = register(new FeatureDungeonSecrets()); + DUNGEON_SBTIME = register(new FeatureDungeonSBTime()); + DUNGEON_REALTIME = register(new FeatureDungeonRealTime()); + DUNGEON_MILESTONE = register(new FeatureDungeonMilestone()); + DUNGEON_DEATHS = register(new FeatureDungeonDeaths()); + DUNGEON_WATCHERWARNING = register(new FeatureWatcherWarning()); + DUNGEON_BOXSTARMOBS = register(new FeatureBoxStarMobs()); + DUNGEON_BOXBAT = register(new FeatureBoxBats()); + DUNGEON_BOXSKELEMASTER = register(new FeatureBoxSkelemaster()); + DUNGEON_CLOSECHEST = register(new FeaturePressAnyKeyToCloseChest()); + DUNGEON_ROOMNAME = register(new FeatureDungeonRoomName()); +// TEST_PEPOLE = register(new FeatureTestPepole()); + DUNGEON_MAP = register(new FeatureDungeonMap()); + SOLVER_BOMBDEFUSE = register(new FeatureSolverBombdefuse()); + SOLVER_KAHOOT = register(new FeatureSolverKahoot()); + SOLVER_BOX = register(new FeatureSolverBox()); + SOLVER_SILVERFISH = register(new FeatureSolverSilverfish()); + SOLVER_ICEPATH = register(new FeatureSolverIcefill()); + SOLVER_BLAZE = register(new FeatureSolverBlaze()); + SOLVER_TELEPORT = register(new FeatureSolverTeleport()); + SOLVER_CREEPER = register(new SimpleFeature("Dungeon.Solvers.Any Floor", "Creeper", "Draws line between prismarine lamps in creeper room", "solver.creeper")); + SOLVER_WATERPUZZLE = register(new SimpleFeature("Dungeon.Solvers.Any Floor", "Waterboard (Advanced)", "Calculates solution for waterboard puzzle and displays it to user", "solver.waterboard")); + SOLVER_TICTACTOE = register(new FeatureSolverTictactoe()); + SOLVER_RIDDLE = register(new FeatureSolverRiddle()); + SECRET_LINE_PROPERTIES_PATHFINDALL_ITEM_DROP = register(new PathfindLineProperties("Dungeon.Secrets.Pathfind To All", "Item Drop Line Settings", "Line Settings when pathfind to Item Drop, when using above feature", "secret.lineproperties.apf.itemdrop", true, SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT)); + SECRET_LINE_PROPERTIES_PATHFINDALL_ESSENCE = register(new PathfindLineProperties("Dungeon.Secrets.Pathfind To All", "Essence Line Settings", "Line Settings when pathfind to Essence, when using above feature", "secret.lineproperties.apf.essence", true, SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT)); + SECRET_LINE_PROPERTIES_PATHFINDALL_CHEST = register(new PathfindLineProperties("Dungeon.Secrets.Pathfind To All", "Chest Line Settings", "Line Settings when pathfind to Chest, when using above feature", "secret.lineproperties.apf.chest", true, SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT)); + SECRET_LINE_PROPERTIES_PATHFINDALL_BAT = register(new PathfindLineProperties("Dungeon.Secrets.Pathfind To All", "Bat Line Settings", "Line Settings when pathfind to Bat, when using above feature", "secret.lineproperties.apf.bat", true, SECRET_LINE_PROPERTIES_PATHFINDALL_PARENT)); + SECRET_PATHFIND_ALL = register(new FeaturePathfindToAll()); + SECRET_LINE_PROPERTIES_AUTOPATHFIND = register(new PathfindLineProperties("Dungeon.Secrets.Legacy AutoPathfind", "Line Settings", "Line Settings when pathfinding using above features", "secret.lineproperties.autopathfind", true, SECRET_LINE_PROPERTIES_GLOBAL)); + SECRET_BLOOD_RUSH_LINE_PROPERTIES = register(new PathfindLineProperties("Dungeon.Secrets.Blood Rush", "Blood Rush Line Settings", "Line Settings to be used", "secret.lineproperties.bloodrush", false, SECRET_LINE_PROPERTIES_GLOBAL)); + SECRET_BLOOD_RUSH = register(new FeatureBloodRush()); + SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon.Secrets.Legacy AutoPathfind", "Auto Pathfind to new secret upon pressing a key", "Auto browse the best next secret when you press key.\nPress settings to edit the key", "secret.keyfornext", false) {{ + addParameter("key", new FeatureParameter("key", "Key", "Press to navigate to next best secret", Keyboard.KEY_NONE, "keybind")); + }}); + + EPIC_COUNTDOWN = register(new FeatureEpicCountdown()); + + RENDER_BREACONS = register(new SimpleFeature("Dungeon.Secrets.Preferences", "Render beacons", "Should the mod not render beacons on secret", "secret.beacons", false)); + DEBUG_BLOCK_CACHING = register(new SimpleFeature("Debug","Enable block getBlockCaching", "Cache all world.getBlockState callls", "debug.blockcache")); + RENDER_DESTENATION_TEXT = register(new SimpleFeature("Dungeon.Secrets.Preferences", "Render Destination text", "Should the mod not render \"destination\" on secrets", "secret.desttext", false)); + SECRET_AUTO_START = register(new SimpleFeature("Dungeon.Secrets.Legacy AutoPathfind", "Auto pathfind to new secret", "Auto browse best secret upon entering the room.", "secret.autouponenter", false)); + SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Dungeon.Secrets.Legacy AutoPathfind", "Auto Pathfind to next secret", "Auto browse best next secret after current one completes.\nthe first pathfinding of first secret needs to be triggered first in order for this option to work", "secret.autobrowse", false)); + BOSSFIGHT_WARNING_ON_PORTAL = register(new FeatureWarningOnPortal()); + BOSSFIGHT_CHESTPRICE = register(new FeatureChestPrice()); + BOSSFIGHT_AUTOREPARTY = register(new FeatureAutoReparty()); + BOSSFIGHT_HEALTH = register(new FeatureBossHealth()); + BOSSFIGHT_HIDE_ANIMALS = register(new FeatureHideAnimals()); + BOSSFIGHT_BEAR_PERCENT = register(new FeatureThornBearPercentage()); + BOSSFIGHT_BOW_TIMER = register(new FeatureThornSpiritBowTimer()); + BOSSFIGHT_BOX_REALLIVID = register(new FeatureBoxRealLivid()); + BOSSFIGHT_TERRACOTTA_TIMER = register(new FeatureTerracotaTimer()); + BOSSFIGHT_CURRENT_PHASE = register(new FeatureCurrentPhase()); + BOSSFIGHT_TERMINAL_SOLVERS = register(new FeatureTerminalSolvers()); + BOSSFIGHT_SIMONSAYS_SOLVER = register(new FeatureSimonSaysSolver()); + PARTYKICKER_APIKEY = register(new APIKey()); + PARTYKICKER_VIEWPLAYER = register(new FeatureViewPlayerStatsOnJoin()); + PARTYKICKER_CUSTOM = register(new FeatureCustomPartyFinder()); + PARTY_LIST = register(new FeaturePartyList()); + PARTY_READY = register(new FeaturePartyReady()); + ETC_DUNGEONSTAT = register(new FeatureTooltipDungeonStat()); + ETC_PRICE = register(new FeatureTooltipPrice()); + ETC_ABILITY_COOLDOWN = register(new FeatureAbilityCooldown()); + ETC_COOLDOWN = register(new FeatureCooldownCounter()); + ETC_REPARTY = register(new FeatureRepartyCommand()); + ETC_EXPLOSION_SOUND = register(new FeatureDecreaseExplosionSound()); + ETC_AUTO_ACCEPT_REPARTY = register(new FeatureAutoAcceptReparty()); + ETC_TEST = register(new FeatureUpdateAlarm()); + FIX_SPIRIT_BOOTS = register(new SimpleFeature("Misc", "Spirit Boots Fixer", "Fix Spirit boots messing up with inventory", "fixes.spirit", true)); + FIX_MESSAGES = register(new FeatureDisableMessage()); + ETC_COPY_MSG = register(new FeatureCopyMessages()); + ETC_PENGUIN = register(new FeaturePenguins()); + ETC_COLLECT_SCORE = register(new FeatureCollectScore()); + COSMETIC_NICKNAMECOLOR = register(new FeatureNicknameColor()); + COSMETIC_PREFIX = register(new FeatureNicknamePrefix()); + DISCORD_RICHPRESENCE = register(new SimpleFeature("Discord", "Discord RPC", "Enable Discord rich presence", "advanced.richpresence", true) { + { + addParameter("disablenotskyblock", new FeatureParameter("disablenotskyblock", "Disable When not on Skyblock", "Disable When not on skyblock", false, "boolean")); + } + }); + DISCORD_ASKTOJOIN = register(new PartyInviteViewer()); + DISCORD_ONLINEALARM = register(new PlayingDGAlarm()); + DISCORD_DONOTUSE = register(new SimpleFeature("Discord", "Disable Native Library", "Disables usage of jna for discord rpc support.\nBreaks any discord related feature in the mod.\nRequires mod restart to get affected.\n\nThis feature is only for those whose minecraft crashes due to discord gamesdk crash.", "discord.rpc", false)); + DEBUG = register(new FeatureDebug()); + ADVANCED_ROOMEDIT = register(new SimpleFeature("Debug", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false) { + { + addParameter("key", new FeatureParameter("key", "Key", "Press to edit room", Keyboard.KEY_R, "keybind")); + } + }); + ADVANCED_DEBUG_ROOM = register(new FeatureRoomDebugInfo()); + ADVANCED_DEBUGGABLE_MAP = register(new FeatureDebuggableMap()); + ADVANCED_COORDS = register(new FeatureRoomCoordDisplay()); + ADVANCED_BAT = register(new FeatureDebugTrap()); + } catch (Exception e) { + System.out.println(e); + throw new RuntimeException(e); + } + + + for (AbstractFeature abstractFeature : featureList) { + if(abstractFeature == null){ + throw new IllegalStateException("Feature " + abstractFeature.getKey() + " is null, this cannot happen!!!"); + } + } + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/GuiFeature.java new file mode 100644 index 00000000..c1d2a144 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/GuiFeature.java @@ -0,0 +1,160 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features; + +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.GuiConfigV2; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.mod.config.types.GUIRectangle; +import kr.syeyoung.dungeonsguide.mod.config.types.TypeConverterRegistry; +import kr.syeyoung.dungeonsguide.mod.features.listener.ScreenRenderListener; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +@Getter +public abstract class GuiFeature extends AbstractFeature implements ScreenRenderListener { + @Setter + private GUIRectangle featureRect; + @Setter(value = AccessLevel.PROTECTED) + private boolean keepRatio; + @Setter(value = AccessLevel.PROTECTED) + private double defaultWidth; + @Setter(value = AccessLevel.PROTECTED) + private double defaultHeight; + private final double defaultRatio; + + protected GuiFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { + super(category, name, description, key); + this.keepRatio = keepRatio; + this.defaultWidth = width; + this.defaultHeight = height; + this.defaultRatio = defaultWidth / defaultHeight; + this.featureRect = new GUIRectangle(0, 0, width, height); + } + + @Override + public void drawScreen(float partialTicks) { + if (!isEnabled()) return; + + GlStateManager.pushMatrix(); + Rectangle featureRect = this.featureRect.getRectangleNoScale(); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GlStateManager.scale(1.0/scaledResolution.getScaleFactor(), 1.0/scaledResolution.getScaleFactor(), 1); + clip(featureRect.x, featureRect.y, featureRect.width, featureRect.height); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + GlStateManager.translate(featureRect.x, featureRect.y, 0); + drawHUD(partialTicks); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + GlStateManager.popMatrix(); + + + GlStateManager.enableBlend(); + GlStateManager.color(1,1,1,1); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + + + public abstract void drawHUD(float partialTicks); + + public void drawDemo(float partialTicks) { + drawHUD(partialTicks); + } + + private void clip(int x, int y, int width, int height) { +// int scale = resolution.getScaleFactor(); + int scale = 1; + GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); + } + + public static FontRenderer getFontRenderer() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + return fr; + } + + @Override + public void loadConfig(JsonObject jsonObject) { + super.loadConfig(jsonObject); + this.featureRect = TypeConverterRegistry.getTypeConverter("guirect",GUIRectangle.class).deserialize(jsonObject.get("$bounds")); + } + + @Override + public JsonObject saveConfig() { + JsonObject object = super.saveConfig(); + object.add("$bounds", TypeConverterRegistry.getTypeConverter("guirect", GUIRectangle.class).serialize(featureRect)); + return object; + } + + public List getTooltipForEditor(GuiGuiLocationConfig guiGuiLocationConfig) { + ArrayList mPanels = new ArrayList<>(); + mPanels.add(new MLabel(){ + { + setText(getName()); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(Minecraft.getMinecraft().fontRendererObj.getStringWidth(getName()), 20); + } + }); + mPanels.add(new MButton() { + { + setText("Edit"); + setOnActionPerformed(() -> { + GuiScreen guiScreen = guiGuiLocationConfig.getBefore(); + if (guiScreen == null) { + guiScreen = new GuiConfigV2(); + } + Minecraft.getMinecraft().displayGuiScreen(guiScreen); + if (guiScreen instanceof GuiConfigV2) { + ((GuiConfigV2) guiScreen).getRootConfigPanel().setCurrentPageAndPushHistory(getEditRoute(((GuiConfigV2) guiScreen).getRootConfigPanel())); + } + }); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(100,20); + } + }); + mPanels.add(new MPassiveLabelAndElement("Enabled", new MToggleButton() {{ + setEnabled(GuiFeature.this.isEnabled()); + setOnToggle(() ->{ + GuiFeature.this.setEnabled(isEnabled()); + }); } + })); + return mPanels; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/SimpleFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/SimpleFeature.java new file mode 100644 index 00000000..b8d20c5c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/SimpleFeature.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features; + +public class SimpleFeature extends AbstractFeature { + protected SimpleFeature(String category, String name, String key) { + this(category, name, name, key); + } + protected SimpleFeature(String category, String name, String description, String key) { + this(category, name, description, key, true); + } + + protected SimpleFeature(String category, String name, String description, String key, boolean enabled) { + super(category, name, description, key); + this.setEnabled(enabled); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebug.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebug.java new file mode 100644 index 00000000..486ac05b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebug.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; + +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureDebug extends SimpleFeature { + + public FeatureDebug() { + super("Debug", "Debug", "Toggles debug mode", "debug", false); + + } + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebugTrap.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebugTrap.java new file mode 100644 index 00000000..92a47949 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebugTrap.java @@ -0,0 +1,80 @@ +package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureDebugTrap extends TextHUDFeature { + public FeatureDebugTrap() { + super("Debug", "Display the current amount of bat entities", "", "advanced.bat", false, getFontRenderer().getStringWidth("Bats: 9999"), getFontRenderer().FONT_HEIGHT); + getStyles().add(new TextStyle("base", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("batsamm", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + private static final List dummyText= new ArrayList<>(); + static { + dummyText.add(new StyledText("Bats: ","base")); + dummyText.add(new StyledText("9999","batsamm")); + } + + + static List avgStorage = new ArrayList<>(); + + public static void updateVal(long timeItTookForThePacketToProcess){ + System.out.println(timeItTookForThePacketToProcess); + if(avgStorage.size() > 5){ + avgStorage.remove( 0); + } + + avgStorage.add(timeItTookForThePacketToProcess); + } + + + static long getAvgTimeItTookToPAcket(){ + return (long) avgStorage.stream().mapToLong(val -> val).average().orElse(0.0); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getMapProcessor() != null; + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("batsamm", "base"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public List getText() { + + List bats = Minecraft.getMinecraft().theWorld.getEntities(EntityBat.class, e -> true); + + + List actualBit = new ArrayList<>(); + actualBit.add(new StyledText("Bats: ","base")); + + + actualBit.add(new StyledText(String.valueOf(getAvgTimeItTookToPAcket()),"batsamm")); + + return actualBit; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebuggableMap.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebuggableMap.java new file mode 100644 index 00000000..7501561e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDebuggableMap.java @@ -0,0 +1,88 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.utils.MapUtils; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.config.GuiUtils; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.Arrays; + +public class FeatureDebuggableMap extends GuiFeature { + public FeatureDebuggableMap() { + super("Debug", "Display Debug Info included map", "ONLY WORKS WITH SECRET SETTING", "advanced.debug.map", true, 128, 128); + this.setEnabled(false); + } + + + DynamicTexture dynamicTexture = new DynamicTexture(128, 128); + ResourceLocation location = Minecraft.getMinecraft().renderEngine.getDynamicTextureLocation("dungeons/map/", dynamicTexture); + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public void drawHUD(float partialTicks) { +// if (!skyblockStatus.isOnDungeon()) return; + if (!FeatureRegistry.DEBUG.isEnabled()) return; +// DungeonContext context = skyblockStatus.getContext(); +// if (context == null) return; + + GlStateManager.pushMatrix(); + double factor = getFeatureRect().getRectangle().getWidth() / 128; + GlStateManager.scale(factor, factor, 1); + int[] textureData = dynamicTexture.getTextureData(); + MapUtils.getImage().getRGB(0, 0, 128, 128, textureData, 0, 128); + dynamicTexture.updateDynamicTexture(); + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + GlStateManager.enableAlpha(); + GuiScreen.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 128, 128, 128, 128); + GlStateManager.popMatrix(); + + + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) return; + Rectangle featureRect = this.getFeatureRect().getRectangleNoScale(); + + int i = (int) ((int) (Mouse.getEventX() - featureRect.getX()) / factor); + int j = (int) ((int) (Minecraft.getMinecraft().displayHeight - Mouse.getEventY() - featureRect.getY())/ factor); + if (i >= 0 && j>= 0 && i <= 128 && j <= 128 && MapUtils.getColors() != null) { + GuiUtils.drawHoveringText(Arrays.asList(i+","+j,"Color: "+MapUtils.getColors()[j * 128 + i]),(int)(Mouse.getEventX() - featureRect.getX()), (int) (Minecraft.getMinecraft().displayHeight - Mouse.getEventY() - featureRect.getY()), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, -1, Minecraft.getMinecraft().fontRendererObj); + } + } + + @Override + public void drawDemo(float partialTicks) { + FontRenderer fr = getFontRenderer(); + Rectangle featureRect = getFeatureRect().getRectangle(); + GL11.glLineWidth(2); + RenderUtils.drawUnfilledBox(0,0,featureRect.width, featureRect.height, 0xff000000, false); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomCoordDisplay.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomCoordDisplay.java new file mode 100644 index 00000000..87f41e93 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomCoordDisplay.java @@ -0,0 +1,94 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.BlockPos; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +public class FeatureRoomCoordDisplay extends GuiFeature { + public FeatureRoomCoordDisplay() { + super("Debug", "Display Coordinate Relative to the Dungeon Room and room's rotation", "X: 0 Y: 3 Z: 5 Facing: Z+" , "advanced.coords", false, getFontRenderer().getStringWidth("X: 48 Y: 100 Z: 48 Facing: Z+"), 10); + this.setEnabled(false); + addParameter("color", new FeatureParameter<>("color", "Color", "Color of text", Color.yellow, "color", nval -> color = nval.getRGB())); + } + + + int color = 0; + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + private static final String[] facing = {"Z+", "X-", "Z-", "X+"}; + @Override + public void drawHUD(float partialTicks) { + if (!skyblockStatus.isOnDungeon()) return; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) return; + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom == null) { + return; + } + + int facing = (int) (thePlayer.rotationYaw + 45) % 360; + if (facing < 0) facing += 360; + int real = (facing / 90 + dungeonRoom.getRoomMatcher().getRotation()) % 4; + + OffsetPoint offsetPoint = new OffsetPoint(dungeonRoom, new BlockPos((int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ)); + + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + double scale = getFeatureRect().getRectangle().getHeight() / fontRenderer.FONT_HEIGHT; + GlStateManager.scale(scale, scale, 0); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fontRenderer.drawString("X: "+offsetPoint.getX()+" Y: "+offsetPoint.getY()+" Z: "+offsetPoint.getZ()+" Facing: "+ FeatureRoomCoordDisplay.facing[real], 0, 0, color); + } + + @Override + public void drawDemo(float partialTicks) { + FontRenderer fr = getFontRenderer(); + int facing = (int) (Minecraft.getMinecraft().thePlayer.rotationYaw + 45) % 360; + if (facing < 0) facing += 360; + double scale = getFeatureRect().getRectangle().getHeight() / fr.FONT_HEIGHT; + GlStateManager.scale(scale, scale, 0); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("X: 0 Y: 3 Z: 5 Facing: "+FeatureRoomCoordDisplay.facing[(facing / 90) % 4], 0,0, this.getParameter("color").getValue().getRGB()); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomDebugInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomDebugInfo.java new file mode 100644 index 00000000..0e983e88 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureRoomDebugInfo.java @@ -0,0 +1,95 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import org.apache.commons.lang3.StringUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +public class FeatureRoomDebugInfo extends GuiFeature { + public FeatureRoomDebugInfo() { + super("Debug", "Display Room Debug Info", "ONLY WORKS WITH SECRET SETTING", "advanced.debug.roominfo", false, getFontRenderer().getStringWidth("longestplayernamepos: 100"), getFontRenderer().FONT_HEIGHT * 6); + this.setEnabled(false); + addParameter("color", new FeatureParameter("color", "Color", "Color of text", Color.white, "color", nval -> color = nval.getRGB())); + } + + int color = 0; + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public void drawHUD(float partialTicks) { + if (!skyblockStatus.isOnDungeon()) return; + if (!FeatureRegistry.DEBUG.isEnabled()) return; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) return; + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (dungeonRoom == null) { + if (context.getBossfightProcessor() == null) { + fontRenderer.drawString("Where are you?!", 0, 0, 0xFFFFFF); + } else { + fontRenderer.drawString("You're prob in bossfight", 0, 0, color); + fontRenderer.drawString("processor: "+context.getBossfightProcessor(), 0, 10, color); + fontRenderer.drawString("phase: "+context.getBossfightProcessor().getCurrentPhase(), 0, 20, color); + fontRenderer.drawString("nextPhase: "+ StringUtils.join(context.getBossfightProcessor().getNextPhases(), ","), 0, 30, color); + fontRenderer.drawString("phases: "+ StringUtils.join(context.getBossfightProcessor().getPhases(), ","), 0, 40, color); + } + } else { + fontRenderer.drawString("you're in the room... color/shape/rot " + dungeonRoom.getColor() + " / " + dungeonRoom.getShape() + " / "+dungeonRoom.getRoomMatcher().getRotation(), 0, 0, color); + fontRenderer.drawString("room uuid: " + dungeonRoom.getDungeonRoomInfo().getUuid() + (dungeonRoom.getDungeonRoomInfo().isRegistered() ? "" : " (not registered)"), 0, 10, color); + fontRenderer.drawString("room name: " + dungeonRoom.getDungeonRoomInfo().getName(), 0, 20, color); + fontRenderer.drawString("room state / max secret: " + dungeonRoom.getCurrentState() + " / "+dungeonRoom.getTotalSecrets(), 0, 30, color); + + } + } + + @Override + public void drawDemo(float partialTicks) { + FontRenderer fr = getFontRenderer(); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Line 1", 0,0, color); + fr.drawString("Line 2", 0,10, color); + fr.drawString("Line 3", 0,20, color); + fr.drawString("Line 4", 0,30, color); + fr.drawString("Line 5", 0,40, color); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureTestPepole.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureTestPepole.java new file mode 100644 index 00000000..cc2f911a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureTestPepole.java @@ -0,0 +1,460 @@ +package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonStartListener; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.stomp.StompManager; +import kr.syeyoung.dungeonsguide.mod.stomp.StompPayload; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.texture.ITextureObject; +import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.client.resources.SkinManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.relauncher.ReflectionHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.json.JSONObject; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.regex.Pattern; + +import static kr.syeyoung.dungeonsguide.mod.utils.TabListUtil.getString; + +public class FeatureTestPepole extends GuiFeature implements ChatListener, DungeonStartListener { + + Logger logger = LogManager.getLogger("FeatureTestPepole"); + private Float scale; + private Set lastmebersRaw; + private boolean broadcastLock; + + public FeatureTestPepole() { + super("Dungeon", "Feuture test", "NOU", "", false, 200, 100); + + + addParameter("scale", new FeatureParameter<>("scale", "Scale", "Scale", 2.0f, "float", nval -> this.scale = nval)); + MinecraftForge.EVENT_BUS.register(this); + +// (new Thread(() -> { +// while (true){ +// handleSelfBroadcasts(); +// } +// }) ).start(); + } + + public static void handlePartyBroadCast(String playload) { + String[] messagge = playload.substring(2).split(":"); + +// String random = messagge[1]; + String username = messagge[0]; + System.out.println("Broadcast was a self broadcast with: " + username); + PartyManager.INSTANCE.getPartyContext().addDgUser(username); + +// String actualPayload = "ACK" + random + ":" + username + ":" + Minecraft.getMinecraft().getSession().getUsername(); +// StompManager.getInstance().send(new StompPayload().header("destination", "/app/party.broadcast").payload( +// new JSONObject().put("partyID", PartyManager.INSTANCE.getPartyContext().getPartyID()) +// .put("payload", actualPayload).toString() +// )); + +// } else if (playload.startsWith("ACK")){ +// String ACKnick = playload.substring(3); +// String[] nicks = ACKnick.split(":"); +// if(Objects.equals(nicks[0], Minecraft.getMinecraft().getSession().getUsername())) { +// FeatureTestPepole.addACK(new Tuple(nicks[1], nicks[2])); +// } + } + +// static List> acknicks = new ArrayList<>(); +// +// static List> sentContros = new ArrayList<>(); + +// public static void addACK(Tuple acKnick) { +// acknicks.add(acKnick); +// } + + public void broadcastYourself() { + if (PartyManager.INSTANCE.getPartyContext().getPartyID() == null) { + return; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + logger.info("Sending self broadcast"); +// int control = (new Random()).nextInt(1000); + String actualPayload = "C:" + Minecraft.getMinecraft().getSession().getUsername() + ":" + 222; + StompManager.getInstance().send(new StompPayload().header("destination", "/app/party.broadcast").payload( + new JSONObject().put("partyID", PartyManager.INSTANCE.getPartyContext().getPartyID()) + .put("payload", actualPayload).toString() + )); +// sentContros.add(new Tuple<>(control, System.currentTimeMillis())); + broadcastLock = false; + } + + public void handleSelfBroadcasts(){ + if(broadcastLock) { + broadcastYourself(); + return; + } + + +// for (Tuple acknick : acknicks) { +// int a = Integer.parseInt(acknick.getFirst()); +// for (Tuple sentContro : sentContros) { +// if(sentContro.getFirst() == a){ +// acknicks.remove(acknick); +// sentContros.remove(a); +// if(sentContro.getSecond() + 500 > System.currentTimeMillis()){ +// broadcastLock = true; +// broadcastYourself(); +// break; +// } +// } +// } +// +// } + + + if(PartyManager.INSTANCE.getPartyContext() == null) return; + + if(lastmebersRaw == null ) { + lastmebersRaw = PartyManager.INSTANCE.getPartyContext().getPartyRawMembers(); + return; + } + + Set membersRaw = PartyManager.INSTANCE.getPartyContext().getPartyRawMembers(); + + if(!membersRaw.equals(lastmebersRaw)){ + logger.info("members changed unlocking locking broadcast"); + broadcastLock = true; + broadcastYourself(); + lastmebersRaw = membersRaw; + } + } + + + HashMap SkullCashe = new HashMap<>(); + + + + ExecutorService executor = Executors.newFixedThreadPool(5); + + + public ItemStack getSkullByUserName(String username) { + if (SkullCashe.containsKey(username)) return SkullCashe.get(username); + ItemStack stack = new ItemStack(Items.skull, 1, 3); + + executor.submit(() -> { + EntityPlayer playerEntityByName = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(username); + if(playerEntityByName == null || playerEntityByName.getGameProfile() == null) { + stack.setTagCompound(new NBTTagCompound()); + stack.getTagCompound().setTag("SkullOwner", new NBTTagString(username)); + return; + } + + // this line should trick mineshaft to caching the player skin + // im doing this bc just setting SkullOwner downloads the skin on main thread + // thus causing a lag spike + Map map = Minecraft.getMinecraft().getSkinManager().loadSkinFromCache(playerEntityByName.getGameProfile()); + + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { + Minecraft.getMinecraft().getSkinManager().loadSkin((MinecraftProfileTexture)map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN); + } + + + + stack.setTagCompound(new NBTTagCompound()); + stack.getTagCompound().setTag("SkullOwner", new NBTTagString(username)); + + }); + + SkullCashe.put(username, stack); + return stack; + } + + private Set ready = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + + private static final List readyPhrase = Arrays.asList("r", "rdy", "ready"); + private static final List negator = Arrays.asList("not ", "not", "n", "n "); + private static final Map readynessIndicator = new HashMap<>(); + + static { + readyPhrase.forEach(val -> readynessIndicator.put(val, true)); + for (String s : negator) { + readyPhrase.forEach(val -> readynessIndicator.put(s + val, false)); + } + readynessIndicator.put("dont start", false); + readynessIndicator.put("don't start", false); + readynessIndicator.put("dont go", false); + readynessIndicator.put("don't go", false); + readynessIndicator.put("start", true); + readynessIndicator.put("go", true); + } + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + String txt = clientChatReceivedEvent.message.getFormattedText(); + if (!txt.startsWith("ยงrยง9Party ยง8>")) return; + + String chat = TextUtils.stripColor(txt.substring(txt.indexOf(":") + 1)).trim().toLowerCase(); + + + String usernamearea = TextUtils.stripColor(txt.substring(13, txt.indexOf(":"))); + String username = null; + for (String s : usernamearea.split(" ")) { + if (s.isEmpty()) continue; + if (s.startsWith("[")) continue; + username = s; + break; + } + + Boolean status = null; + String longestMatch = ""; + for (Map.Entry stringBooleanEntry : readynessIndicator.entrySet()) { + if (chat.startsWith(stringBooleanEntry.getKey()) || chat.endsWith(stringBooleanEntry.getKey()) || (stringBooleanEntry.getKey().length() >= 3 && chat.contains(stringBooleanEntry.getKey()))) { + if (stringBooleanEntry.getKey().length() > longestMatch.length()) { + longestMatch = stringBooleanEntry.getKey(); + status = stringBooleanEntry.getValue(); + } + } + } + if (status == null) ; + else if (status) ready.add(username); + else ready.remove(username); + + } + + @Override + public void onDungeonStart() { + ready.clear(); + } + + boolean isAloneInParty() { + if (PartyManager.INSTANCE.getPartyContext() != null) { + return PartyManager.INSTANCE.getPartyContext().getPartyRawMembers().size() == 1; + } + return false; + } + + final Pattern tabListRegex = Pattern.compile("\\*[a-zA-Z0-9_]{2,16}\\*", Pattern.MULTILINE); + + /** + * We regex their name out + * @param networkPlayerInfo the network player info of player + * @return the username of player + */ + private String getPlayerNameWithChecks(NetworkPlayerInfo networkPlayerInfo) { + String name; + if (networkPlayerInfo.getDisplayName() != null) { + name = networkPlayerInfo.getDisplayName().getFormattedText(); + } else { + name = ScorePlayerTeam.formatPlayerName( + networkPlayerInfo.getPlayerTeam(), + networkPlayerInfo.getGameProfile().getName() + ); + } + + if (name.trim().equals("ยงr") || name.startsWith("ยงr ")) return null; + + name = TextUtils.stripColor(name); + + return getString(name, tabListRegex); + } + + boolean isPlayerInDungeon(String username) { + + List list = new ArrayList<>(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); + + // 19 iterations bc we only want to scan the player part of tab list + for (int i = 1; i < 20; i++) { + if(list.size() < i) break; + NetworkPlayerInfo networkPlayerInfo = list.get(i); + + String name = getPlayerNameWithChecks(networkPlayerInfo); + if (name == null) continue; + + EntityPlayer entityplayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(name); + + + if (entityplayer != null && (!entityplayer.isInvisible())) { + if (name == username) return true; + } + + + } + return false; + } + + + public final Map cachedProfiles = new HashMap<>(); + + + void renderItem(GameProfile stack, int x, int y){ + + +// GameProfile a = new GameProfile(); + + GameProfile toDraw = cachedProfiles.get(stack.getName()) ? stack : null; + + TileEntitySkullRenderer.instance.renderSkull(x, y, -0.5F, EnumFacing.UP, 180.0F, 1, stack, -1); + + if(toDraw == null && !cachedProfiles.containsKey(stack.getName())){ + cachedProfiles.put(stack.getName(), false); + new Thread(() -> { + Map map = Minecraft.getMinecraft().getSkinManager().loadSkinFromCache(stack); + + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { + + MinecraftProfileTexture profileTexture = map.get(MinecraftProfileTexture.Type.SKIN); + + final ResourceLocation resourceLocation = new ResourceLocation("skins/" + profileTexture.getHash()); + ITextureObject iTextureObject = Minecraft.getMinecraft().getTextureManager().getTexture(resourceLocation); + if (iTextureObject == null) { + + String skinCacheDir = ReflectionHelper.getPrivateValue(SkinManager.class, Minecraft.getMinecraft().getSkinManager(), "field_152796_d", "skinCacheDir"); + + File file = new File(skinCacheDir, profileTexture.getHash().length() > 2 ? profileTexture.getHash().substring(0, 2) : "xx"); + File file2 = new File(file, profileTexture.getHash()); + final IImageBuffer iImageBuffer = new ImageBufferDownload(); + ThreadDownloadImageData threadDownloadImageData = new ThreadDownloadImageData(file2, profileTexture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer() { + + public BufferedImage parseUserSkin(BufferedImage image) { + if (iImageBuffer != null) { + image = iImageBuffer.parseUserSkin(image); + } + + return image; + } + + public void skinAvailable() { + if (iImageBuffer != null) { + iImageBuffer.skinAvailable(); + } + } + }); + Minecraft.getMinecraft().getTextureManager().loadTexture(resourceLocation, threadDownloadImageData); + } + } + + cachedProfiles.replace(stack.getName(), true); + }).start(); + } + + + + } + + @Override + public void drawHUD(float partialTicks) { + + if (PartyManager.INSTANCE.getPartyContext() == null) return; + if (!PartyManager.INSTANCE.getPartyContext().isPartyExistHypixel()) return; +// if(isAloneInParty()) return; + + ResourceLocation logoLoc = new ResourceLocation("dungeonsguide:textures/dglogox32.png"); + + FontRenderer fr = getFontRenderer(); + + + int y = 0; + for (String partyRawMember : PartyManager.INSTANCE.getPartyContext().getPartyRawMembers()) { + + boolean isDgUser = isDgUser(partyRawMember); + + int xOffset = isDgUser ? 9 : -2; + + GlStateManager.pushMatrix(); + + + GlStateManager.scale(scale, scale, 1F); + + Gui.drawRect(15 + xOffset, 5 + y, fr.getStringWidth(partyRawMember + genPlayerText(partyRawMember)) + 20 + xOffset, 15 + y, getColorTextColor(partyRawMember)); + + RenderHelper.enableStandardItemLighting(); + renderItem(Minecraft.getMinecraft().theWorld.getPlayerEntityByName(partyRawMember).getGameProfile(), 0, y + 1); +// Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(getSkullByUserName(partyRawMember), 0, y + 1); + RenderHelper.disableStandardItemLighting(); + + fr.drawString(partyRawMember, 15 + xOffset, y + 5, 0xffffff); + + + fr.drawString(genPlayerText(partyRawMember), 16 + fr.getStringWidth(partyRawMember) + xOffset, y + 5, 0xf9f9fa); + + if (isDgUser) { + + GlStateManager.translate(xOffset + 5, y + 3.5F, 200F); + GlStateManager.scale(0.32F, 0.32F, 1F); + Minecraft.getMinecraft().getTextureManager().bindTexture(logoLoc); + Gui.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 32, 32, 32, 32); + } + + + GlStateManager.popMatrix(); + + y += 12; + } + + } + + private boolean isDgUser(String partyRawMember) { + if (Objects.equals(partyRawMember, Minecraft.getMinecraft().getSession().getUsername())) return true; + return PartyManager.INSTANCE.getPartyContext().isDgUser(partyRawMember); + } + + + private int getColorTextColor(String partyRawMember) { + if (Objects.equals(genPlayerText(partyRawMember), ": Ready") || Objects.equals(genPlayerText(partyRawMember), ": Not Ready")) { + boolean isPlayerReady = ready.contains(partyRawMember); + return isPlayerReady ? 0xFF12bc00 : 0xFFd70022; + } + + + return 0xFF38383d; + } + + + String genPlayerText(String username) { + + if (DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) { + if (Objects.equals(username, Minecraft.getMinecraft().getSession().getUsername())) { + return ": In Dungeon"; + } else if (isPlayerInDungeon(username)) { + return ": In Dungeon"; + } else { + return ": Somewhere"; + } + } else { + if (ready.contains(username)) { + return ": Ready"; + } + + return ": Not Ready"; + } + } + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureAutoReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureAutoReparty.java new file mode 100644 index 00000000..8ac55d88 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureAutoReparty.java @@ -0,0 +1,34 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonQuitListener; + +public class FeatureAutoReparty extends SimpleFeature implements DungeonQuitListener { + public FeatureAutoReparty() { + super("Party.Reparty", "Auto reparty when dungeon finishes","Auto reparty on dungeon finish\n\nThis automates player chatting action, (disbanding, repartying) Thus it might be against hypixel's rules.\nBut mods like auto-gg exist so I'm leaving this feature.\nThis option is use-at-your-risk and you'll be responsible for ban if you somehow get banned because of this feature\n(Although it is not likely to happen)\nDefaults to off", "party.autoreparty", false); + } + + @Override + public void onDungeonQuit() { + if (isEnabled()) DungeonsGuide.getDungeonsGuide().getCommandReparty().requestReparty(true); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBossHealth.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBossHealth.java new file mode 100644 index 00000000..02ec1a87 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBossHealth.java @@ -0,0 +1,104 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.HealthData; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureBossHealth extends TextHUDFeature { + public FeatureBossHealth() { + super("Dungeon.Bossfight", "Display Boss(es) Health", "Show the health of boss and minibosses in bossfight (Guardians, Priests..)", "bossfight.health", false, getFontRenderer().getStringWidth("The Professor: 4242m"), getFontRenderer().FONT_HEIGHT * 5); + this.setEnabled(true); + addParameter("totalHealth", new FeatureParameter("totalHealth", "show total health", "Show total health along with current health", false, "boolean", nval -> totalHealth = nval)); + addParameter("formatHealth", new FeatureParameter("formatHealth", "format health", "1234568 -> 1m", true, "boolean", nval -> formatHealth = nval)); + addParameter("ignoreInattackable", new FeatureParameter("ignoreInattackable", "Don't show health of in-attackable enemy", "For example, do not show guardians health when they're not attackable", false, "boolean", nval -> ignoreInattackable = nval)); + + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("health", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("maxHealth", new AColor(0x55, 0x55,0xFF,255), new AColor(0, 0,0,0), false)); + } + + + boolean totalHealth; + boolean formatHealth; + boolean ignoreInattackable; + + + + @Override + public boolean doesScaleWithHeight() { + return false; + } + + @Override + public boolean isHUDViewable() { + return SkyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() != null; + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("title", "separator", "health", "separator2", "maxHealth"); + } + + @Override + public java.util.List getDummyText() { + List actualBit = new ArrayList(); + addLine(new HealthData("The Professor", 3300000, 5000000, false), actualBit); + addLine(new HealthData("Chaos Guardian", 500000, 2000000, true), actualBit); + addLine(new HealthData("Healing Guardian", 1000000, 3000000, true), actualBit); + addLine(new HealthData("Laser Guardian", 5000000, 5000000, true), actualBit); + addLine(new HealthData("Giant", 10000000, 20000000, false), actualBit); + return actualBit; + } + + public void addLine(HealthData data, List actualBit) { + if (ignoreInattackable && !data.isAttackable()) return; + + actualBit.add(new StyledText(data.getName(),"title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText( (formatHealth ? TextUtils.format(data.getHealth()) : data.getHealth()) + (totalHealth ? "" : "\n"),"health")); + if (totalHealth) { + actualBit.add(new StyledText("/", "separator2")); + actualBit.add(new StyledText( (formatHealth ? TextUtils.format(data.getMaxHealth()) : data.getMaxHealth()) +"\n","maxHealth")); + } + } + + @Override + public java.util.List getText() { + List actualBit = new ArrayList(); + List healths = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor().getHealths(); + for (HealthData heal : healths) { + addLine(heal, actualBit); + } + return actualBit; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBoxRealLivid.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBoxRealLivid.java new file mode 100644 index 00000000..18be868c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureBoxRealLivid.java @@ -0,0 +1,54 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorLivid; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.util.AxisAlignedBB; + + +public class FeatureBoxRealLivid extends SimpleFeature implements WorldRenderListener { + public FeatureBoxRealLivid() { + super("Dungeon.Bossfight.Floor 5", "Box Real Livid", "Box Real Livid in bossfight", "Dungeon.Bossfight.realLividBox", true); + addParameter("color", new FeatureParameter("color", "Highlight Color", "Highlight Color of Livid", new AColor(0,255,0,150), "acolor", nval -> color = nval)); + } + + AColor color = null; + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + if (!skyblockStatus.isOnDungeon()) return; + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() == null) return; + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() == null) return; + if (!(DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorLivid)) return; + EntityOtherPlayerMP playerMP = ((BossfightProcessorLivid) DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor()).getRealLivid(); + + if (playerMP != null) + RenderUtils.highlightBox(playerMP, AxisAlignedBB.fromBounds(-0.4,0,-0.4,0.4,1.8,0.4), color, partialTicks, true); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureChestPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureChestPrice.java new file mode 100644 index 00000000..ba5043fe --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureChestPrice.java @@ -0,0 +1,174 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.GuiBackgroundRenderListener; +import kr.syeyoung.dungeonsguide.mod.utils.AhUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.client.event.GuiScreenEvent; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.util.Comparator; +import java.util.Set; +import java.util.TreeSet; + +public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRenderListener { + public FeatureChestPrice() { + super("Dungeon", "Show Profit of Dungeon Reward Chests","Show Profit of Dungeon Chests", "bossfight.profitchest", false); + } + + @Override + public void onGuiBGRender(GuiScreenEvent.BackgroundDrawnEvent rendered) { + if (!isEnabled()) return; + if (!(rendered.gui instanceof GuiChest)) return; + if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + + GlStateManager.disableLighting(); + + ContainerChest chest = (ContainerChest) ((GuiChest) rendered.gui).inventorySlots; + if (!chest.getLowerChestInventory().getName().endsWith("Chest")) return; + IInventory actualChest = chest.getLowerChestInventory(); + + int chestPrice = 0; + int itemPrice = 0; + for (int i = 0; i 0) { + for (int j1 = 0; j1 < nbttaglist1.tagCount(); ++j1) { + String str = nbttaglist1.getStringTagAt(j1); + if (str.endsWith("Coins")) { + String coins = TextUtils.stripColor(str).replace(" Coins", "").replace(",",""); + try { + chestPrice = Integer.parseInt(coins); + } catch (Exception e) { + + } + } + } + } + } + } + } + itemPrice += getPrice(item) * item.stackSize; + } + } + + int i = 222; + int j = i - 108; + int ySize = j + (actualChest.getSizeInventory() / 9) * 18; + int left = (rendered.gui.width + 176) / 2; + int top = (rendered.gui.height - ySize ) / 2; + + int width = 120; + + GlStateManager.pushMatrix(); + GlStateManager.translate(left, top, 0); + Gui.drawRect( 0,0,width, 30, 0xFFDDDDDD); + + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("BIN/AH Price: ", 5,5, 0xFF000000); + String str = TextUtils.format(itemPrice); + fr.drawString(str, width - fr.getStringWidth(str) - 5, 5, 0xFF000000); + + fr.drawString("Profit: ", 5,15, 0xFF000000); + str = (itemPrice > chestPrice ? "+" : "") +TextUtils.format(itemPrice - chestPrice); + fr.drawString(str, width - fr.getStringWidth(str) - 5, 15, itemPrice > chestPrice ? 0xFF00CC00 : 0xFFCC0000); + + GlStateManager.popMatrix(); + + GlStateManager.enableLighting(); + GlStateManager.enableBlend(); + } + + public static long getPrice(ItemStack itemStack) { + if (itemStack == null) return 0; + NBTTagCompound compound = itemStack.getTagCompound(); + if (compound == null) + return 0; + if (!compound.hasKey("ExtraAttributes")) + return 0; + final String id = compound.getCompoundTag("ExtraAttributes").getString("id"); + if (id.equals("ENCHANTED_BOOK")) { + final NBTTagCompound enchants = compound.getCompoundTag("ExtraAttributes").getCompoundTag("enchantments"); + Set keys = enchants.getKeySet(); + Set actualKeys = new TreeSet(new Comparator() { + public int compare(String o1, String o2) { + String id2 = id + "::" + o1 + "-" + enchants.getInteger(o1); + AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); + long price1 = (auctionData == null) ? 0 : auctionData.lowestBin; + String id3 = id + "::" + o2 + "-" + enchants.getInteger(o2); + AhUtils.AuctionData auctionData2 = AhUtils.auctions.get(id3); + long price2 = (auctionData2 == null) ? 0 : auctionData2.lowestBin; + return (compare2(price1, price2) == 0) ? o1.compareTo(o2) : compare2(price1, price2); + } + + public int compare2(long y, long x) { + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } + }); + actualKeys.addAll(keys); + int totalLowestPrice = 0; + for (String key : actualKeys) { + String id2 = id + "::" + key + "-" + enchants.getInteger(key); + AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); + totalLowestPrice += auctionData.lowestBin; + } + return totalLowestPrice; + } else { + AhUtils.AuctionData auctionData = AhUtils.auctions.get(id); + if (auctionData == null) { + return 0; + } else { + if (auctionData.sellPrice == -1 && auctionData.lowestBin != -1) return auctionData.lowestBin; + else if (auctionData.sellPrice != -1 && auctionData.lowestBin == -1) return auctionData.sellPrice; + else { + long ahPrice = auctionData.lowestBin; + if (ahPrice > auctionData.sellPrice) return ahPrice; + else return auctionData.sellPrice; + } + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureCurrentPhase.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureCurrentPhase.java new file mode 100644 index 00000000..f1a32868 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureCurrentPhase.java @@ -0,0 +1,74 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureCurrentPhase extends TextHUDFeature { + public FeatureCurrentPhase() { + super("Dungeon.Bossfight", "Display Current Phase", "Displays the current phase of bossfight", "bossfight.phasedisplay", false, getFontRenderer().getStringWidth("Current Phase: fight-2-idk-howlng"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(true); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("phase", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Current Phase","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("fight-2","phase")); + } + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() != null; + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("title", "separator", "phase"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public List getText() { + String currentPhsae = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor().getCurrentPhase(); + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Current Phase","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(currentPhsae,"phase")); + return actualBit; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureHideAnimals.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureHideAnimals.java new file mode 100644 index 00000000..d946ae39 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureHideAnimals.java @@ -0,0 +1,76 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.EntityLivingRenderListener; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorThorn; +import net.minecraft.entity.passive.*; +import net.minecraftforge.client.event.RenderLivingEvent; + + +public class FeatureHideAnimals extends SimpleFeature implements EntityLivingRenderListener { + public FeatureHideAnimals() { + super("Dungeon.Bossfight.Floor 4", "Hide animals on f4", "Hide Spirit Animals on F4. \nClick on Edit for precise setting", "bossfight.hideanimals", false); + addParameter("sheep", new FeatureParameter("sheep", "Hide Sheeps", "Hide Sheeps", true, "boolean", nval -> sheep = nval)); + addParameter("cow", new FeatureParameter("cow", "Hide Cows", "Hide Cows", true, "boolean", nval -> cow = nval)); + addParameter("chicken", new FeatureParameter("chicken", "Hide Chickens", "Hide Chickens", true, "boolean", nval -> chicken = nval)); + addParameter("wolf", new FeatureParameter("wolf", "Hide Wolves", "Hide Wolves", true, "boolean", nval -> wolf = nval)); + addParameter("rabbit", new FeatureParameter("rabbit", "Hide Rabbits", "Hide Rabbits", true, "boolean", nval -> rabbit = nval)); + } + + boolean sheep; + boolean cow; + boolean chicken; + boolean wolf; + boolean rabbit; + + + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + @Override + public void onEntityRenderPre(RenderLivingEvent.Pre renderPlayerEvent) { + if (!isEnabled()) return; + if (!skyblockStatus.isOnDungeon()) return; + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() == null) return; + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() == null) return; + if (!(DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorThorn)) return; + + if (renderPlayerEvent.entity instanceof EntitySheep && sheep) { + renderPlayerEvent.setCanceled(true); + } else if (renderPlayerEvent.entity instanceof EntityCow && cow ) { + renderPlayerEvent.setCanceled(true); + } else if (renderPlayerEvent.entity instanceof EntityChicken && chicken) { + renderPlayerEvent.setCanceled(true); + } else if (renderPlayerEvent.entity instanceof EntityWolf && wolf) { + renderPlayerEvent.setCanceled(true); + } else if (renderPlayerEvent.entity instanceof EntityRabbit && rabbit) { + renderPlayerEvent.setCanceled(true); + } + } + + @Override + public void onEntityRenderPost(RenderLivingEvent.Post renderPlayerEvent) { + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureTerracotaTimer.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureTerracotaTimer.java new file mode 100644 index 00000000..a1e849df --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureTerracotaTimer.java @@ -0,0 +1,77 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorSadan; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.entity.boss.BossStatus; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureTerracotaTimer extends TextHUDFeature { + public FeatureTerracotaTimer() { + super("Dungeon.Bossfight.Floor 6", "Display Terracotta phase timer", "Displays Terracotta phase timer", "bossfight.terracota", true, getFontRenderer().getStringWidth("Terracottas: 1m 99s"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(true); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("time", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Terracottas","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("1m 99s","time")); + } + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorSadan && + "fight-1".equalsIgnoreCase(DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor().getCurrentPhase()); + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("title", "separator", "number", "unit"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public List getText() { + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Terracottas","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(TextUtils.formatTime((long) (BossStatus.healthScale * 1000 * 60 * 1.5)),"time")); + return actualBit; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornBearPercentage.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornBearPercentage.java new file mode 100644 index 00000000..6eac5186 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornBearPercentage.java @@ -0,0 +1,78 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorThorn; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureThornBearPercentage extends TextHUDFeature { + public FeatureThornBearPercentage() { + super("Dungeon.Bossfight.Floor 4", "Display Spirit Bear Summon Percentage", "Displays spirit bear summon percentage in hud", "bossfight.spiritbear", true, getFontRenderer().getStringWidth("Spirit Bear: 100%"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(true); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("unit", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + private static final java.util.List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Spirit Bear","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("50","number")); + dummyText.add(new StyledText("%","unit")); + } + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorThorn; + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("title", "separator", "number", "unit"); + } + + @Override + public java.util.List getDummyText() { + return dummyText; + } + + @Override + public java.util.List getText() { + int percentage = (int) (((BossfightProcessorThorn) DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor()).calculatePercentage() * 100); + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Spirit Bear","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(percentage+"","number")); + actualBit.add(new StyledText("%","unit")); + return actualBit; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornSpiritBowTimer.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornSpiritBowTimer.java new file mode 100644 index 00000000..208aef73 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureThornSpiritBowTimer.java @@ -0,0 +1,110 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.TitleListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorThorn; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.network.play.server.S45PacketTitle; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureThornSpiritBowTimer extends TextHUDFeature implements ChatListener, TitleListener { + public FeatureThornSpiritBowTimer() { + super("Dungeon.Bossfight.Floor 4", "Display Spirit bow timer", "Displays how long until spirit bow gets destroyed", "bossfight.spiritbowdisplay", false, getFontRenderer().getStringWidth("Spirit Bow Destruction: 2m 00s"), getFontRenderer().FONT_HEIGHT); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("time", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Spirit Bow Destruction","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("1s","time")); + } + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorThorn && time > System.currentTimeMillis(); + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("title", "separator", "time"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public List getText() { + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Spirit Bow Destruction","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(TextUtils.formatTime(time - System.currentTimeMillis()),"time")); + return actualBit; + } + private long time = 0; + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (!(skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorThorn)) return; + String text = clientChatReceivedEvent.message.getFormattedText(); + if (text.equals("ยงrยงaยงlThe ยงrยง5ยงlSpirit Bow ยงrยงaยงlhas dropped!ยงr")) { + time = System.currentTimeMillis() + 16000; + } else if (text.startsWith("ยงrยงc[BOSS] Thornยงrยงf: ")) { + if (text.contains("another wound") + || text.contains("My energy, it goes away") + || text.contains("dizzy") + || text.contains("a delicate feeling")) { + time = 0; + } + } else if (text.startsWith("ยงrยงb[CROWD]")) { + if (text.contains("That wasn't fair!!!") || text.contains("how to damage") || text.contains("Cheaters!") || text.contains("BOOOO")) { + time = 0; + } else if (text.contains("missing easy shots like that") || text.contains("missed the shot!") || text.contains("Keep dodging") || text.contains("no thumbs") || text.contains("can't aim")) { + time = 0; + } + } else if (text.equals("ยงrยงcThe ยงrยง5Spirit Bowยงrยงc disintegrates as you fire off the shot!ยงr")) { + time = 0; + } + } + + @Override + public void onTitle(S45PacketTitle renderPlayerEvent) { + if (!(skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() instanceof BossfightProcessorThorn)) return; + if (renderPlayerEvent.getMessage().getFormattedText().contains("picked up")) { + time = System.currentTimeMillis() + 21000; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureWarningOnPortal.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureWarningOnPortal.java new file mode 100644 index 00000000..2d5eb2d2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/FeatureWarningOnPortal.java @@ -0,0 +1,200 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.impl.dungeon.FeatureDungeonScore; +import kr.syeyoung.dungeonsguide.mod.features.text.*; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.util.*; + +public class FeatureWarningOnPortal extends SimpleFeature implements StyledTextProvider { + public FeatureWarningOnPortal() { + super("Dungeon.Blood Room", "Score Warning on Watcher portal", "Display warnings such as\n- 'NOT ALL ROOMS DISCOVERED'\n- 'NOT ALL ROOMS COMPLETED'\n- 'Expected Score: 304'\n- 'MISSING 3 CRYPTS'\non portal", "bossfight.warningonportal"); + addParameter("textStyles", new FeatureParameter>("textStyles", "", "", new ArrayList(), "list_textStyle")); + getStyles().add(new TextStyle("warning", new AColor(255, 0,0,255), new AColor(255, 255,255,255), false)); + getStyles().add(new TextStyle("field_name", new AColor(255, 72,255,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("field_separator", new AColor(204, 204,204,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("field_value", new AColor(255, 255,0,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("field_etc", new AColor(204, 204,204,255), new AColor(0, 0,0,0), false)); + } + + + private static final List dummyText = new ArrayList(); + static { + dummyText.add(new StyledText("!!!WARNING!!! <- text changes in boss-room\n", "warning")); + + dummyText.add(new StyledText("Total Secrets","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("103/100 of 50","field_value")); + dummyText.add(new StyledText("(103% 41.2 Explorer)","field_etc")); + + + dummyText.add(new StyledText("Crypts","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("5/5\n","field_value")); + + + dummyText.add(new StyledText("Deaths","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("0\n","field_value")); + + dummyText.add(new StyledText("Score Estimate","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("1000 ","field_value")); + dummyText.add(new StyledText("(S++++)\n","field_etc")); + + + dummyText.add(new StyledText("Skill","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("100 ","field_value")); + dummyText.add(new StyledText("(0 Deaths: 0 pts)\n","field_etc")); + + dummyText.add(new StyledText("Explorer","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("100 ","field_value")); + dummyText.add(new StyledText("(100% + secrets)\n","field_etc")); + + dummyText.add(new StyledText("Time","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("100 ","field_value")); + dummyText.add(new StyledText("(-30m 29s)\n","field_etc")); + + dummyText.add(new StyledText("Bonus","field_name")); + dummyText.add(new StyledText(": ","field_separator")); + dummyText.add(new StyledText("5\n","field_value")); + } + @Override + public List getDummyText() { + return dummyText; + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public List getText() { + ArrayList texts = new ArrayList(); + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + FeatureDungeonScore.ScoreCalculation scoreCalculation = FeatureRegistry.DUNGEON_SCORE.calculateScore(); + + boolean failed = context.getDungeonRoomList().stream().anyMatch(a -> a.getCurrentState() == DungeonRoom.RoomState.FAILED); + if (context.getMapProcessor().getUndiscoveredRoom() > 0) { + texts.add(new StyledText("There are at least "+context.getMapProcessor().getUndiscoveredRoom()+" undiscovered rooms!\n", "warning")); + } else if (failed) { + texts.add(new StyledText("There is a failed puzzle room! Yikes!\n", "warning")); + } else if (!scoreCalculation.isFullyCleared()) { + texts.add(new StyledText("Some rooms are not fully cleared!\n", "warning")); + } else if (scoreCalculation.getTombs() < 5) { + texts.add(new StyledText("Only less than 5 crypts are blown up!\n", "warning")); + } else { + texts.add(new StyledText("\n", "warning")); + } + + texts.add(new StyledText("Total Secrets","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getSecrets() +"/" + scoreCalculation.getEffectiveTotalSecrets()+" of "+scoreCalculation.getTotalSecrets(),"field_value")); + texts.add(new StyledText(" ("+(int)(scoreCalculation.getSecrets() / (float)scoreCalculation.getEffectiveTotalSecrets() * 100.0f)+"% "+(int)Math.ceil(scoreCalculation.getSecrets() / (float)scoreCalculation.getEffectiveTotalSecrets() * 40.0f)+" Explorer)\n","field_etc")); + + + texts.add(new StyledText("Crypts","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getTombs() +"/5\n","field_value")); + + + texts.add(new StyledText("Deaths","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getDeaths() + "\n","field_value")); + + int sum = scoreCalculation.getTime() + scoreCalculation.getExplorer() + scoreCalculation.getSkill() + scoreCalculation.getBonus(); + texts.add(new StyledText("Score Estimate","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(sum+" ","field_value")); + texts.add(new StyledText("("+FeatureRegistry.DUNGEON_SCORE.getLetter(sum)+")\n","field_etc")); + + + texts.add(new StyledText("Skill","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getSkill()+" ","field_value")); + texts.add(new StyledText("("+scoreCalculation.getDeaths()+" Deaths: "+(scoreCalculation.getDeaths() * -2)+" pts)\n","field_etc")); + + texts.add(new StyledText("Explorer","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getExplorer()+" ","field_value")); + texts.add(new StyledText("("+ DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getPercentage() +"% + secrets)\n","field_etc")); + + texts.add(new StyledText("Time","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getTime()+" ","field_value")); + texts.add(new StyledText("("+ TextUtils.formatTime(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed())+")\n","field_etc")); + + texts.add(new StyledText("Bonus","field_name")); + texts.add(new StyledText(": ","field_separator")); + texts.add(new StyledText(scoreCalculation.getBonus()+"\n","field_value")); + + + return texts; + } + + public List getStyles() { + return this.>getParameter("textStyles").getValue(); + } + private Map stylesMap; + public Map getStylesMap() { + if (stylesMap == null) { + List styles = getStyles(); + Map res = new HashMap(); + for (TextStyle ts : styles) { + res.put(ts.getGroupName(), ts); + } + stylesMap = res; + } + return stylesMap; + } + + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { + @Override + public MPanel get() { + MFeatureEdit featureEdit = new MFeatureEdit(FeatureWarningOnPortal.this, rootConfigPanel); + featureEdit.addParameterEdit("textStyles", new PanelTextParameterConfig(FeatureWarningOnPortal.this)); + for (FeatureParameter parameter: getParameters()) { + if (parameter.getKey().equals("textStyles")) continue; + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureWarningOnPortal.this, parameter, rootConfigPanel)); + } + return featureEdit; + } + }); + return "base." + getKey() ; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java new file mode 100644 index 00000000..de0fff4f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java @@ -0,0 +1,53 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; + +import java.util.ArrayList; +import java.util.List; + +public class CorrectThePaneSolutionProvider implements TerminalSolutionProvider { + @Override + public TerminalSolution provideSolution(ContainerChest chest, List clicked) { + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList()); + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null) { + if (inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + inventorySlot.getStack().getItemDamage() == EnumDyeColor.RED.getMetadata()) { + ts.getCurrSlots().add(inventorySlot); + } + } + } + + + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().equals("Correct all the panes!"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/FeatureSimonSaysSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/FeatureSimonSaysSolver.java new file mode 100644 index 00000000..3bb66763 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/FeatureSimonSaysSolver.java @@ -0,0 +1,113 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.InteractListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.TickListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.bossfight.BossfightProcessorNecron; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.awt.*; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +public class FeatureSimonSaysSolver extends SimpleFeature implements WorldRenderListener, TickListener, InteractListener { + public FeatureSimonSaysSolver() { + super("Dungeon.Bossfight.Floor 7+","Simon Says Solver","Solver for Simon says puzzle", "Dungeon.Bossfight.simonsays2"); + } + + private final SkyblockStatus ss = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + private final List orderbuild = new ArrayList(); + private final LinkedList orderclick = new LinkedList(); + + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + DungeonContext dc = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (dc == null) { + return; + } + if (!(dc.getBossfightProcessor() instanceof BossfightProcessorNecron)) return; + if (Minecraft.getMinecraft().thePlayer.getPosition().distanceSq(309,123,291) > 400) return; + + + if (orderclick.size() >= 1) + RenderUtils.highlightBlock(orderclick.get(0), new Color(0, 255 ,255, 100), partialTicks, false); + if (orderclick.size() >= 2) + RenderUtils.highlightBlock(orderclick.get(1), new Color(255, 170, 0, 100), partialTicks, false); + } + private boolean wasButton = false; + @Override + public void onTick() { + DungeonContext dc = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (dc == null) { + wasButton = false; + return; + } + if (!(dc.getBossfightProcessor() instanceof BossfightProcessorNecron)) return; + + if (wasButton && DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(new BlockPos(309, 123, 291)).getBlock() == Blocks.air) { + orderclick.clear(); + orderbuild.clear(); + wasButton = false; + } else if (!wasButton && DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(new BlockPos(309, 123, 291)).getBlock() == Blocks.stone_button){ + orderclick.addAll(orderbuild); + wasButton = true; + } + + + if (!wasButton) { + for (BlockPos allInBox : BlockPos.getAllInBox(new BlockPos(310, 123, 291), new BlockPos(310, 120, 294))) { + if (DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(allInBox).getBlock() == Blocks.sea_lantern && !orderbuild.contains(allInBox)) { + orderbuild.add(allInBox); + } + } + } + } + + @Override + public void onInteract(PlayerInteractEvent event) { + if (!isEnabled()) return; + + DungeonContext dc = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (dc == null) return; + if (!(dc.getBossfightProcessor() instanceof BossfightProcessorNecron)) return; + if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return; + World w = dc.getWorld(); + + BlockPos pos = event.pos.add(1,0,0); + if (120 <= pos.getY() && pos.getY() <= 123 && pos.getX() == 310 && 291 <= pos.getZ() && pos.getZ() <= 294) { + if (DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(event.pos).getBlock() != Blocks.stone_button) return; + if (pos.equals(orderclick.peek())) { + orderclick.poll(); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/FeatureTerminalSolvers.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/FeatureTerminalSolvers.java new file mode 100644 index 00000000..0b24dfce --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/FeatureTerminalSolvers.java @@ -0,0 +1,153 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import org.lwjgl.input.Mouse; + +import java.util.ArrayList; +import java.util.List; + +public class FeatureTerminalSolvers extends SimpleFeature implements GuiOpenListener, TickListener, GuiPostRenderListener, GuiClickListener, TooltipListener { + public FeatureTerminalSolvers() { + super("Dungeon.Bossfight.Floor 7+","F7 GUI Terminal Solver", "Solve f7 gui terminals. (color, startswith, order, navigate, correct panes)", "bossfight.terminals"); + } + + public static final List solutionProviders = new ArrayList(); + + static { + solutionProviders.add(new WhatStartsWithSolutionProvider()); + solutionProviders.add(new SelectAllColorSolutionProivider()); + solutionProviders.add(new SelectInOrderSolutionProvider()); + solutionProviders.add(new NavigateMazeSolutionProvider()); + solutionProviders.add(new CorrectThePaneSolutionProvider()); + } + + private TerminalSolutionProvider solutionProvider; + private TerminalSolution solution; + private final List clicked = new ArrayList(); + + @Override + public void onGuiOpen(GuiOpenEvent event) { + if (!isEnabled()) return; + solution = null; + solutionProvider = null; + clicked.clear(); + if (event.gui instanceof GuiChest) { + ContainerChest cc = (ContainerChest) ((GuiChest) event.gui).inventorySlots; + for (TerminalSolutionProvider solutionProvider : solutionProviders) { + if (solutionProvider.isApplicable(cc)) { + solution = solutionProvider.provideSolution(cc, clicked); + this.solutionProvider = solutionProvider; + } + } + } + } + + @Override + public void onTick() { + if (!isEnabled()) return; + if (solutionProvider == null) return; + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { + solution = null; + solutionProvider = null; + clicked.clear(); + return; + } + ContainerChest cc = (ContainerChest) ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots; + + solution = solutionProvider.provideSolution(cc, clicked); + } + + @Override + public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { + if (!isEnabled()) return; + if (solutionProvider == null) return; + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { + solution = null; + solutionProvider = null; + clicked.clear(); + return; + } + + if (solution != null) { + int i = 222; + int j = i - 108; + int ySize = j + (((ContainerChest)(((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots)).getLowerChestInventory().getSizeInventory() / 9) * 18; + int left = (rendered.gui.width - 176) / 2; + int top = (rendered.gui.height - ySize ) / 2; + GlStateManager.pushMatrix(); + GlStateManager.disableDepth(); + GlStateManager.disableLighting(); + GlStateManager.colorMask(true, true, true, false); + GlStateManager.translate(left, top, 0); + if (solution.getCurrSlots() != null) { + for (Slot currSlot : solution.getCurrSlots()) { + int x = currSlot.xDisplayPosition; + int y = currSlot.yDisplayPosition; + Gui.drawRect(x, y, x + 16, y + 16, 0x7700FFFF); + } + } + if (solution.getNextSlots() != null) { + for (Slot nextSlot : solution.getNextSlots()) { + int x = nextSlot.xDisplayPosition; + int y = nextSlot.yDisplayPosition; + Gui.drawRect(x, y, x + 16, y + 16, 0x77FFFF00); + } + } + GlStateManager.colorMask(true, true, true, true); + GlStateManager.popMatrix(); + } + GlStateManager.enableBlend(); + GlStateManager.enableLighting(); + } + + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + if (!isEnabled()) return; + if (Mouse.getEventButton() == -1) return; + if (solutionProvider == null) return; + if (solution == null) return; + if (solution.getCurrSlots() == null) { + return; + } + Slot s = ((GuiChest) Minecraft.getMinecraft().currentScreen).getSlotUnderMouse(); + if (solution.getCurrSlots().contains(s)) { + clicked.add(s); + return; + } + } + + @Override + public void onTooltip(ItemTooltipEvent event) { + if (!isEnabled()) return; + if (solutionProvider == null) return; + event.toolTip.clear(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/NavigateMazeSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/NavigateMazeSolutionProvider.java new file mode 100644 index 00000000..62fc7e19 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/NavigateMazeSolutionProvider.java @@ -0,0 +1,144 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; + +import java.util.ArrayList; +import java.util.List; + +public class NavigateMazeSolutionProvider implements TerminalSolutionProvider { + @Override + public TerminalSolution provideSolution(ContainerChest chest, List clicked) { + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList()); + Slot solution = null; + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null) { + if (inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + inventorySlot.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + int x = inventorySlot.slotNumber % 9; + int y = inventorySlot.slotNumber / 9; + + if (x > 0) { + Slot toChk = chest.inventorySlots.get(y * 9 + x - 1); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + solution = inventorySlot; + break; + } + } + if (x < 8) { + Slot toChk = chest.inventorySlots.get(y * 9 + x + 1); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + solution = inventorySlot; + break; + } + } + if (y > 0) { + Slot toChk = chest.inventorySlots.get((y-1) * 9 + x); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + solution = inventorySlot; + break; + } + } + if (y < chest.getLowerChestInventory().getSizeInventory() / 9 - 1) { + Slot toChk = chest.inventorySlots.get((y+1) * 9 + x); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + solution = inventorySlot; + break; + } + } + } + } + } + + if (solution == null) return null; + ts.getCurrSlots().add(solution); + ts.setNextSlots(new ArrayList()); + { + int x = solution.slotNumber % 9; + int y = solution.slotNumber / 9; + + if (x > 0) { + Slot toChk = chest.inventorySlots.get(y * 9 + x - 1); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + ts.getNextSlots().add(toChk); + return ts; + } + } + if (x < 8) { + Slot toChk = chest.inventorySlots.get(y * 9 + x + 1); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + ts.getNextSlots().add(toChk); + return ts; + } + } + if (y > 0) { + Slot toChk = chest.inventorySlots.get((y-1) * 9 + x); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + ts.getNextSlots().add(toChk); + return ts; + } + } + if (y < chest.getLowerChestInventory().getSizeInventory() / 9 - 1) { + Slot toChk = chest.inventorySlots.get((y+1) * 9 + x); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + ts.getNextSlots().add(toChk); + return ts; + } + } + } + + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().equals("Navigate the maze!"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/SelectAllColorSolutionProivider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/SelectAllColorSolutionProivider.java new file mode 100644 index 00000000..379d5179 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/SelectAllColorSolutionProivider.java @@ -0,0 +1,60 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.EnumDyeColor; + +import java.util.ArrayList; +import java.util.List; + +public class SelectAllColorSolutionProivider implements TerminalSolutionProvider { + @Override + public TerminalSolution provideSolution(ContainerChest chest, List clicked) { + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList()); + String name = chest.getLowerChestInventory().getName(); + EnumDyeColor edc = null; + for (EnumDyeColor edc2 : EnumDyeColor.values()) { + if (name.contains(edc2.getName().toUpperCase().replace("_"," "))) { + edc = edc2; + break; + } + } + if (edc == null) return null; + + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && !inventorySlot.getStack().isItemEnchanted()) { + if (inventorySlot.getStack().getItem() != Items.dye && inventorySlot.getStack().getItemDamage() == edc.getMetadata()) + ts.getCurrSlots().add(inventorySlot); + else if (inventorySlot.getStack().getItem() == Items.dye && inventorySlot.getStack().getItemDamage() == edc.getDyeDamage()) + ts.getCurrSlots().add(inventorySlot); + } + } + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().startsWith("Select all the "); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/SelectInOrderSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/SelectInOrderSolutionProvider.java new file mode 100644 index 00000000..03eab5ef --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/SelectInOrderSolutionProvider.java @@ -0,0 +1,72 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; + +import java.util.ArrayList; +import java.util.List; + +public class SelectInOrderSolutionProvider implements TerminalSolutionProvider { + @Override + public TerminalSolution provideSolution(ContainerChest chest, List clicked) { + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList()); + int lowest = 1000; + Slot slotLowest = null; + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) + && inventorySlot.getStack().getItemDamage() == EnumDyeColor.RED.getMetadata()) { + if (inventorySlot.getStack().stackSize < lowest) { + lowest = inventorySlot.getStack().stackSize; + slotLowest = inventorySlot; + } + } + } + if (slotLowest != null) + ts.getCurrSlots().add(slotLowest); + + Slot next = null; + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) + && inventorySlot.getStack().getItemDamage() == EnumDyeColor.RED.getMetadata()) { + if (inventorySlot.getStack().stackSize == lowest + 1) { + next = inventorySlot; + } + } + } + if (next != null) { + ts.setNextSlots(new ArrayList()); + ts.getNextSlots().add(next); + } + + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().equals("Click in order!"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/TerminalSolution.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/TerminalSolution.java new file mode 100644 index 00000000..3d76aa44 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/TerminalSolution.java @@ -0,0 +1,30 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import lombok.Data; +import net.minecraft.inventory.Slot; + +import java.util.List; + +@Data +public class TerminalSolution { + private List currSlots; + private List nextSlots; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/TerminalSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/TerminalSolutionProvider.java new file mode 100644 index 00000000..e2534d16 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/TerminalSolutionProvider.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; + +import java.util.List; + +public interface TerminalSolutionProvider { + TerminalSolution provideSolution(ContainerChest chest, List clicked); + boolean isApplicable(ContainerChest chest); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java new file mode 100644 index 00000000..889f34c0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java @@ -0,0 +1,50 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.boss.terminal; + +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; + +import java.util.ArrayList; +import java.util.List; + +public class WhatStartsWithSolutionProvider implements TerminalSolutionProvider{ + @Override + public TerminalSolution provideSolution(ContainerChest chest, List clicked) { + String that = chest.getLowerChestInventory().getName().replace("What starts with: '", "").replace("'?", "").trim().toLowerCase(); + + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList()); + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && !inventorySlot.getStack().isItemEnchanted() ) { + String name = TextUtils.stripColor(inventorySlot.getStack().getDisplayName()).toLowerCase(); + if (name.startsWith(that)) + ts.getCurrSlots().add(inventorySlot); + } + } + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().startsWith("What starts with: '"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/FeatureNicknameColor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/FeatureNicknameColor.java new file mode 100644 index 00000000..ce4599f5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/FeatureNicknameColor.java @@ -0,0 +1,49 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.cosmetics; + +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureNicknameColor extends SimpleFeature { + public FeatureNicknameColor() { + super("Cosmetics", "Nickname Color", "Click on Edit to choose nickname color cosmetic", "cosmetic.nickname"); + addParameter("dummy", new FeatureParameter("dummy", "dummy", "dummy", "dummy", "string")); + } + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , () -> new PrefixSelectorGUI("color", new String[] { + "ยง9Party ยง8> ยงrยงa[RANKยง6+ยงa] %prefix%%name%ยงf: TEST", + "ยง2Guild > ยงrยงa[RANKยง6+ยงa] %prefix%%name% ยง3[Vet]ยงf: TEST", + "ยงdTo ยงrยงrยงa[RANKยงrยง6+ยงrยงa] %prefix%%name%ยงrยง7: ยงrยง7TESTยงr", + "ยงdFrom ยงrยงrยงa[RANKยงrยง6+ยงrยงa] %prefix%%name%ยงrยง7: ยงrยง7TESTยงr", + "ยงrยงb[RANKยงc+ยงb] %prefix%%name%ยงf: TEST", + "ยงrยงbCo-op > ยงrยงa[RANKยง6+ยงa] %prefix%%name%ยงf: ยงrTESTยงr" + }, a -> (a.replace("&", "ยง")+"Color "+(a.replace("&", "ยง").equals("ยงz") ? "(Rainbow on sba)" : "")))); + return "base." + getKey(); + } + + @Override + public boolean isDisyllable() { + return false; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/FeatureNicknamePrefix.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/FeatureNicknamePrefix.java new file mode 100644 index 00000000..698eabb9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/FeatureNicknamePrefix.java @@ -0,0 +1,49 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.cosmetics; + +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureNicknamePrefix extends SimpleFeature { + public FeatureNicknamePrefix() { + super("Cosmetics", "Nickname Prefix", "Click on Edit to choose prefix cosmetic", "cosmetic.prefix"); + addParameter("dummy", new FeatureParameter("dummy", "dummy", "dummy", "dummy", "string")); + } + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , () -> new PrefixSelectorGUI("prefix", new String[] { + "ยง9Party ยง8> ยงr%prefix% ยงa[RANKยง6+ยงa] %name%ยงf: TEST", + "ยง2Guild > ยงr%prefix% ยงa[RANKยง6+ยงa] %name% ยง3[Vet]ยงf: TEST", + "ยงdTo ยงr%prefix% ยงrยงa[RANKยงrยง6+ยงrยงa] %name%ยงrยง7: ยงrยง7TESTยงr", + "ยงdFrom ยงr%prefix% ยงrยงa[RANKยงrยง6+ยงrยงa] %name%ยงrยง7: ยงrยง7TESTยงr", + "ยงr%prefix% ยงb[RANKยงc+ยงb] %name%ยงf: TEST", + "ยงrยงbCo-op > ยงr%prefix% ยงa[RANKยง6+ยงa] %name%ยงf: ยงrTESTยงr" + }, a->a.replace("&", "ยง"))); + return "base." + getKey(); + } + + @Override + public boolean isDisyllable() { + return false; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/PrefixSelectorGUI.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/PrefixSelectorGUI.java new file mode 100644 index 00000000..6cbcfe15 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/cosmetics/PrefixSelectorGUI.java @@ -0,0 +1,188 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.cosmetics; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; +import java.util.List; +import java.util.function.Function; + +public class PrefixSelectorGUI extends MPanel { + private String cosmeticType; + private Function optionTransformer; + + public PrefixSelectorGUI(String cosmeticType, String[] previews, Function optionTransformer) { + this.cosmeticType = cosmeticType; + this.previews = previews; + this.optionTransformer = optionTransformer; + CosmeticsManager cosmeticsManager = DungeonsGuide.getDungeonsGuide().getCosmeticsManager(); + List activeCosmeticList = cosmeticsManager.getActiveCosmeticByPlayer().computeIfAbsent(Minecraft.getMinecraft().thePlayer.getGameProfile().getId(), (a) -> new ArrayList<>()); + for (ActiveCosmetic activeCosmetic : activeCosmeticList) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData != null && cosmeticData.getCosmeticType().equals(cosmeticType)) { + selected = cosmeticData; + return; + } + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + private CosmeticData selected; + // ยง9Party ยง8> ยงa[VIPยง6+ยงa] syeyoungยงf: ty + // ยง2Guild > ยงa[VIPยง6+ยงa] syeyoung ยง3[Vet]ยงf + // ยงdTo ยงrยงa[VIPยงrยง6+ยงrยงa] SlashSlayerยงrยง7: ยงrยง7whatยงr + // ยงdFrom ยงrยงa[VIPยงrยง6+ยงrยงa] SlashSlayerยงrยง7: ยงrยง7?ยงr + // ยง7Rock_Birdยง7ยงrยง7: SELLING 30 DIAMOD BLOCK /p meยงr + // ยงb[MVPยงc+ยงb] Probutnoobgamerยงf: quitting skyblock! highe + // ยงrยงbCo-op > ยงa[VIPยง6+ยงa] syeyoungยงf: ยงrwhatยงr + String[] previews; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + CosmeticsManager cosmeticsManager = DungeonsGuide.getDungeonsGuide().getCosmeticsManager(); + + List activeCosmeticList2 = cosmeticsManager.getActiveCosmeticByPlayer().get(Minecraft.getMinecraft().thePlayer.getGameProfile().getId()); + Set activeCosmeticList = new HashSet<>(); + if (activeCosmeticList2 !=null) { + for (ActiveCosmetic activeCosmetic : activeCosmeticList2) { + activeCosmeticList.add(activeCosmetic.getCosmeticData()); + } + } + + + + GlStateManager.translate(0,2,0); + Gui.drawRect(0,0,getBounds().width, getBounds().height-2, 0xFF444444); + Gui.drawRect(5,5,265, getBounds().height-7, 0xFF222222); + Gui.drawRect(6,17,264, getBounds().height-8, 0xFF555555); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Preview", (270 - fr.getStringWidth("Preview")) / 2, 7, 0xFFFFFFFF); + + { + String prefix = selected != null ? selected.getData() : "[DG]"; + GlStateManager.pushMatrix(); + GlStateManager.translate(6,17,0); + for (int i = 0; i < previews.length; i++) { + fr.drawString(previews[i].replace("%name%", Minecraft.getMinecraft().getSession().getUsername()).replace("%prefix%", prefix.replace("&", "ยง")), 0, i*fr.FONT_HEIGHT, -1); + } + GlStateManager.popMatrix(); + } + { + GlStateManager.pushMatrix(); + GlStateManager.translate(270,17,0); + int relX = relMousex0 - 270, relY = relMousey0 - 19; + int cnt = 0; + for (CosmeticData value : cosmeticsManager.getCosmeticDataMap().values()) { + if (value.getCosmeticType().equals(cosmeticType)) { + if (!cosmeticsManager.getPerms().contains(value.getReqPerm()) && value.getReqPerm().startsWith("invis_")) continue; + Gui.drawRect(0,0,220, fr.FONT_HEIGHT+3, 0xFF222222); + Gui.drawRect(1,1, 219, fr.FONT_HEIGHT+2, 0xFF555555); + Gui.drawRect(120,1,160, fr.FONT_HEIGHT+2, new Rectangle(120,cnt * (fr.FONT_HEIGHT+4) + 2,40,fr.FONT_HEIGHT+1).contains(relX, relY) ? 0xFF859DF0 : 0xFF7289da); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(optionTransformer.apply(value.getData()), 2, 2, -1); + fr.drawString("TEST", (280-fr.getStringWidth("TEST"))/2, 2, -1); + + if (cosmeticsManager.getPerms().contains(value.getReqPerm())) { + Gui.drawRect(161,1,219, fr.FONT_HEIGHT+2, new Rectangle(161,cnt * (fr.FONT_HEIGHT+4) + 2,58,fr.FONT_HEIGHT+1).contains(relX, relY) ? 0xFF859DF0 : 0xFF7289da); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (activeCosmeticList.contains(value.getId())) { + fr.drawString("UNSELECT", (381 - fr.getStringWidth("UNSELECT")) / 2, 2, -1); + } else { + fr.drawString("SELECT", (381 - fr.getStringWidth("SELECT")) / 2, 2, -1); + } + } else { + Gui.drawRect(161,1,219, fr.FONT_HEIGHT+2, 0xFFFF3333); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Locked", (381 - fr.getStringWidth("Locked")) / 2, 2, -1); + } + GlStateManager.translate(0,fr.FONT_HEIGHT+4, 0); + + cnt++; + } + } + GlStateManager.popMatrix(); + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + CosmeticsManager cosmeticsManager = DungeonsGuide.getDungeonsGuide().getCosmeticsManager(); + + int relX = relMouseX - 270, relY = relMouseY - 19; + int cnt = 0; + + List activeCosmeticList = cosmeticsManager.getActiveCosmeticByPlayer().computeIfAbsent(Minecraft.getMinecraft().thePlayer.getGameProfile().getId(), (a) -> new ArrayList<>()); + + for (CosmeticData value : cosmeticsManager.getCosmeticDataMap().values()) { + if (value.getCosmeticType().equals(cosmeticType)) { + if (!cosmeticsManager.getPerms().contains(value.getReqPerm()) && value.getReqPerm().startsWith("invis_")) continue; + if (new Rectangle(120,cnt * (fr.FONT_HEIGHT+4) + 2,40,fr.FONT_HEIGHT+1).contains(relX, relY)) { + selected = value; + return; + } + try { + if (new Rectangle(161, cnt * (fr.FONT_HEIGHT + 4) + 2, 58, fr.FONT_HEIGHT + 1).contains(relX, relY) && cosmeticsManager.getPerms().contains(value.getReqPerm())) { + for (ActiveCosmetic activeCosmetic : activeCosmeticList) { + if (activeCosmetic.getCosmeticData().equals(value.getId())) { + cosmeticsManager.removeCosmetic(activeCosmetic); + return; + } + } + cosmeticsManager.setCosmetic(value); + selected = value; + } + } catch (Exception e) { + e.printStackTrace(); + } + + cnt++; + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/ImageTexture.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/ImageTexture.java new file mode 100644 index 00000000..3a4c226a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/ImageTexture.java @@ -0,0 +1,118 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.discord.inviteViewer; + + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.ResourceLocation; + +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.stream.ImageInputStream; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Iterator; + +@Data +public class ImageTexture { + private String url; + private BufferedImage image; + private DynamicTexture previewTexture; + private ResourceLocation resourceLocation; + + private int width; + private int height; + private int frames; + private int size; + + @Getter @Setter + private int lastFrame = 0; + + public void buildGLThings() { + previewTexture = new DynamicTexture(image); + resourceLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("dgurl/"+url, previewTexture); + } + + public ImageTexture(String url) throws IOException { + this.url = url; + + URL urlObj = new URL(url); + HttpURLConnection huc = (HttpURLConnection) urlObj.openConnection(); + huc.addRequestProperty("User-Agent", "DungeonsGuideMod (dungeons.guide, 1.0)"); + ImageInputStream imageInputStream = ImageIO.createImageInputStream(huc.getInputStream()); + Iterator readers = ImageIO.getImageReaders(imageInputStream); + if(!readers.hasNext()) throw new IOException("No image reader what" + url); + ImageReader reader = readers.next(); + reader.setInput(imageInputStream); + frames = reader.getNumImages(true); + BufferedImage dummyFrame = reader.read(0); + width = dummyFrame.getWidth(); height = dummyFrame.getHeight(); + + + image = new BufferedImage(width, height * frames, dummyFrame.getType()); + Graphics2D graphics2D = image.createGraphics(); + + for (int i = 0; i < frames; i++) { + BufferedImage bufferedImage = reader.read(i); + graphics2D.drawImage(bufferedImage, 0, i*height, null); + } + reader.dispose(); imageInputStream.close(); huc.disconnect(); + } + + public void drawFrame(int frame, int x, int y, int width, int height) { + if (getResourceLocation() == null) + buildGLThings(); + + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(getResourceLocation()); + + GlStateManager.color(1, 1, 1, 1.0F); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos((double)x, (double)(y + height), 0.0D) + .tex(0,((frame+1) * height)/ ((double)frames * height)).endVertex(); + worldrenderer.pos((double)(x + width), (double)(y + height), 0.0D) + .tex(1, ((frame+1) * height)/ ((double)frames * height)).endVertex(); + worldrenderer.pos((double)(x + width), (double)y, 0.0D) + .tex(1,(frame * height)/ ((double)frames * height)).endVertex(); + worldrenderer.pos((double)x, (double)y, 0.0D) + .tex(0, (frame * height) / ((double)frames * height)).endVertex(); + tessellator.draw(); + } + + public void drawFrameAndIncrement(int x, int y, int width, int height) { + drawFrame(lastFrame, x,y,width,height); + lastFrame++; + if (lastFrame >= frames) lastFrame = 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java new file mode 100644 index 00000000..e73c2d52 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java @@ -0,0 +1,314 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.discord.inviteViewer; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.events.impl.DiscordUserJoinRequestEvent; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.*; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.RichPresenceManager; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordActivityJoinRequestReply; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.client.event.GuiScreenEvent; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.util.*; +import java.util.List; +import java.util.concurrent.*; + +public class PartyInviteViewer extends SimpleFeature implements GuiPostRenderListener, ScreenRenderListener, TickListener, GuiClickListener, DiscordUserJoinRequestListener { + public PartyInviteViewer() { + super("Discord", "Party Invite Viewer","Simply type /dg asktojoin or /dg atj to toggle whether ask-to-join would be presented as option on discord!\n\nRequires Discord RPC to be enabled", "discord.party_invite_viewer"); + } + + @Override + public boolean isDisyllable() { + return false; + } + + @Override + public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { + renderRequests(true); + } + + @Override + public void drawScreen(float partialTicks) { + if (!isEnabled()) return; + try { + renderRequests(false); + } catch (Throwable t) { + t.printStackTrace(); + } + } + @Override + public void onTick() { + try { + List partyJoinRequestList = new ArrayList<>(); + boolean isOnHypixel = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnHypixel(); + for (PartyJoinRequest joinRequest:joinRequests) { + if (joinRequest.getTtl() != -1) { + joinRequest.setTtl(joinRequest.getTtl() - 1); + if (joinRequest.getTtl() == 0 || !isOnHypixel) { + partyJoinRequestList.add(joinRequest); + } + } else if (!isOnHypixel){ +// DiscordRPC.discordRespond(joinRequest.getDiscordUser().userId, DiscordRPC.DiscordReply.NO); + partyJoinRequestList.add(joinRequest); + } else if (joinRequest.getExpire() < System.currentTimeMillis()) { + partyJoinRequestList.add(joinRequest); + } + } + joinRequests.removeAll(partyJoinRequestList); + } catch (Throwable e) {e.printStackTrace();} + } + + + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + if (!isEnabled()) return; + int mouseX = Mouse.getX(); + int mouseY = Minecraft.getMinecraft().displayHeight - Mouse.getY() +3; + for (PartyJoinRequest joinRequest:joinRequests) { + if (joinRequest.getWholeRect() != null && joinRequest.getWholeRect().contains(mouseX, mouseY)) { + mouseInputEvent.setCanceled(true); + + if (Mouse.getEventButton() == -1) return; + + if (joinRequest.getReply() != null) { + joinRequests.remove(joinRequest); + return; + } + + if (!joinRequest.isInvite()) { + if (joinRequest.getAcceptRect().contains(mouseX, mouseY)) { + joinRequest.setReply(PartyJoinRequest.Reply.ACCEPT); + joinRequest.setTtl(60); + RichPresenceManager.INSTANCE.respond(joinRequest.getDiscordUser().id, EDiscordActivityJoinRequestReply.DiscordActivityJoinRequestReply_Yes); + return; + } + + if (joinRequest.getDenyRect().contains(mouseX, mouseY)) { + joinRequest.setReply(PartyJoinRequest.Reply.DENY); + joinRequest.setTtl(60); + RichPresenceManager.INSTANCE.respond(joinRequest.getDiscordUser().id, EDiscordActivityJoinRequestReply.DiscordActivityJoinRequestReply_No); + return; + } + + if (joinRequest.getIgnoreRect().contains(mouseX, mouseY)) { + joinRequest.setReply(PartyJoinRequest.Reply.IGNORE); + joinRequest.setTtl(60); + RichPresenceManager.INSTANCE.respond(joinRequest.getDiscordUser().id, EDiscordActivityJoinRequestReply.DiscordActivityJoinRequestReply_Ignore); + return; + } + } else { + if (joinRequest.getAcceptRect().contains(mouseX, mouseY)) { + joinRequest.setReply(PartyJoinRequest.Reply.ACCEPT); + joinRequest.setTtl(60); + RichPresenceManager.INSTANCE.accept(joinRequest.getDiscordUser().id); + return; + } + + if (joinRequest.getDenyRect().contains(mouseX, mouseY)) { + joinRequest.setReply(PartyJoinRequest.Reply.DENY); + joinRequest.setTtl(60); + return; + } + } + + return; + } + } + } + + + + public CopyOnWriteArrayList joinRequests = new CopyOnWriteArrayList<>(); + + ExecutorService executorService = Executors.newFixedThreadPool(3); + public Map> futureMap = new HashMap<>(); + public Map imageMap = new HashMap<>(); + + public Future loadImage(String url) { + if (imageMap.containsKey(url)) return CompletableFuture.completedFuture(imageMap.get(url)); + if (futureMap.containsKey(url)) return futureMap.get(url); + Future future = executorService.submit(() -> { + try { + ImageTexture imageTexture = new ImageTexture(url); + imageMap.put(url, imageTexture); + return imageTexture; + } catch (Exception e) { + throw e; + } + }); + futureMap.put(url,future); + return future; + } + + + public void renderRequests(boolean hover) { + try { + GlStateManager.pushMatrix(); + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + GlStateManager.scale(1.0 / sr.getScaleFactor(), 1.0 / sr.getScaleFactor(), 1.0); + int height = 90; + int gap = 5; + int x = 5; + int y = 5; + for (PartyJoinRequest partyJoinRequest : joinRequests) { + renderRequest(partyJoinRequest, x, y, 350,height, hover); + y += height + gap; + } + GlStateManager.popMatrix(); + GlStateManager.enableBlend(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + + public void renderRequest(PartyJoinRequest partyJoinRequest, int x, int y, int width, int height, boolean hover) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + + int mouseX = Mouse.getX(); + int mouseY = Minecraft.getMinecraft().displayHeight - Mouse.getY() +3; + + partyJoinRequest.getWholeRect().setBounds(x,y,width,height); + + + GlStateManager.pushMatrix(); + GlStateManager.translate(x,y,0); + + Gui.drawRect(0, 0,width,height, 0xFF23272a); + Gui.drawRect(2, 2, width-2, height-2, 0XFF2c2f33); + { + String avatar = "https://cdn.discordapp.com/avatars/"+Long.toUnsignedString(partyJoinRequest.getDiscordUser().id.longValue())+"/"+partyJoinRequest.getAvatar()+"."+(partyJoinRequest.getAvatar().startsWith("a_") ? "gif":"png"); + Future loadedImageFuture = loadImage(avatar); + ImageTexture loadedImage = null; + if (loadedImageFuture.isDone()) { + try { + loadedImage = loadedImageFuture.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + if (loadedImage != null) { + loadedImage.drawFrameAndIncrement( 7,7,height-14,height-14); + } else { + Gui.drawRect(7, 7, height - 7, height-7, 0xFF4E4E4E); + } + } + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.pushMatrix(); + GlStateManager.translate(height +3,7, 0); + + GlStateManager.pushMatrix(); + GlStateManager.scale(3.0,3.0,1.0); + fr.drawString(partyJoinRequest.getUsername()+"", 0,0, 0xFFFFFFFF, true); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.translate(fr.getStringWidth(partyJoinRequest.getUsername()+"") * 3 + 1, (int)(fr.FONT_HEIGHT*1.5), 0); + fr.drawString("#"+partyJoinRequest.getDiscriminator(), 0,0,0xFFaaaaaa, true); + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + GlStateManager.translate(0, fr.FONT_HEIGHT * 3 + 5, 0); + GlStateManager.scale(1.0,1.0,1.0); + if (partyJoinRequest.isInvite()) + fr.drawString("ยงewants to you to join their party! ("+(TextUtils.formatTime(partyJoinRequest.getExpire() - System.currentTimeMillis()))+")", 0,0,0xFFFFFFFF,false); + else + fr.drawString("wants to join your party! ("+(TextUtils.formatTime(partyJoinRequest.getExpire() - System.currentTimeMillis()))+")", 0,0,0xFFFFFFFF,false); + GlStateManager.popMatrix(); + GlStateManager.popMatrix(); + if (partyJoinRequest.getReply() == null) { + GlStateManager.pushMatrix(); + GlStateManager.translate(height + 3, height - 32, 0); + int widthForTheThing = (width - height) / 3; + GlStateManager.pushMatrix(); + String text = "Accept"; + partyJoinRequest.getAcceptRect().setBounds(x + height + 3, y + height - 25, widthForTheThing - 10, 25); + Gui.drawRect(0, 0, widthForTheThing - 10, 25, hover && partyJoinRequest.getAcceptRect().contains(mouseX, mouseY) ? 0xFF859DF0 : 0xFF7289da); + GlStateManager.translate((widthForTheThing - 10 - fr.getStringWidth(text) * 2) / 2, 15 - fr.FONT_HEIGHT, 0); + + GlStateManager.scale(2.0f, 2.0f, 1.0f); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(text, 0, 0, 0xFFFFFFFF); + GlStateManager.popMatrix(); + GlStateManager.translate(widthForTheThing, 0, 0); + partyJoinRequest.getDenyRect().setBounds(x + height + 3 + widthForTheThing, y + height - 25, widthForTheThing - 10, 25); + Gui.drawRect(0, 0, widthForTheThing - 10, 25, hover && partyJoinRequest.getDenyRect().contains(mouseX, mouseY) ? 0xFFAEC0CB : 0xFF99aab5); + GlStateManager.pushMatrix(); + text = "Deny"; + GlStateManager.translate((widthForTheThing - 10 - fr.getStringWidth(text) * 2) / 2, 15 - fr.FONT_HEIGHT, 0); + GlStateManager.scale(2.0f, 2.0f, 1.0f); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(text, 0, 0, 0xFFFFFFFF); + GlStateManager.popMatrix(); + if (!partyJoinRequest.isInvite()) { + GlStateManager.translate(widthForTheThing, 0, 0); + partyJoinRequest.getIgnoreRect().setBounds(x + height + 3 + widthForTheThing + widthForTheThing, y + height - 25, widthForTheThing - 10, 25); + Gui.drawRect(0, 0, widthForTheThing - 10, 25, hover && partyJoinRequest.getIgnoreRect().contains(mouseX, mouseY) ? 0xFFAEC0CB : 0xFF99aab5); // AEC0CB + + GlStateManager.pushMatrix(); + text = "Ignore"; + GlStateManager.translate((widthForTheThing - 10 - fr.getStringWidth(text) * 2) / 2, 15 - fr.FONT_HEIGHT, 0); + GlStateManager.scale(2.0f, 2.0f, 1.0f); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(text, 0, 0, 0xFFFFFFFF); + GlStateManager.popMatrix(); + } + GlStateManager.popMatrix(); + } else { + GlStateManager.pushMatrix(); + GlStateManager.translate(height + 3, height - 28, 0); + GlStateManager.scale(2.0f,2.0f,1.0f); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(partyJoinRequest.getReply().getPast()+" the invite.",0,0,0xFFFFFFFF); + GlStateManager.popMatrix(); + } + GlStateManager.popMatrix(); + } + + @Override + public void onDiscordUserJoinRequest(DiscordUserJoinRequestEvent event) { + PartyJoinRequest partyInvite = new PartyJoinRequest(); + partyInvite.setDiscordUser(event.getDiscordUser()); + partyInvite.setExpire(System.currentTimeMillis() + 30000L); + partyInvite.setInvite(event.isInvite()); + joinRequests.add(partyInvite); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyJoinRequest.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyJoinRequest.java new file mode 100644 index 00000000..a50966dc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyJoinRequest.java @@ -0,0 +1,59 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.discord.inviteViewer; + +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.GameSDK; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.datastruct.DiscordUser; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; + +import java.awt.*; + +@Data +public class PartyJoinRequest { + private DiscordUser discordUser; + + public void setDiscordUser(DiscordUser discordUser) { + this.discordUser = discordUser; + username = GameSDK.readString(discordUser.username); + discriminator = GameSDK.readString(discordUser.discriminator); + avatar = GameSDK.readString(discordUser.avatar); + } + + private String username, discriminator, avatar; + private long expire; + + private Rectangle wholeRect = new Rectangle(); + private Rectangle acceptRect = new Rectangle(); + private Rectangle denyRect = new Rectangle(); + private Rectangle ignoreRect = new Rectangle(); + + private boolean isInvite; + private int ttl = -1; + private Reply reply; + + @AllArgsConstructor + public enum Reply { + ACCEPT("Accepted"), DENY("Denied"), IGNORE("Ignored"); + + @Getter + private final String past; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/invteTooltip/MTooltipInvite.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/invteTooltip/MTooltipInvite.java new file mode 100644 index 00000000..81331686 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/invteTooltip/MTooltipInvite.java @@ -0,0 +1,127 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.discord.invteTooltip; + +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordActivityActionType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordRelationshipType; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct.IDiscordActivityManager; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.interfacestruct.IDiscordCore; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.typedef.DiscordSnowflake; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.JDiscordRelation; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.RichPresenceManager; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.renderer.GlStateManager; + +import java.awt.*; +import java.util.HashSet; +import java.util.Set; + +public class MTooltipInvite extends MModal { + private MScrollablePanel mScrollablePanel; + private MList list; + private MTextField search; + private MButton close; + private Set invited = new HashSet<>(); + public MTooltipInvite() { + setTitle("Invite Discord Friend"); + mScrollablePanel = new MScrollablePanel(1); + mScrollablePanel.setHideScrollBarWhenNotNecessary(true); + add(mScrollablePanel); + + list = new MList() { + @Override + public void resize(int parentWidth, int parentHeight) { + setSize(new Dimension(parentWidth, 9999)); + realignChildren(); + } + }; + list.setGap(1); + list.setDrawLine(true); + list.setGapLineColor(RenderUtils.blendAlpha(0x141414, 0.13f)); + mScrollablePanel.add(list); + mScrollablePanel.getScrollBarY().setWidth(5); + + search = new MTextField() { + @Override + public void edit(String str) { + super.edit(str); resetListContent(); + } + }; + search.setPlaceHolder("Search..."); + add(search); + + close = new MButton(); + close.setText("X"); + close.setBackground( RenderUtils.blendAlpha(0x141414, 0.20f)); + close.setHover( RenderUtils.blendAlpha(0x141414, 0.25f)); + close.setClicked( RenderUtils.blendAlpha(0x141414, 0.24f)); + close.setOnActionPerformed(this::close); + addSuper(close); + resetListContent(); + } + + @Override + public void onBoundsUpdate() { + super.onBoundsUpdate(); + Dimension effDim = getModalContent().getSize(); + search.setBounds(new Rectangle(5,2,effDim.width-10, 15)); + mScrollablePanel.setBounds(new Rectangle(10,18,effDim.width-20, effDim.height-25)); + close.setBounds(new Rectangle(getModalContent().getBounds().x + effDim.width-15,getModalContent().getBounds().y - 16,15,15)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + GlStateManager.pushMatrix(); + super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); + GlStateManager.popMatrix(); + + Dimension modalSize = getModalSize(); + Dimension effDim = getEffectiveDimension(); + int x = (effDim.width-modalSize.width)/2; + int y = (effDim.height - modalSize.height)/2; + GlStateManager.translate(x,y, 0); + } + + private void resetListContent() { + for (MPanel childComponent : list.getChildComponents()) { + list.remove(childComponent); + } + + String searchTxt = search.getText().trim().toLowerCase(); + for (JDiscordRelation value : RichPresenceManager.INSTANCE.getRelationMap().values()) { +// if (value.getDiscordActivity().getApplicationId() != 816298079732498473L) continue; + if (value.getDiscordRelationshipType() == EDiscordRelationshipType.DiscordRelationshipType_Blocked) continue; + if (!searchTxt.isEmpty() && !(value.getDiscordUser().getUsername().toLowerCase().contains(searchTxt))) continue; + list.add(new MTooltipInviteElement(value, invited.contains(value.getDiscordUser().getId()), this::invite)); + } + setBounds(getBounds()); + } + + public void invite(long id) { + invited.add(id); + IDiscordCore iDiscordCore = RichPresenceManager.INSTANCE.getIDiscordCore(); + IDiscordActivityManager iDiscordActivityManager = iDiscordCore.GetActivityManager.getActivityManager(iDiscordCore); + iDiscordActivityManager.SendInvite.sendInvite(iDiscordActivityManager, new DiscordSnowflake(id), EDiscordActivityActionType.DiscordActivityActionType_Join, "Dungeons Guide RPC Invite TESt", Pointer.NULL, (callbackData, result) -> { + System.out.println("Discord returned "+result+" For inviting "+id); + }); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/invteTooltip/MTooltipInviteElement.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/invteTooltip/MTooltipInviteElement.java new file mode 100644 index 00000000..f29dff4b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/invteTooltip/MTooltipInviteElement.java @@ -0,0 +1,109 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.discord.invteTooltip; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.impl.discord.inviteViewer.ImageTexture; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.JDiscordRelation; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; + +import java.awt.*; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.function.Consumer; + +public class MTooltipInviteElement extends MPanel { + private JDiscordRelation relation; + private MButton invite; + public MTooltipInviteElement(JDiscordRelation jDiscordRelation, boolean invited, Consumer inviteCallback) { + this.relation = jDiscordRelation; + this.invite = new MButton(); + if (!invited) { + invite.setText("Invite"); + invite.setRoundness(2); + invite.setBorder(0xFF02EE67); + invite.setHover(RenderUtils.blendAlpha(0x141414, 0.2f)); + invite.setBackground(RenderUtils.blendAlpha(0x141414, 0.17f)); + invite.setForeground(new Color(0xFF02EE67)); + + invite.setOnActionPerformed(() -> { + if (invite.isEnabled()) + inviteCallback.accept(jDiscordRelation.getDiscordUser().getId()); + + invite.setText("Sent"); + invite.setRoundness(2); + invite.setHover(0); invite.setBorder(0); + invite.setBackground(0); invite.setDisabled(0); invite.setEnabled(false); + invite.setForeground(new Color(0xFF02EE67)); + }); + } else { + invite.setText("Sent"); + invite.setRoundness(2); + invite.setHover(0); + invite.setBackground(0); invite.setDisabled(0); invite.setEnabled(false); + invite.setForeground(new Color(0xFF02EE67)); + } + + add(invite); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (lastAbsClip.contains(absMousex, absMousey) && getTooltipsOpen() == 0) { + RenderUtils.drawRoundedRectangle(0,0,bounds.width, bounds.height, 3, Math.PI/8, RenderUtils.blendAlpha(0x141414, 0.17f)); + GlStateManager.enableTexture2D(); + } + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + if (!relation.getDiscordUser().getAvatar().isEmpty()){ + String avatar = "https://cdn.discordapp.com/avatars/"+Long.toUnsignedString(relation.getDiscordUser().getId())+"/"+relation.getDiscordUser().getAvatar()+"."+(relation.getDiscordUser().getAvatar().startsWith("a_") ? "gif":"png"); + Future loadedImageFuture = FeatureRegistry.DISCORD_ASKTOJOIN.loadImage(avatar); + ImageTexture loadedImage = null; + if (loadedImageFuture.isDone()) { + try { + loadedImage = loadedImageFuture.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + if (loadedImage != null) { + loadedImage.drawFrameAndIncrement( 3,3,bounds.height-6,bounds.height-6); + } else { + Gui.drawRect(3, 3, bounds.height - 6, bounds.height-6, 0xFF4E4E4E); + } + } + fr.drawString(relation.getDiscordUser().getUsername()+"#"+relation.getDiscordUser().getDiscriminator(), bounds.height,(bounds.height-fr.FONT_HEIGHT)/2, -1); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(100, 20); + } + + @Override + public void onBoundsUpdate() { + invite.setBounds(new Rectangle(bounds.width-53,2,50,bounds.height-4)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java new file mode 100644 index 00000000..b37aa62d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java @@ -0,0 +1,170 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.discord.onlinealarm; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.events.impl.DiscordUserUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.impl.discord.inviteViewer.ImageTexture; +import kr.syeyoung.dungeonsguide.mod.features.listener.DiscordUserUpdateListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.ScreenRenderListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.TickListener; +import kr.syeyoung.dungeonsguide.mod.discord.gamesdk.jna.enumuration.EDiscordRelationshipType; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.JDiscordActivity; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.JDiscordRelation; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +public class PlayingDGAlarm extends SimpleFeature implements DiscordUserUpdateListener, ScreenRenderListener, TickListener { + public PlayingDGAlarm() { + super("Discord", "Friend Online Notification","Notifies you in bottom when your discord friend has launched a Minecraft with DG!\n\nRequires the Friend's Discord RPC to be enabled", "discord.playingalarm"); + } + private List notif = new CopyOnWriteArrayList<>(); + + @Override + public void onTick() { + try { + List partyJoinRequestList = new ArrayList<>(); + boolean isOnHypixel = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnHypixel(); + for (PlayerOnline joinRequest:notif) { + if (!isOnHypixel){ + partyJoinRequestList.add(joinRequest); + } else if (joinRequest.getEnd() < System.currentTimeMillis()) { + partyJoinRequestList.add(joinRequest); + } + } + notif.removeAll(partyJoinRequestList); + } catch (Throwable e) {e.printStackTrace();} + } + + + + @Override + public void drawScreen(float partialTicks) { + if (!isEnabled()) return; + try { + GlStateManager.pushMatrix(); + GlStateManager.translate(0,0,100); + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + GlStateManager.scale(1.0 / sr.getScaleFactor(), 1.0 / sr.getScaleFactor(), 1.0); + int height = 90; + int gap = 5; + int x = Minecraft.getMinecraft().displayWidth-350-gap; + int y = Minecraft.getMinecraft().displayHeight-(height+gap)*notif.size(); + for (PlayerOnline partyJoinRequest : notif) { + renderRequest(partyJoinRequest, x, y, 350,height); + y += height + gap; + } + GlStateManager.popMatrix(); + GlStateManager.enableBlend(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + public void renderRequest(PlayerOnline online, int x, int y, int width, int height) { + GlStateManager.pushMatrix(); + GlStateManager.translate(x,y,0); + + Gui.drawRect(0, 0,width,height, 0xFF23272a); + Gui.drawRect(2, 2, width-2, height-2, 0XFF2c2f33); + { + String avatar = "https://cdn.discordapp.com/avatars/"+Long.toUnsignedString(online.getJDiscordRelation().getDiscordUser().getId())+"/"+online.getJDiscordRelation().getDiscordUser().getAvatar()+"."+(online.getJDiscordRelation().getDiscordUser().getAvatar().startsWith("a_") ? "gif":"png"); + Future loadedImageFuture = FeatureRegistry.DISCORD_ASKTOJOIN.loadImage(avatar); + ImageTexture loadedImage = null; + if (loadedImageFuture.isDone()) { + try { + loadedImage = loadedImageFuture.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + if (loadedImage != null) { + loadedImage.drawFrameAndIncrement( 7,7,height-14,height-14); + } else { + Gui.drawRect(7, 7, height - 7, height-7, 0xFF4E4E4E); + } + } + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.pushMatrix(); + GlStateManager.translate(height +3,7, 0); + + GlStateManager.pushMatrix(); + GlStateManager.scale(3.0,3.0,1.0); + fr.drawString(online.getJDiscordRelation().getDiscordUser().getUsername()+"", 0,0, 0xFFFFFFFF, true); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.translate(fr.getStringWidth(online.getJDiscordRelation().getDiscordUser().getUsername()+"") * 3 + 1, (int)(fr.FONT_HEIGHT*1.5), 0); + fr.drawString("#"+online.getJDiscordRelation().getDiscordUser().getDiscriminator(), 0,0,0xFFaaaaaa, true); + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + GlStateManager.translate(0, fr.FONT_HEIGHT * 3 + 5, 0); + GlStateManager.scale(1.0,1.0,1.0); + fr.drawString("Started Playing Skyblock! (Dismissed in "+(TextUtils.formatTime(online.getEnd() - System.currentTimeMillis()))+")", 0,0,0xFFFFFFFF,false); + GlStateManager.popMatrix(); + GlStateManager.popMatrix(); + GlStateManager.popMatrix(); + } + + + @Data @AllArgsConstructor + public static class PlayerOnline { + private JDiscordRelation jDiscordRelation; + private long end; + } + + @Override + public void onDiscordUserUpdate(DiscordUserUpdateEvent event) { + JDiscordRelation prev = event.getPrev(), current = event.getCurrent(); + if (!isDisplayable(prev) && isDisplayable(current)) { + notif.add(new PlayerOnline(current, System.currentTimeMillis()+3000)); + } + } + + public boolean isDisplayable(JDiscordRelation jDiscordRelation) { + EDiscordRelationshipType relationshipType = jDiscordRelation.getDiscordRelationshipType(); + if (relationshipType == EDiscordRelationshipType.DiscordRelationshipType_Blocked) return false; + if (relationshipType == EDiscordRelationshipType.DiscordRelationshipType_None) return false; + if (relationshipType == EDiscordRelationshipType.DiscordRelationshipType_PendingIncoming) return false; + if (relationshipType == EDiscordRelationshipType.DiscordRelationshipType_PendingOutgoing) return false; + + JDiscordActivity jDiscordActivity = jDiscordRelation.getDiscordActivity(); + return jDiscordActivity.getApplicationId() == 816298079732498473L; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxBats.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxBats.java new file mode 100644 index 00000000..6c76b668 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxBats.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + + +public class FeatureBoxBats extends SimpleFeature implements WorldRenderListener { + public FeatureBoxBats() { + super("Dungeon.Mobs", "Box Bats", "Box bats in dungeons\nDoes not appear through walls", "dungeon.batbox", true); + addParameter("radius", new FeatureParameter("radius", "Highlight Radius", "The maximum distance between player and bats to be boxed", 20, "integer")); + addParameter("color", new FeatureParameter("color", "Highlight Color", "Highlight Color of Bats", new AColor(255,0,0,50), "acolor")); + } + + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + if (!skyblockStatus.isOnDungeon()) return; + + final BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + int val = this.getParameter("radius").getValue(); + final int sq = val * val; + + List skeletonList = Minecraft.getMinecraft().theWorld.getEntities(EntityBat.class, new Predicate() { + @Override + public boolean apply(@Nullable EntityBat input) { + if (input != null && input.isInvisible()) return false; + return input != null && input.getDistanceSq(player) < sq; + } + }); + AColor c = this.getParameter("color").getValue(); + for (EntityBat entitySkeleton : skeletonList) { + if (!entitySkeleton.isInvisible()) + RenderUtils.highlightBox(entitySkeleton, c, partialTicks, true); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxSkelemaster.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxSkelemaster.java new file mode 100644 index 00000000..4b7923d7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxSkelemaster.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.util.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + + +public class FeatureBoxSkelemaster extends SimpleFeature implements WorldRenderListener { + public FeatureBoxSkelemaster() { + super("Dungeon.Mobs", "Box Skeleton Masters", "Box skeleton masters in dungeons", "dungeon.skeletonmasterbox", true); + addParameter("radius", new FeatureParameter("radius", "Highlight Radius", "The maximum distance between player and skeletonmaster to be boxed", 20, "integer")); + addParameter("color", new FeatureParameter("color", "Highlight Color", "Highlight Color of Skeleton master", new AColor(255,0,0,50), "acolor")); + } + + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + if (!skyblockStatus.isOnDungeon()) return; + + final BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + int val = this.getParameter("radius").getValue(); + final int sq = val * val; + + List skeletonList = Minecraft.getMinecraft().theWorld.getEntities(EntityArmorStand.class, new Predicate() { + @Override + public boolean apply(@Nullable EntityArmorStand input) { + if (player.distanceSq(input.getPosition()) > sq) return false; + if (!input.getAlwaysRenderNameTag()) return false; + return input.getName().contains("Skeleton Master"); + } + }); + AColor c = this.getParameter("color").getValue(); + for (EntityArmorStand entitySkeleton : skeletonList) { + RenderUtils.highlightBox(entitySkeleton, c, partialTicks, true); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxStarMobs.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxStarMobs.java new file mode 100644 index 00000000..3407e57a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureBoxStarMobs.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.util.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + + +public class FeatureBoxStarMobs extends SimpleFeature implements WorldRenderListener { + public FeatureBoxStarMobs() { + super("Dungeon.Mobs", "Box Starred mobs", "Box Starred mobs in dungeons", "dungeon.starmobbox", false); + addParameter("radius", new FeatureParameter("radius", "Highlight Radius", "The maximum distance between player and starred mobs to be boxed", 20, "integer")); + addParameter("color", new FeatureParameter("color", "Highlight Color", "Highlight Color of Starred mobs", new AColor(0,255,255,50), "acolor")); + } + + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + if (!skyblockStatus.isOnDungeon()) return; + + final BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + int val = this.getParameter("radius").getValue(); + final int sq = val * val; + + List skeletonList = Minecraft.getMinecraft().theWorld.getEntities(EntityArmorStand.class, new Predicate() { + @Override + public boolean apply(@Nullable EntityArmorStand input) { + if (player.distanceSq(input.getPosition()) > sq) return false; + if (!input.getAlwaysRenderNameTag()) return false; + return input.getName().contains("โœฏ"); + } + }); + AColor c = this.getParameter("color").getValue(); + for (EntityArmorStand entitySkeleton : skeletonList) { + RenderUtils.highlightBox(entitySkeleton, c, partialTicks, true); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureCollectScore.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureCollectScore.java new file mode 100644 index 00000000..f9ea3a49 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureCollectScore.java @@ -0,0 +1,77 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.stomp.StompManager; +import kr.syeyoung.dungeonsguide.mod.stomp.StompPayload; +import kr.syeyoung.dungeonsguide.mod.utils.MapUtils; +import kr.syeyoung.dungeonsguide.mod.wsresource.StaticResourceCache; +import net.minecraft.util.ChatComponentText; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.json.JSONObject; + +import java.util.concurrent.ExecutionException; + +public class FeatureCollectScore extends SimpleFeature { + Logger logger = LogManager.getLogger("FeatureCollectScore"); + public FeatureCollectScore() { + super("Misc", "Collect Speed Score", "Collect Speed score, run time, and floor and send that to developer's server for speed formula. This data is completely anonymous, opt out of the feature by disabling this feature", "misc.gatherscoredata", true); + } + + public void collectDungeonRunData(byte[] mapData, DungeonContext context) { + int skill = MapUtils.readNumber(mapData, 51, 35, 9); + int exp = MapUtils.readNumber(mapData, 51, 54, 9); + int time = MapUtils.readNumber(mapData, 51, 73, 9); + int bonus = MapUtils.readNumber(mapData, 51, 92, 9); + ChatTransmitter.sendDebugChat(new ChatComponentText(("skill: " + skill + " / exp: " + exp + " / time: " + time + " / bonus : " + bonus))); + JSONObject payload = new JSONObject().put("timeSB", FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed()) + .put("timeR", FeatureRegistry.DUNGEON_REALTIME.getTimeElapsed()) + .put("timeScore", time) + .put("completionStage", context.getBossRoomEnterSeconds() == -1 ? 0 : + context.isDefeated() ? 2 : 1) + .put("percentage", DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getPercentage() / 100.0) + .put("floor", DungeonContext.getDungeonName()); + ChatTransmitter.sendDebugChat(new ChatComponentText(payload.toString())); + + if(!StompManager.getInstance().isStompConnected()){ + logger.warn("Error stomp is not connected while trying to send dungeons scored"); + return; + } + + String target = null; + try { + target = StaticResourceCache.INSTANCE.getResource(StaticResourceCache.DATA_COLLECTION).get().getValue(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + + if (FeatureRegistry.ETC_COLLECT_SCORE.isEnabled() && !target.contains("falsefalsefalsefalse")) { + StompManager.getInstance().send(new StompPayload().payload(payload.toString()).destination(target.replace("false", "").trim())); + } + } + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java new file mode 100644 index 00000000..0e9254dd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java @@ -0,0 +1,108 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureDungeonCurrentRoomSecrets extends TextHUDFeature implements ChatListener { + public FeatureDungeonCurrentRoomSecrets() { + super("Dungeon.HUDs", "Display # Secrets in current room", "Display what your actionbar says", "dungeon.stats.secretsroom", true, getFontRenderer().getStringWidth("Secrets In Room: 8/8"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(false); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("currentSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("totalSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Secrets In Room","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("5","currentSecrets")); + dummyText.add(new StyledText("/","separator2")); + dummyText.add(new StyledText("8","totalSecrets")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("title", "separator", "currentSecrets", "separator2", "totalSecrets"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + private int latestCurrSecrets = 0; + private int latestTotalSecrets = 0; + + + @Override + public List getText() { + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getBossfightProcessor() != null) return new ArrayList(); + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Secrets In Room","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(latestCurrSecrets +"","currentSecrets")); + actualBit.add(new StyledText("/","separator2")); + actualBit.add(new StyledText(latestTotalSecrets +"","totalSecrets")); + return actualBit; + } + + @Override + public void onChat(ClientChatReceivedEvent chat) { + if (chat.type != 2) return; + String text = chat.message.getFormattedText(); + if (!text.contains("/")) return; + + int secretsIndex = text.indexOf("Secrets"); + if (secretsIndex != -1) { + int theindex = 0; + for (int i = secretsIndex; i >= 0; i--) { + if (text.startsWith("ยง7", i)) { + theindex = i; + } + } + String it = text.substring(theindex + 2, secretsIndex - 1); + + latestCurrSecrets = Integer.parseInt(it.split("/")[0]); + latestTotalSecrets = Integer.parseInt(it.split("/")[1]); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonDeaths.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonDeaths.java new file mode 100644 index 00000000..ca5a5cf7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonDeaths.java @@ -0,0 +1,168 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.events.impl.DungeonDeathEvent; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.*; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class FeatureDungeonDeaths extends TextHUDFeature implements ChatListener { + public FeatureDungeonDeaths() { + super("Dungeon.HUDs", "Display Deaths", "Display names of player and death count in dungeon run", "dungeon.stats.deaths", false, getFontRenderer().getStringWidth("longestplayernamepos: 100"), getFontRenderer().FONT_HEIGHT * 6); + this.setEnabled(false); + getStyles().add(new TextStyle("username", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("total", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("deaths", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("totalDeaths", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public boolean isHUDViewable() { + if (!skyblockStatus.isOnDungeon()) return false; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + return context != null; + } + + @Override + public boolean doesScaleWithHeight() { + return false; + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("username", "separator", "deaths", "total", "totalDeaths"); + } + + @Override + public List getText() { + + List text= new ArrayList(); + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + Map deaths = context.getDeaths(); + int i = 0; + int deathsCnt = 0; + for (Map.Entry death:deaths.entrySet()) { + text.add(new StyledText(death.getKey(),"username")); + text.add(new StyledText(": ","separator")); + text.add(new StyledText(death.getValue()+"\n","deaths")); + deathsCnt += death.getValue(); + } + text.add(new StyledText("Total Deaths","total")); + text.add(new StyledText(": ","separator")); + text.add(new StyledText(getTotalDeaths()+"","totalDeaths")); + + return text; + } + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("syeyoung","username")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("-130\n","deaths")); + dummyText.add(new StyledText("rioho","username")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("-999999\n","deaths")); + dummyText.add(new StyledText("dungeonsguide","username")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("-42\n","deaths")); + dummyText.add(new StyledText("penguinman","username")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("0\n","deaths")); + dummyText.add(new StyledText("probablysalt","username")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("0\n","deaths")); + dummyText.add(new StyledText("Total Deaths","total")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("0","totalDeaths")); + } + + @Override + public List getDummyText() { + return dummyText; + } + + public int getTotalDeaths() { + if (!skyblockStatus.isOnDungeon()) return 0; + for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { + String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); + if (name.contains("Deaths")) { + String whatever = TextUtils.keepIntegerCharactersOnly(TextUtils.keepScoreboardCharacters(TextUtils.stripColor(name))); + if (whatever.isEmpty()) break; + return Integer.parseInt(whatever); + } + } + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) return 0; + int d = 0; + for (Integer value : context.getDeaths().values()) { + d += value; + } + return d; + } + + Pattern deathPattern = Pattern.compile("ยงrยงc โ˜  (.+?)ยงrยง7 .+and became a ghost.+"); + Pattern meDeathPattern = Pattern.compile("ยงrยงc โ˜  ยงrยง7You .+and became a ghost.+"); + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (clientChatReceivedEvent.type == 2) return; + if (!skyblockStatus.isOnDungeon()) return; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) return; + + String txt = clientChatReceivedEvent.message.getFormattedText(); + Matcher m = deathPattern.matcher(txt); + if (m.matches()) { + String nickname = TextUtils.stripColor(m.group(1)); + int deaths = context.getDeaths().getOrDefault(nickname, 0); + context.getDeaths().put(nickname, deaths + 1); + context.createEvent(new DungeonDeathEvent(nickname, txt, deaths)); + ChatTransmitter.sendDebugChat(new ChatComponentText("Death verified :: "+nickname+" / "+(deaths + 1))); + } + Matcher m2 = meDeathPattern.matcher(txt); + if (m2.matches()) { + String nickname = "me"; + int deaths = context.getDeaths().getOrDefault(nickname, 0); + context.getDeaths().put(nickname, deaths + 1); + context.createEvent(new DungeonDeathEvent(Minecraft.getMinecraft().thePlayer.getName(), txt, deaths)); + ChatTransmitter.sendDebugChat(new ChatComponentText("Death verified :: me / "+(deaths + 1))); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMap.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMap.java new file mode 100644 index 00000000..135696e1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMap.java @@ -0,0 +1,508 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import com.google.common.collect.ComparisonChain; +import com.google.common.collect.Ordering; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.MapProcessor; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.BossroomEnterListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonEndListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonStartListener; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TabListUtil; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EnumPlayerModelParts; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.*; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.storage.MapData; +import org.jetbrains.annotations.Nullable; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import javax.vecmath.Vector2d; +import java.awt.*; +import java.util.List; + +public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, DungeonStartListener, BossroomEnterListener { + private AColor backgroudColor; + private AColor playerColor; + private boolean shouldCacheMap; + private float playerHeadScale; + private boolean shouldShowOtherPlayers; + private float textScale; + private boolean showSecretCount; + private boolean showPlayerHeads; + private boolean shouldRotateWithPlayer; + private boolean shouldScale; + private float postscaleOfMap; + private boolean centerMapOnPlayer; + + public FeatureDungeonMap() { + super("Dungeon", "Dungeon Map", "Display dungeon map!", "dungeon.map", true, 128, 128); + this.setEnabled(false); + addParameter("scale", new FeatureParameter<>("scale", "Scale map", "Whether to scale map to fit screen", true, "boolean", nval -> shouldScale = nval)); + addParameter("cacheMap", new FeatureParameter<>("cacheMap", "Should cache map data", "name", true, "boolean", nval -> shouldCacheMap = nval)); + addParameter("playerCenter", new FeatureParameter<>("playerCenter", "Center map at player", "Render you in the center", false, "boolean", nval -> centerMapOnPlayer = nval)); + addParameter("rotate", new FeatureParameter<>("rotate", "Rotate map centered at player", "Only works with Center map at player enabled", false, "boolean", nval -> shouldRotateWithPlayer = nval)); + addParameter("postScale", new FeatureParameter<>("postScale", "Scale factor of map", "Only works with Center map at player enabled", 1.0f, "float", nval -> postscaleOfMap = nval)); + addParameter("useplayerheads", new FeatureParameter<>("useplayerheads", "Use player heads instead of arrows", "Option to use player heads instead of arrows", true, "boolean", nval -> showPlayerHeads = nval)); + addParameter("showotherplayers", new FeatureParameter<>("showotherplayers", "Show other players", "Option to show other players in map", true, "boolean", nval -> shouldShowOtherPlayers = nval)); + addParameter("showtotalsecrets", new FeatureParameter<>("showtotalsecrets", "Show Total secrets in the room", "Option to overlay total secrets in the specific room", true, "boolean", nval -> showSecretCount = nval)); + addParameter("playerheadscale", new FeatureParameter<>("playerheadscale", "Player head scale", "Scale factor of player heads, defaults to 1", 1.0f, "float", nval -> playerHeadScale = nval)); + addParameter("textScale", new FeatureParameter<>("textScale", "Text scale", "Scale factor of texts on map, defaults to 1", 1.0f, "float", nval -> textScale = nval)); + + addParameter("border_color", new FeatureParameter<>("border_color", "Color of the border", "Same as name", new AColor(255, 255, 255, 255), "acolor")); + addParameter("background_color", new FeatureParameter<>("background_color", "Color of the background", "Same as name", new AColor(0x22000000, true), "acolor", nval -> backgroudColor = nval)); + addParameter("player_color", new FeatureParameter<>("player_color", "Color of the player border", "Same as name", new AColor(255, 255, 255, 0), "acolor", nval -> playerColor = nval)); + } + + public static final Ordering sorter = Ordering.from((compare1, compare2) -> { + ScorePlayerTeam scoreplayerteam = compare1.getPlayerTeam(); + ScorePlayerTeam scoreplayerteam1 = compare2.getPlayerTeam(); + return ComparisonChain.start().compareTrueFirst(compare1.getGameType() != WorldSettings.GameType.SPECTATOR, compare2.getGameType() != WorldSettings.GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getRegisteredName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getRegisteredName() : "").compare(compare1.getGameProfile().getName(), compare2.getGameProfile().getName()).result(); + }); + + private boolean on = false; + + @Override + public void onDungeonEnd() { + on = false; + } + + @Override + public void onDungeonStart() { + on = true; + } + + @Override + public void onBossroomEnter() { + on = false; + } + + @Override + public void drawHUD(float partialTicks) { + if (!on) return; + if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null || !context.getMapProcessor().isInitialized()) return; + + MapProcessor mapProcessor = context.getMapProcessor(); + MapData mapData = mapProcessor.getLatestMapData(); + Rectangle featureRect = getFeatureRect().getRectangle(); + Gui.drawRect(0, 0, featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, backgroudColor)); + GlStateManager.color(1, 1, 1, 1); + GlStateManager.pushMatrix(); + if (mapData == null) { + Gui.drawRect(0, 0, featureRect.width, featureRect.height, 0xFFFF0000); + } else { + renderMap(partialTicks, mapProcessor, mapData, context); + } + GlStateManager.popMatrix(); + GL11.glLineWidth(2); + RenderUtils.drawUnfilledBox(0, 0, featureRect.width, featureRect.height, this.getParameter("border_color").getValue()); + } + + @Override + public void drawDemo(float partialTicks) { + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon() && context != null && context.getMapProcessor().isInitialized() && on) { + drawHUD(partialTicks); + return; + } + Rectangle featureRect = getFeatureRect().getRectangle(); + Gui.drawRect(0, 0, featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, backgroudColor)); + FontRenderer fr = getFontRenderer(); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Please join a dungeon to see preview", featureRect.width / 2 - fr.getStringWidth("Please join a dungeon to see preview") / 2, featureRect.height / 2 - fr.FONT_HEIGHT / 2, 0xFFFFFFFF); + GL11.glLineWidth(2); + RenderUtils.drawUnfilledBox(0, 0, featureRect.width, featureRect.height, this.getParameter("border_color").getValue()); + } + + public void renderMap(float partialTicks, MapProcessor mapProcessor, MapData mapData, DungeonContext context) { + EntityPlayer p = Minecraft.getMinecraft().thePlayer; + + float postScale = this.centerMapOnPlayer ? postscaleOfMap : 1; + + Rectangle featureRect = getFeatureRect().getRectangle(); + int width = featureRect.width; + + float scale = shouldScale ? width / 128.0f : 1; + + GlStateManager.translate(width / 2d, width / 2d, 0); + GlStateManager.scale(scale, scale, 0); + GlStateManager.scale(postScale, postScale, 0); + + Vector2d pt = mapProcessor.worldPointToMapPointFLOAT(p.getPositionEyes(partialTicks)); + double yaw = p.rotationYaw; + if (this.centerMapOnPlayer) { + if (this.shouldRotateWithPlayer) { + GlStateManager.rotate((float) (180.0 - yaw), 0, 0, 1); + } + GlStateManager.translate(-pt.x, -pt.y, 0); + } else { + GlStateManager.translate(-64, -64, 0); + } + + updateMapTexture(mapData.colors, mapProcessor, context.getDungeonRoomList()); + + render(); + + + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(1, 771, 0, 1); + + if (this.showPlayerHeads) { + renderHeads(mapProcessor, mapData, scale, postScale, partialTicks); + } else { + renderArrows(mapData, scale, postScale); + } + + + FontRenderer fr = getFontRenderer(); + if (this.showSecretCount) { + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + GlStateManager.pushMatrix(); + + Point mapPt = mapProcessor.roomPointToMapPoint(dungeonRoom.getUnitPoints().get(0)); + GlStateManager.translate(mapPt.x + mapProcessor.getUnitRoomDimension().width / 2d, mapPt.y + mapProcessor.getUnitRoomDimension().height / 2d, 0); + + if (this.centerMapOnPlayer && this.shouldRotateWithPlayer) { + GlStateManager.rotate((float) (yaw - 180), 0, 0, 1); + } + GlStateManager.scale(1 / scale, 1 / scale, 0); + GlStateManager.scale(1 / postScale, 1 / postScale, 0); + GlStateManager.scale(textScale, textScale, 0); + String str = ""; + if (dungeonRoom.getTotalSecrets() == -1) { + str += "? "; + } else if (dungeonRoom.getTotalSecrets() != 0) { + str += dungeonRoom.getTotalSecrets() + " "; + } + + DungeonRoom.RoomState currentState = dungeonRoom.getCurrentState(); + switch (currentState) { + case FINISHED: + case COMPLETE_WITHOUT_SECRETS: + str += "โœ”"; + break; + case DISCOVERED: + str += "โ˜"; + break; + case FAILED: + str += "โŒ"; + break; + } + + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (currentState == DungeonRoom.RoomState.FINISHED) { + fr.drawString(str, -(fr.getStringWidth(str) / 2), -(fr.FONT_HEIGHT / 2), 0xFF00FF00); + } else { + if (dungeonRoom.getColor() == 74) { + fr.drawString(str, -(fr.getStringWidth(str) / 2), -(fr.FONT_HEIGHT / 2), 0xff000000); + } else { + fr.drawString(str, -(fr.getStringWidth(str) / 2), -(fr.FONT_HEIGHT / 2), 0xFFFFFFFF); + } + } + + GlStateManager.popMatrix(); + } + } + + } + + + private final DynamicTexture mapTexture = new DynamicTexture(128, 128); + private final ResourceLocation generatedMapTexture = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("dungeonmap/map", mapTexture); + private final int[] mapTextureData = mapTexture.getTextureData(); + + private void updateMapTexture(byte[] colors, MapProcessor mapProcessor, List dungeonRooms) { + + if(shouldCacheMap){ + if(!didMapChange(dungeonRooms)){ + return; + } + } + + + for (int i = 0; i < 16384; ++i) { + int j = colors[i] & 255; + + if (j / 4 == 0) { + this.mapTextureData[i] = 0x00000000; + } else { + this.mapTextureData[i] = MapColor.mapColorArray[j / 4].getMapColor(j & 3); + } + } + + if (this.showSecretCount) { + for (DungeonRoom dungeonRoom : dungeonRooms) { + for (Point pt : dungeonRoom.getUnitPoints()) { + for (int y1 = 0; y1 < mapProcessor.getUnitRoomDimension().height; y1++) { + for (int x1 = 0; x1 < mapProcessor.getUnitRoomDimension().width; x1++) { + int x = MathHelper.clamp_int(pt.x * (mapProcessor.getUnitRoomDimension().width + mapProcessor.getDoorDimensions().height) + x1 + mapProcessor.getTopLeftMapPoint().x, 0, 128); + int y = MathHelper.clamp_int(pt.y * (mapProcessor.getUnitRoomDimension().height + mapProcessor.getDoorDimensions().height) + y1 + mapProcessor.getTopLeftMapPoint().y, 0, 128); + int i = y * 128 + x; + int j = dungeonRoom.getColor(); + + if (j / 4 == 0) { + this.mapTextureData[i] = 0x00000000; + } else { + this.mapTextureData[i] = MapColor.mapColorArray[j / 4].getMapColor(j & 3); + } + } + } + } + } + } + + + this.mapTexture.updateDynamicTexture(); + } + + int[] lastRoomColors = new int[50]; + + int[] lastRoomSecrets = new int[50]; + + private boolean didMapChange(List dungeonRooms) { + int[] currentRoomColors = new int[50]; + int[] currentRoomSecrets = new int[50]; + + for (int i = 0; i < dungeonRooms.size(); i++) { + DungeonRoom dungeonRoom = dungeonRooms.get(i); + + currentRoomSecrets[i] = dungeonRoom.getTotalSecrets(); + currentRoomColors[i] = dungeonRoom.getColor(); + + } + + for (int i = 0; i < 50; i++) { + if(lastRoomColors[i] != currentRoomColors[i] || lastRoomSecrets[i] != currentRoomSecrets[i]) { + lastRoomColors = currentRoomColors; + lastRoomSecrets = currentRoomSecrets; + return true; + } + } + + lastRoomColors = currentRoomColors; + lastRoomSecrets = currentRoomSecrets; + return false; + } + + @Nullable + public Tuple> loadPlayerList() { + String[] names = new String[21]; + + List networkList = sorter.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); + if (networkList.size() < 40) return null; + + for (int i = 0; i < 20; i++) { + names[i] = TabListUtil.getPlayerNameWithChecks(networkList.get(i)); + } + + return new Tuple<>(names, networkList); + } + + long nextRefresh; + + Tuple> playerListCached; + + public Tuple> getPlayerListCached(){ + if(playerListCached == null || nextRefresh <= System.currentTimeMillis()){ + ChatTransmitter.sendDebugChat("Refreshing players on map"); + playerListCached = loadPlayerList(); + nextRefresh = System.currentTimeMillis() + 10000; + } + return playerListCached; + } + + + private void renderHeads(MapProcessor mapProcessor, MapData mapData, float scale, float postScale, float partialTicks) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + + Tuple> playerList = getPlayerListCached(); + + List networkList = playerList.getSecond(); + String[] names = playerList.getFirst(); + + + + // 21 iterations bc we only want to scan the player part of tab list + for (int i = 1; i < 20; i++) { + NetworkPlayerInfo networkPlayerInfo = networkList.get(i); + + String name = names[i]; + if (name == null) continue; + + + EntityPlayer entityplayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(name); + + Vector2d pt2 = null; + double yaw2 = 0; + + if (entityplayer != null && (!entityplayer.isInvisible() || entityplayer == thePlayer)) { + // getting location from player entity + pt2 = mapProcessor.worldPointToMapPointFLOAT(entityplayer.getPositionEyes(partialTicks)); + yaw2 = entityplayer.prevRotationYawHead + (entityplayer.rotationYawHead - entityplayer.prevRotationYawHead) * partialTicks; + if(DungeonsGuide.getDungeonsGuide().verbose) System.out.println("Got player location from entity"); + } +// else { +// // getting player location from map +// String iconName = mapProcessor.getMapIconToPlayerMap().get(name); +// if (iconName != null) { +// Vec4b vec = mapData.mapDecorations.get(iconName); +// if (vec != null) { +// System.out.println("Got player location from map"); +// pt2 = new Vector2d(vec.func_176112_b() / 2d + 64, vec.func_176113_c() / 2d + 64); +// yaw2 = vec.func_176111_d() * 360 / 16.0f; +// } else { +// System.out.println("Failed getting location from map, vec is null"); +// } +// } else { +// System.out.println("Failed getting location from map, icon name is null"); +// } +// } + + if(pt2 == null) return; + + if (entityplayer == thePlayer || shouldShowOtherPlayers) { + drawHead(scale, postScale, networkPlayerInfo, entityplayer, pt2, (float) yaw2); + } + + } + } + + /** + * @param scale Scale of the map + * @param postScale + * @param networkPlayerInfo + * @param entityplayer + * @param pt2 + * @param yaw2 + */ + private void drawHead(float scale, float postScale, NetworkPlayerInfo networkPlayerInfo, EntityPlayer entityplayer, Vector2d pt2, float yaw2) { + GlStateManager.pushMatrix(); + boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE); + GlStateManager.enableTexture2D(); + Minecraft.getMinecraft().getTextureManager().bindTexture(networkPlayerInfo.getLocationSkin()); + int l2 = 8 + (flag1 ? 8 : 0); + int i3 = 8 * (flag1 ? -1 : 1); + + GlStateManager.translate(pt2.x, pt2.y, 0); + GlStateManager.rotate(yaw2, 0, 0, 1); + + GlStateManager.scale(1 / scale, 1 / scale, 0); + GlStateManager.scale(1 / postScale, 1 / postScale, 0); + + GlStateManager.scale(playerHeadScale, playerHeadScale, 0); + + // cutting out the player head out of the skin texture + Gui.drawScaledCustomSizeModalRect(-4, -4, 8.0F, l2, 8, i3, 8, 8, 64.0F, 64.0F); + GL11.glLineWidth(1); + RenderUtils.drawUnfilledBox(-4, -4, 4, 4, this.playerColor); + GlStateManager.popMatrix(); + } + + + private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png"); + + private void renderArrows(MapData mapData, float scale, float postScale) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + int k = 0; + Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons); + for (Vec4b vec4b : mapData.mapDecorations.values()) { + if (vec4b.func_176110_a() == 1 || this.shouldShowOtherPlayers) { + GlStateManager.pushMatrix(); + GlStateManager.translate(vec4b.func_176112_b() / 2.0F + 64.0F, vec4b.func_176113_c() / 2.0F + 64.0F, -0.02F); + GlStateManager.rotate((vec4b.func_176111_d() * 360) / 16.0F, 0.0F, 0.0F, 1.0F); + + GlStateManager.scale(1 / scale, 1 / scale, 0); + GlStateManager.scale(1 / postScale, 1 / postScale, 0); + GlStateManager.scale(this.playerHeadScale * 5, this.playerHeadScale * 5, 0); + + GlStateManager.translate(-0.125F, 0.125F, 0.0F); + byte b0 = vec4b.func_176110_a(); + float f1 = (b0 % 4) / 4.0F; + float f2 = (b0 / 4f) / 4.0F; + float f3 = (b0 % 4 + 1) / 4.0F; + float f4 = (b0 / 4f + 1) / 4.0F; + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(-1.0D, 1.0D, k * -0.001F).tex(f1, f2).endVertex(); + worldrenderer.pos(1.0D, 1.0D, k * -0.001F).tex(f3, f2).endVertex(); + worldrenderer.pos(1.0D, -1.0D, k * -0.001F).tex(f3, f4).endVertex(); + worldrenderer.pos(-1.0D, -1.0D, k * -0.001F).tex(f1, f4).endVertex(); + tessellator.draw(); + GlStateManager.popMatrix(); + ++k; + } + } + } + + private void render() { + int i = 0; + int j = 0; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + float f = 0.0F; + Minecraft.getMinecraft().getTextureManager().bindTexture(this.generatedMapTexture); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(1, 771, 0, 1); + GlStateManager.disableAlpha(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos((i) + f, (j + 128) - f, -0.009999999776482582D).tex(0.0D, 1.0D).endVertex(); + worldrenderer.pos((i + 128) - f, (j + 128) - f, -0.009999999776482582D).tex(1.0D, 1.0D).endVertex(); + worldrenderer.pos((i + 128) - f, (j) + f, -0.009999999776482582D).tex(1.0D, 0.0D).endVertex(); + worldrenderer.pos((i) + f, (j) + f, -0.009999999776482582D).tex(0.0D, 0.0D).endVertex(); + tessellator.draw(); + GlStateManager.enableAlpha(); + GlStateManager.disableBlend(); + + GlStateManager.pushMatrix(); + GlStateManager.translate(0.0F, 0.0F, -0.04F); + GlStateManager.scale(1.0F, 1.0F, 1.0F); + GlStateManager.popMatrix(); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMilestone.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMilestone.java new file mode 100644 index 00000000..270b1d75 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonMilestone.java @@ -0,0 +1,110 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +public class FeatureDungeonMilestone extends TextHUDFeature implements ChatListener { + public FeatureDungeonMilestone() { + super("Dungeon.HUDs", "Display Current Class Milestone", "Display current class milestone of yourself", "dungeon.stats.milestone", true, getFontRenderer().getStringWidth("Milestone: 12"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(false); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Milestone","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("9","number")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("title", "separator", "number"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public List getText() { + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Milestone","title")); + actualBit.add(new StyledText(": ","separator")); + for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { + String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); + if (name.startsWith("ยงr Milestone: ยงr")) { + String milestone = TextUtils.stripColor(name).substring(13); + actualBit.add(new StyledText(milestone+"","number")); + break; + } + } + return actualBit; + } + + public static final Pattern milestone_pattern = Pattern.compile("ยงrยงeยงl(.+) Milestone ยงrยงe(.)ยงrยง7: .+ ยงrยงa(.+)ยงr"); + + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (clientChatReceivedEvent.type == 2) return; + if (!skyblockStatus.isOnDungeon()) return; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) return; + String txt = clientChatReceivedEvent.message.getFormattedText(); + if (milestone_pattern.matcher(txt).matches()) { + context.getMilestoneReached().add(new String[] { + TextUtils.formatTime(FeatureRegistry.DUNGEON_REALTIME.getTimeElapsed()), + TextUtils.formatTime(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed()) + }); + ChatTransmitter.sendDebugChat(new ChatComponentText("Reached Milestone At " + TextUtils.formatTime(FeatureRegistry.DUNGEON_REALTIME.getTimeElapsed()) + " / "+TextUtils.formatTime(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed()))); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRealTime.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRealTime.java new file mode 100644 index 00000000..68117523 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRealTime.java @@ -0,0 +1,91 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonQuitListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonStartListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureDungeonRealTime extends TextHUDFeature implements DungeonStartListener, DungeonQuitListener { + public FeatureDungeonRealTime() { + super("Dungeon.HUDs", "Display Real Time-Dungeon Time", "Display how much real time has passed since dungeon run started", "dungeon.stats.realtime", true, getFontRenderer().getStringWidth("Time(Real): 59m 59s"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(false); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("discriminator", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + private long started = -1; + + public long getTimeElapsed() { + return System.currentTimeMillis() - started; + } + + private static final java.util.List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Time","title")); + dummyText.add(new StyledText("(Real)","discriminator")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("-42h","number")); + } + + @Override + public boolean isHUDViewable() { + return started != -1; + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("title", "discriminator", "separator", "number"); + } + + @Override + public java.util.List getDummyText() { + return dummyText; + } + + @Override + public java.util.List getText() { + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Time","title")); + actualBit.add(new StyledText("(Real)","discriminator")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(TextUtils.formatTime(getTimeElapsed()),"number")); + return actualBit; + } + + @Override + public void onDungeonStart() { + started= System.currentTimeMillis(); + } + + @Override + public void onDungeonQuit() { + started = -1; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRoomName.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRoomName.java new file mode 100644 index 00000000..d0bea24f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonRoomName.java @@ -0,0 +1,95 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureDungeonRoomName extends TextHUDFeature { + public FeatureDungeonRoomName() { + super("Dungeon.HUDs", "Display name of the room you are in", "Display name of the room you are in", "dungeon.roomname", false, getFontRenderer().getStringWidth("You're in puzzle-tictactoe"), getFontRenderer().FONT_HEIGHT); + getStyles().add(new TextStyle("in", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("roomname", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + public int getTotalSecretsInt() { + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + int totalSecrets = 0; + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + if (dungeonRoom.getTotalSecrets() != -1) + totalSecrets += dungeonRoom.getTotalSecrets(); + } + return totalSecrets; + } + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("You're in ","in")); + dummyText.add(new StyledText("puzzle-tictactoe","roomname")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() != null && DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getMapProcessor() != null; + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("roomname", "in"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public List getText() { + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + + Point roomPt = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getMapProcessor().worldPointToRoomPoint(player.getPosition()); + DungeonRoom dungeonRoom = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getRoomMapper().get(roomPt); + List actualBit = new ArrayList(); + actualBit.add(new StyledText("You're in ","in")); + if (dungeonRoom == null) { + actualBit.add(new StyledText("Unknown","roomname")); + } else { + actualBit.add(new StyledText(dungeonRoom.getDungeonRoomInfo().getName(),"roomname")); + } + + + return actualBit; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSBTime.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSBTime.java new file mode 100644 index 00000000..437ed653 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSBTime.java @@ -0,0 +1,119 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +public class FeatureDungeonSBTime extends TextHUDFeature { + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + public FeatureDungeonSBTime() { + super("Dungeon.HUDs", "Display Ingame Dungeon Time", "Display how much time skyblock thinks has passed since dungeon run started", "dungeon.stats.igtime", true, getFontRenderer().getStringWidth("Time(IG): 1h 59m 59s"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(false); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("discriminator", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + public int getTimeElapsed() { + Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + Collection scores = scoreboard.getSortedScores(objective); + String time = "idkyet"; + for (Score sc:scores) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); + if (strippedLine.startsWith("Time Elapsed: ")) { + time = strippedLine.substring(14); + } + } + time = time.replace(" ", ""); + int hour = time.indexOf('h') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('h'))); + if (time.contains("h")) time = time.substring(time.indexOf('h') + 1); + int minute = time.indexOf('m') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('m'))); + if (time.contains("m")) time = time.substring(time.indexOf('m') + 1); + int second = time.indexOf('s') == -1 ? 0 : Integer.parseInt(time.substring(0, time.indexOf('s'))); + + int time2 = hour * 60 * 60 + minute * 60 + second; + return time2 * 1000; + } + + private static final java.util.List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Time","title")); + dummyText.add(new StyledText("(Ig)","discriminator")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("-42h","number")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("title", "discriminator", "separator", "number"); + } + + @Override + public java.util.List getDummyText() { + return dummyText; + } + + @Override + public java.util.List getText() { + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Time","title")); + actualBit.add(new StyledText("(Ig)","discriminator")); + actualBit.add(new StyledText(": ","separator")); + Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + Collection scores = scoreboard.getSortedScores(objective); + String time = "unknown"; + for (Score sc:scores) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String strippedLine = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()))).trim(); + if (strippedLine.startsWith("Time Elapsed: ")) { + time = strippedLine.substring(14); + } + } + actualBit.add(new StyledText(time,"number")); + return actualBit; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonScore.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonScore.java new file mode 100644 index 00000000..79f6ee21 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonScore.java @@ -0,0 +1,351 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TimeScoreUtil; +import kr.syeyoung.dungeonsguide.mod.wsresource.StaticResource; +import kr.syeyoung.dungeonsguide.mod.wsresource.StaticResourceCache; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.MathHelper; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +public class FeatureDungeonScore extends TextHUDFeature { + public FeatureDungeonScore() { + super("Dungeon.HUDs", "Display Current Score", "Calculate and Display current score\nThis data is from pure calculation and can be different from actual score.", "dungeon.stats.score", false, 200, getFontRenderer().FONT_HEIGHT * 4); + this.setEnabled(false); + addParameter("verbose", new FeatureParameter("verbose", "Show each score instead of sum", "Skill: 100 Explore: 58 S->S+(5 tombs) instead of Score: 305", true, "boolean")); + + getStyles().add(new TextStyle("scorename", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("score", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("brackets", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("etc", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("currentScore", new AColor(0xFF, 0xAA,0x00,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("arrow", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("nextScore", new AColor(0xFF, 0xAA,0x00,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("required", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + private static final java.util.List dummyText= new ArrayList(); + private static final java.util.List dummyText2= new ArrayList(); + static { + dummyText.add(new StyledText("Score","scorename")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("305 ","score")); + dummyText.add(new StyledText("(","brackets")); + dummyText.add(new StyledText("S+","currentScore")); + dummyText.add(new StyledText(")","brackets")); + + + + dummyText2.add(new StyledText("Skill","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("100 ","score")); + dummyText2.add(new StyledText("(","brackets")); + dummyText2.add(new StyledText("0 Deaths","etc")); + dummyText2.add(new StyledText(")\n","brackets")); + dummyText2.add(new StyledText("Explorer","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("99 ","score")); + dummyText2.add(new StyledText("(","brackets")); + dummyText2.add(new StyledText("Rooms O Secrets 39/40","etc")); + dummyText2.add(new StyledText(")\n","brackets")); + dummyText2.add(new StyledText("Time","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("100 ","score")); + dummyText2.add(new StyledText("Bonus","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("0 ","score")); + dummyText2.add(new StyledText("Total","scorename")); + dummyText2.add(new StyledText(": ","separator")); + dummyText2.add(new StyledText("299\n","score")); + dummyText2.add(new StyledText("S","currentScore")); + dummyText2.add(new StyledText("->","arrow")); + dummyText2.add(new StyledText("S+ ","nextScore")); + dummyText2.add(new StyledText("(","brackets")); + dummyText2.add(new StyledText("1 Required 1 crypt","required")); + dummyText2.add(new StyledText(")","brackets")); + + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("scorename", "separator", "score", "brackets", "etc", "currentScore", "arrow", "nextScore", "required"); + + } + + @Override + public java.util.List getDummyText() { + + if (this.getParameter("verbose").getValue()) {return dummyText2;} else return dummyText; + } + + @Override + public java.util.List getText() { + List actualBit = new ArrayList(); + + ScoreCalculation score = calculateScore(); + if (score == null) return new ArrayList(); + int sum = score.time + score.skill + score.explorer + score.bonus; + if (this.getParameter("verbose").getValue()) { + actualBit.add(new StyledText("Skill", "scorename")); + actualBit.add(new StyledText(": ", "separator")); + actualBit.add(new StyledText(score.skill + " ", "score")); + actualBit.add(new StyledText("(", "brackets")); + actualBit.add(new StyledText(score.deaths + " Deaths", "etc")); + actualBit.add(new StyledText(")\n", "brackets")); + actualBit.add(new StyledText("Explorer", "scorename")); + actualBit.add(new StyledText(": ", "separator")); + actualBit.add(new StyledText(score.explorer + " ", "score")); + actualBit.add(new StyledText("(", "brackets")); + actualBit.add(new StyledText("Rooms " + (score.fullyCleared ? "O" : "X") + " Secrets " + score.secrets + "/" + score.effectiveTotalSecrets +" of "+score.getTotalSecrets() + (score.totalSecretsKnown ? "" : "?"), "etc")); + actualBit.add(new StyledText(")\n", "brackets")); + actualBit.add(new StyledText("Time", "scorename")); + actualBit.add(new StyledText(": ", "separator")); + actualBit.add(new StyledText(score.time + " ", "score")); + actualBit.add(new StyledText("Bonus", "scorename")); + actualBit.add(new StyledText(": ", "separator")); + actualBit.add(new StyledText(score.bonus + " ", "score")); + actualBit.add(new StyledText("Total", "scorename")); + actualBit.add(new StyledText(": ", "separator")); + actualBit.add(new StyledText(sum + "\n", "score")); + actualBit.addAll(buildRequirement(score)); + } else { + String letter = getLetter(sum); + actualBit.add(new StyledText("Score", "scorename")); + actualBit.add(new StyledText(": ", "separator")); + actualBit.add(new StyledText(sum + " ", "score")); + actualBit.add(new StyledText("(", "brackets")); + actualBit.add(new StyledText(letter, "currentScore")); + actualBit.add(new StyledText(")", "brackets")); + } + + return actualBit; + } + + @Data + @AllArgsConstructor + public static class ScoreCalculation { + private int skill, explorer, time, bonus, tombs; + private boolean fullyCleared; + private int secrets, totalSecrets, effectiveTotalSecrets; + private boolean totalSecretsKnown; + private int deaths; + } + + public int getCompleteRooms() { + for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { + String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); + if (name.startsWith("ยงr Completed Rooms: ยงr")) { + String milestone = TextUtils.stripColor(name).substring(18); + return Integer.parseInt(milestone); + } + } + return 0; + } + public int getTotalRooms() { + int compRooms = getCompleteRooms(); + if (compRooms == 0) return 100; + return (int) (100 * (compRooms / (double) DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getPercentage())); + } + public int getUndiscoveredPuzzles() { + int cnt = 0; + for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { + String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); + if (name.startsWith("ยงr ???: ")) { + cnt ++; + } + } + return cnt; + } + + public ScoreCalculation calculateScore() { + if (!skyblockStatus.isOnDungeon()) return null; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) return null; + if (!context.getMapProcessor().isInitialized()) return null; + + int skill = 100; + int deaths = 0; + { + deaths = FeatureRegistry.DUNGEON_DEATHS.getTotalDeaths(); + skill -= FeatureRegistry.DUNGEON_DEATHS.getTotalDeaths() * 2; + int totalCompRooms= 0; + int roomCnt = 0; + int roomSkillPenalty = 0; +// boolean bossroomIncomplete = true; + boolean traproomIncomplete = context.isTrapRoomGen(); + int incompletePuzzles = getUndiscoveredPuzzles(); + + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { +// if (dungeonRoom.getColor() == 74 && dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED) +// bossroomIncomplete = false; + if (dungeonRoom.getColor() == 62 && dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED) + traproomIncomplete = false; + if (dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED) + totalCompRooms += dungeonRoom.getUnitPoints().size(); + if (dungeonRoom.getColor() == 66 && (dungeonRoom.getCurrentState() == DungeonRoom.RoomState.DISCOVERED || dungeonRoom.getCurrentState() == DungeonRoom.RoomState.FAILED)) // INCOMPLETE PUZZLE ON MAP + incompletePuzzles++; + roomCnt += dungeonRoom.getUnitPoints().size(); + } + roomSkillPenalty += incompletePuzzles * 10; + if (context.getMapProcessor().getUndiscoveredRoom() != 0) + roomCnt = getTotalRooms(); + roomSkillPenalty += (roomCnt - totalCompRooms) * 4; +// if (bossroomIncomplete) roomSkillPenalty -=1; + if (traproomIncomplete) roomSkillPenalty -=1; + + + skill -= roomSkillPenalty; + + + + skill = MathHelper.clamp_int(skill, 0, 100); + } + int explorer = 0; + boolean fullyCleared = false; + boolean totalSecretsKnown = true; + int totalSecrets = 0; + int secrets = 0; + { + int completed = 0; + double total = 0; + + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + if (dungeonRoom.getCurrentState() != DungeonRoom.RoomState.DISCOVERED && dungeonRoom.getCurrentState() != DungeonRoom.RoomState.FAILED) + completed += dungeonRoom.getUnitPoints().size(); + total += dungeonRoom.getUnitPoints().size(); + } + + totalSecrets = FeatureRegistry.DUNGEON_SECRETS.getTotalSecretsInt() ; + totalSecretsKnown = FeatureRegistry.DUNGEON_SECRETS.sureOfTotalSecrets(); + + fullyCleared = completed >= getTotalRooms() && context.getMapProcessor().getUndiscoveredRoom() == 0; + explorer += MathHelper.clamp_int((int) Math.floor(6.0 / 10.0 * (context.getMapProcessor().getUndiscoveredRoom() != 0 ? DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getPercentage() : completed / total * 100)), 0, 60); + explorer += MathHelper.clamp_int((int) Math.floor(40 * (secrets = FeatureRegistry.DUNGEON_SECRETS.getSecretsFound()) / Math.ceil(totalSecrets * context.getSecretPercentage())),0,40); + } + int time = 0; + { + int maxTime = context.getMaxSpeed(); +// int timeSec = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000 - maxTime + 480; +// +// if (timeSec <= 480) time = 100; +// else if (timeSec <= 580) time = (int) Math.ceil(148 - 0.1 * timeSec); +// else if (timeSec <= 980) time = (int) Math.ceil(119 - 0.05 * timeSec); +// else if (timeSec < 3060) time = (int) Math.ceil(3102 - (1/30.0) * timeSec); +// time = MathHelper.clamp_int(time, 0, 100); // just in case. + time = TimeScoreUtil.estimate(FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed(), maxTime); + } + int bonus = 0; + int tombs; + { + bonus += tombs = MathHelper.clamp_int(FeatureRegistry.DUNGEON_TOMBS.getTombsFound(), 0, 5); + if (context.isGotMimic()) bonus += 2; + CompletableFuture staticResourceCompletableFuture = StaticResourceCache.INSTANCE.getResource(StaticResourceCache.BONUS_SCORE); + if (staticResourceCompletableFuture.isDone()) { + try { + bonus += Integer.parseInt(staticResourceCompletableFuture.get().getValue().trim()); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + } + + // amazing thing + return new ScoreCalculation(skill, explorer, time, bonus, tombs, fullyCleared, secrets, totalSecrets, (int)Math.ceil (totalSecrets * context.getSecretPercentage()), totalSecretsKnown, deaths); + } + public String getLetter(int score) { + if (score <= 99) return "D"; + if (score <= 159) return "C"; + if (score <= 229) return "B"; + if (score <= 269) return "A"; + if (score <= 299) return "S"; + return "S+"; + } + public int getScoreRequirement(String letter) { + if (letter.equals("D")) return 0; + if (letter.equals("C")) return 100; + if (letter.equals("B")) return 160; + if (letter.equals("A")) return 230; + if (letter.equals("S")) return 270; + if (letter.equals("S+")) return 300; + return -1; + } + public String getNextLetter(String letter) { + if (letter.equals("D")) return "C"; + if (letter.equals("C")) return "B"; + if (letter.equals("B")) return "A"; + if (letter.equals("A")) return "S"; + if (letter.equals("S")) return "S+"; + else return null; + } + public List buildRequirement(ScoreCalculation calculation) { + List actualBit = new ArrayList(); + int current = calculation.time + calculation.bonus + calculation.explorer + calculation.skill; + String currentLetter = getLetter(current); + String nextLetter= getNextLetter(currentLetter); + if (nextLetter == null) { + actualBit.add(new StyledText("S+ Expected","nextScore")); + return actualBit; + } + int req = getScoreRequirement(nextLetter); + int reqPT2 = req- current; + int reqPT = req - current; + + int tombsBreakable = Math.min(5 - calculation.tombs, reqPT); + reqPT -= tombsBreakable; + + double secretPer = 40.0 / calculation.effectiveTotalSecrets; + int secrets = (int) Math.ceil(reqPT / secretPer); + + actualBit.add(new StyledText(currentLetter,"currentScore")); + actualBit.add(new StyledText("->","arrow")); + actualBit.add(new StyledText(nextLetter+" ","nextScore")); + actualBit.add(new StyledText("(","brackets")); + actualBit.add(new StyledText(reqPT2+" required "+tombsBreakable+" crypt "+secrets+" secrets","required")); + actualBit.add(new StyledText(")","brackets")); + return actualBit; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSecrets.java new file mode 100644 index 00000000..a5a444c2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonSecrets.java @@ -0,0 +1,145 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureDungeonSecrets extends TextHUDFeature { + public FeatureDungeonSecrets() { + super("Dungeon.HUDs", "Display Total # of Secrets", "Display how much total secrets have been found in a dungeon run.\n+ sign means DG does not know the correct number, but it's somewhere above that number.", "dungeon.stats.secrets", true, getFontRenderer().getStringWidth("Secrets: 999/999+ of 999+"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(false); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("currentSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator2", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("totalSecrets", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("unknown", new AColor(0xFF, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + public int getSecretsFound() { + for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { + String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); + if (name.startsWith("ยงr Secrets Found: ยงrยงb") && !name.contains("%")) { + String noColor = TextUtils.stripColor(name); + return Integer.parseInt(noColor.substring(16)); + } + } + return 0; + } + public double getSecretPercentage() { + for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { + String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); + if (name.startsWith("ยงr Secrets Found: ยงr") && name.contains("%")) { + String noColor = TextUtils.stripColor(name); + return Double.parseDouble(noColor.substring(16).replace("%", "")); + } + } + return 0; + } + + public int getTotalSecretsInt() { + if (getSecretsFound() != 0) return (int) Math.ceil (getSecretsFound() / getSecretPercentage() * 100); + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + int totalSecrets = 0; + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + if (dungeonRoom.getTotalSecrets() != -1) + totalSecrets += dungeonRoom.getTotalSecrets(); + } + return totalSecrets; + } + public boolean sureOfTotalSecrets() { + if (getSecretsFound() != 0) return true; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context.getMapProcessor().getUndiscoveredRoom() > 0) return false; + boolean allknown = true; + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + if (dungeonRoom.getTotalSecrets() == -1) allknown = false; + } + return allknown; + } + + public String getTotalSecrets() { + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) return "?"; + int totalSecrets = 0; + boolean allknown = true; + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + if (dungeonRoom.getTotalSecrets() != -1) + totalSecrets += dungeonRoom.getTotalSecrets(); + else allknown = false; + } + return totalSecrets + (allknown ? "":"+"); + } + + + private static final java.util.List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Secrets","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("999","currentSecrets")); + dummyText.add(new StyledText("/","separator2")); + dummyText.add(new StyledText("2","totalSecrets")); + dummyText.add(new StyledText("+","unknown")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("title", "separator", "currentSecrets", "separator2", "totalSecrets", "unknown"); + } + + @Override + public java.util.List getDummyText() { + return dummyText; + } + + @Override + public java.util.List getText() { + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Secrets","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(getSecretsFound() +"","currentSecrets")); + actualBit.add(new StyledText("/","separator2")); + + actualBit.add(new StyledText((int)Math.ceil(getTotalSecretsInt() * DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getSecretPercentage())+" of "+getTotalSecretsInt(),"totalSecrets")); + actualBit.add(new StyledText(getTotalSecrets().contains("+") ? "+" : "","unknown")); + return actualBit; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonTombs.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonTombs.java new file mode 100644 index 00000000..3290b831 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureDungeonTombs.java @@ -0,0 +1,88 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureDungeonTombs extends TextHUDFeature { + public FeatureDungeonTombs() { + super("Dungeon.HUDs", "Display # of Crypts", "Display how much total crypts have been blown up in a dungeon run", "dungeon.stats.tombs", true, getFontRenderer().getStringWidth("Crypts: 42"), getFontRenderer().FONT_HEIGHT); + this.setEnabled(false); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + public int getTombsFound() { + for (NetworkPlayerInfo networkPlayerInfoIn : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) { + String name = networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName()); + if (name.startsWith("ยงr Crypts: ยงrยง6")) { + return Integer.parseInt(TextUtils.stripColor(name).substring(9)); + } + } + return 0; + } + + private static final java.util.List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Crypts","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("42","number")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("title", "separator", "number"); + } + + @Override + public java.util.List getDummyText() { + return dummyText; + } + + @Override + public java.util.List getText() { + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Crypts","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(getTombsFound()+"","number")); + return actualBit; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureHideNameTags.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureHideNameTags.java new file mode 100644 index 00000000..994a1891 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureHideNameTags.java @@ -0,0 +1,53 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.EntityLivingRenderListener; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraftforge.client.event.RenderLivingEvent; + + +public class FeatureHideNameTags extends SimpleFeature implements EntityLivingRenderListener { + public FeatureHideNameTags() { + super("Dungeon.Mobs", "Hide mob nametags", "Hide mob nametags in dungeon", "dungeon.hidenametag", false); + } + + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + @Override + public void onEntityRenderPre(RenderLivingEvent.Pre renderPlayerEvent) { + if (!isEnabled()) return; + if (!skyblockStatus.isOnDungeon()) return; + + if (renderPlayerEvent.entity instanceof EntityArmorStand) { + EntityArmorStand armorStand = (EntityArmorStand) renderPlayerEvent.entity; + if (armorStand.getAlwaysRenderNameTag()) + renderPlayerEvent.setCanceled(true); + } + } + + @Override + public void onEntityRenderPost(RenderLivingEvent.Post renderPlayerEvent) { + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeaturePlayerESP.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeaturePlayerESP.java new file mode 100644 index 00000000..5255ac7a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeaturePlayerESP.java @@ -0,0 +1,111 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.PlayerRenderListener; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.event.RenderPlayerEvent; +import org.lwjgl.opengl.GL11; + + +public class FeaturePlayerESP extends SimpleFeature implements PlayerRenderListener { + public FeaturePlayerESP() { + super("Dungeon.Teammates", "See players through walls", "See players through walls", "dungeon.playeresp", false); + setEnabled(false); + } + + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + private boolean preCalled = false; + @Override + public void onEntityRenderPre(RenderPlayerEvent.Pre renderPlayerEvent) { + + + if (preCalled) return; + if (!isEnabled()) return; + + + DungeonContext dungeonContext = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (dungeonContext == null) return; + if (!dungeonContext.getPlayers().contains(renderPlayerEvent.entityPlayer.getName())) { + return; + } + + preCalled = true; + + GL11.glEnable(GL11.GL_STENCIL_TEST); + GL11.glClearStencil(0); + GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); + + GL11.glStencilMask(0xFF); + GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); + + EntityPlayer entity = renderPlayerEvent.entityPlayer; + InventoryPlayer inv = entity.inventory; + ItemStack[] armor = inv.armorInventory; + inv.armorInventory = new ItemStack[4]; + ItemStack[] hand = inv.mainInventory; + inv.mainInventory = new ItemStack[36]; + + float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * renderPlayerEvent.partialRenderTick; + try { + renderPlayerEvent.renderer.doRender((AbstractClientPlayer) renderPlayerEvent.entityPlayer, renderPlayerEvent.x, renderPlayerEvent.y, renderPlayerEvent.z, f, renderPlayerEvent.partialRenderTick); + } catch (Throwable t) {} + + GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); + GL11.glStencilFunc(GL11.GL_NOTEQUAL, 1, 0xff); + GL11.glDepthMask(false); + GL11.glDepthFunc(GL11.GL_GEQUAL); + + GlStateManager.pushMatrix(); + GlStateManager.translate(renderPlayerEvent.x, renderPlayerEvent.y + 0.9, renderPlayerEvent.z); + GlStateManager.scale(1.2f, 1.1f, 1.2f); + renderPlayerEvent.renderer.setRenderOutlines(true); + try { + renderPlayerEvent.renderer.doRender((AbstractClientPlayer) renderPlayerEvent.entityPlayer, 0,-0.9,0, f, renderPlayerEvent.partialRenderTick); + } catch (Throwable t) {} + + renderPlayerEvent.renderer.setRenderOutlines(false); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GlStateManager.popMatrix(); + + GL11.glDisable(GL11.GL_STENCIL_TEST); // Turn this shit off! + + inv.armorInventory = armor; + inv.mainInventory = hand; + + preCalled = false; + + } + + @Override + public void onEntityRenderPost(RenderPlayerEvent.Post renderPlayerEvent) { + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java new file mode 100644 index 00000000..8ae1c3e5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java @@ -0,0 +1,89 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.impl.boss.FeatureChestPrice; +import kr.syeyoung.dungeonsguide.mod.features.listener.GuiClickListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.KeyInputListener; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraftforge.client.event.GuiScreenEvent; +import org.lwjgl.input.Mouse; + +public class FeaturePressAnyKeyToCloseChest extends SimpleFeature implements KeyInputListener, GuiClickListener { + public FeaturePressAnyKeyToCloseChest() { + super("Dungeon", "Press Any Mouse Button or Key to close Secret Chest", "dungeon.presskeytoclose"); + addParameter("threshold", new FeatureParameter("threshold", "Price Threshold", "The maximum price of item for chest to be closed. Default 1m", 1000000, "integer")); + } + + @Override + public void onKeyInput(GuiScreenEvent.KeyboardInputEvent keyboardInputEvent) { + GuiScreen screen = Minecraft.getMinecraft().currentScreen; + if (!isEnabled()) return; + if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + + if (screen instanceof GuiChest){ + ContainerChest ch = (ContainerChest) ((GuiChest)screen).inventorySlots; + if (!("Large Chest".equals(ch.getLowerChestInventory().getName()) + || "Chest".equals(ch.getLowerChestInventory().getName()))) return; + IInventory actualChest = ch.getLowerChestInventory(); + + int priceSum = 0; + for (int i = 0; i < actualChest.getSizeInventory(); i++) { + priceSum += FeatureChestPrice.getPrice(actualChest.getStackInSlot(i)); + } + + int threshold = this.getParameter("threshold").getValue(); + if (priceSum < threshold) { + Minecraft.getMinecraft().thePlayer.closeScreen(); + } + } + } + + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + GuiScreen screen = Minecraft.getMinecraft().currentScreen; + if (!isEnabled()) return; + if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + if (Mouse.getEventButton() == -1) return; + + if (screen instanceof GuiChest){ + ContainerChest ch = (ContainerChest) ((GuiChest)screen).inventorySlots; + if (!("Large Chest".equals(ch.getLowerChestInventory().getName()) + || "Chest".equals(ch.getLowerChestInventory().getName()))) return; + IInventory actualChest = ch.getLowerChestInventory(); + + int priceSum = 0; + for (int i = 0; i < actualChest.getSizeInventory(); i++) { + priceSum += FeatureChestPrice.getPrice(actualChest.getStackInSlot(i)); + } + + int threshold = this.getParameter("threshold").getValue(); + if (priceSum < threshold) { + Minecraft.getMinecraft().thePlayer.closeScreen(); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java new file mode 100644 index 00000000..a61d6966 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java @@ -0,0 +1,106 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + +public class FeatureWarnLowHealth extends TextHUDFeature { + public FeatureWarnLowHealth() { + super("Dungeon.Teammates", "Low Health Warning", "Warn if someone is on low health", "dungeon.lowhealthwarn", false, 500, 20); + addParameter("threshold", new FeatureParameter("threshold", "Health Threshold", "Health Threshold for this feature to be toggled. default to 500", 500, "integer")); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("unit", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + setEnabled(false); + } + + + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon(); + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("title", "separator", "number", "unit"); + } + + private static final java.util.List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("DungeonsGuide","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("500","number")); + dummyText.add(new StyledText("hp","unit")); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public List getText() { + String lowestHealthName = ""; + int lowestHealth = 999999999; + Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + for (Score sc : scoreboard.getSortedScores(objective)) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String line = ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()).trim(); + String stripped = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(line)); + if (line.contains("[") && line.endsWith("โค")) { + String name = stripped.split(" ")[stripped.split(" ").length - 2]; + int health = Integer.parseInt(stripped.split(" ")[stripped.split(" ").length - 1]); + if (health < lowestHealth) { + lowestHealth = health; + lowestHealthName = name; + } + } + } + if (lowestHealth > this.getParameter("threshold").getValue()) return new ArrayList(); + + List actualBit = new ArrayList(); + actualBit.add(new StyledText(lowestHealthName,"title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText(lowestHealth+"","number")); + actualBit.add(new StyledText("hp","unit")); + return actualBit; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWatcherWarning.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWatcherWarning.java new file mode 100644 index 00000000..5c931910 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWatcherWarning.java @@ -0,0 +1,87 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonEndListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; + +public class FeatureWatcherWarning extends TextHUDFeature implements ChatListener, DungeonEndListener { + + public FeatureWatcherWarning() { + super("Dungeon.Blood Room","Watcher Spawn Alert", "Alert when watcher says 'That will be enough for now'", "dungen.watcherwarn", true, getFontRenderer().getStringWidth("Watcher finished spawning all mobs!"), getFontRenderer().FONT_HEIGHT); + getStyles().add(new TextStyle("warning", new AColor(0xFF, 0x69,0x17,255), new AColor(0, 0,0,0), false)); + setEnabled(false); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public boolean isHUDViewable() { + return warning > System.currentTimeMillis(); + } + + @Override + public List getUsedTextStyle() { + return Collections.singletonList("warning"); + } + + private final UUID lastRoomUID = UUID.randomUUID(); + private long warning = 0; + + private static final List text = new ArrayList(); + static { + text.add(new StyledText("Watcher finished spawning all mobs!", "warning")); + } + + @Override + public List getText() { + return text; + } + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (clientChatReceivedEvent.message.getFormattedText().equals("ยงrยงc[BOSS] The Watcherยงrยงf: That will be enough for now.ยงr")) { + warning = System.currentTimeMillis() + 2500; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context ==null) return; + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + if (dungeonRoom != null && dungeonRoom.getColor() == 18) + dungeonRoom.setCurrentState(DungeonRoom.RoomState.DISCOVERED); + } + } + } + + @Override + public void onDungeonEnd() { + warning = 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureAutoAcceptReparty.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureAutoAcceptReparty.java new file mode 100644 index 00000000..7222f585 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureAutoAcceptReparty.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +public class FeatureAutoAcceptReparty extends SimpleFeature implements ChatListener { + public FeatureAutoAcceptReparty() { + super("Party.Reparty", "Auto accept reparty", "Automatically accept reparty", "qol.autoacceptreparty", true); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + private String lastDisband; + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (clientChatReceivedEvent.message.getFormattedText().endsWith("ยงehas disbanded the party!ยงr")) { + lastDisband = null; + String[] texts = TextUtils.stripColor(clientChatReceivedEvent.message.getFormattedText()).split(" "); + for (String s : texts) { + if (s.isEmpty()) continue; + if (s.startsWith("[")) continue; + if (s.equalsIgnoreCase("has")) break; + lastDisband = s; + break; + } + } else if (clientChatReceivedEvent.message.getFormattedText().contains("ยงehas invited you to join their party!")) { + String[] texts = TextUtils.stripColor(clientChatReceivedEvent.message.getFormattedText()).split(" "); + boolean equals = false; + for (String s : texts) { + if (s.isEmpty()) continue; + if (s.startsWith("[")) continue; + if (s.equalsIgnoreCase("has")) continue; + if (s.equalsIgnoreCase(lastDisband)) { + equals = true; + break; + } + } + + if (equals && isEnabled()) { + ChatProcessor.INSTANCE.addToChatQueue("/p accept " + lastDisband, () -> {}, true); + lastDisband = null; + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCooldownCounter.java new file mode 100644 index 00000000..ae740803 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCooldownCounter.java @@ -0,0 +1,96 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonQuitListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.GuiOpenListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.ContainerChest; +import net.minecraftforge.client.event.GuiOpenEvent; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureCooldownCounter extends TextHUDFeature implements DungeonQuitListener, GuiOpenListener { + public FeatureCooldownCounter() { + super("Dungeon", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, getFontRenderer().getStringWidth("Cooldown: 10s "), getFontRenderer().FONT_HEIGHT); + getStyles().add(new TextStyle("title", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + private long leftDungeonTime = 0L; + + private static final java.util.List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Cooldown","title")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("20s","number")); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public boolean isHUDViewable() { + return System.currentTimeMillis() - leftDungeonTime < 20000; + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("title", "separator", "number"); + } + + @Override + public List getText() { + List actualBit = new ArrayList(); + actualBit.add(new StyledText("Cooldown","title")); + actualBit.add(new StyledText(": ","separator")); + actualBit.add(new StyledText((20 - (System.currentTimeMillis() - leftDungeonTime) / 1000)+"s","number")); + return actualBit; + } + + @Override + public boolean doesScaleWithHeight() { + return true; + } + + @Override + public void onDungeonQuit() { + leftDungeonTime = System.currentTimeMillis(); + } + + @Override + public void onGuiOpen(GuiOpenEvent rendered) { + if (!(rendered.gui instanceof GuiChest)) return; + ContainerChest chest = (ContainerChest) ((GuiChest) rendered.gui).inventorySlots; + if (chest.getLowerChestInventory().getName().contains("On cooldown!")) { + leftDungeonTime = System.currentTimeMillis(); + } else if (chest.getLowerChestInventory().getName().contains("Error")) { + leftDungeonTime = System.currentTimeMillis(); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCopyMessages.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCopyMessages.java new file mode 100644 index 00000000..f4c3ef91 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureCopyMessages.java @@ -0,0 +1,42 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.HoverEvent; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +public class FeatureCopyMessages extends SimpleFeature implements ChatListener { + public FeatureCopyMessages() { + super("Misc.Chat", "Copy Chat Messages", "Click on copy to copy", "etc.copymsg"); + setEnabled(false); + } + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (!isEnabled()) return; + if (clientChatReceivedEvent.type == 2) return; + + clientChatReceivedEvent.message.appendSibling(new ChatComponentText(" ยง7[Copy]").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, TextUtils.stripColor(clientChatReceivedEvent.message.getFormattedText()))).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("ยงeCopy Message"))))); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureDecreaseExplosionSound.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureDecreaseExplosionSound.java new file mode 100644 index 00000000..aef65de2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureDecreaseExplosionSound.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.SoundListener; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraftforge.client.event.sound.PlaySoundEvent; + +public class FeatureDecreaseExplosionSound extends SimpleFeature implements SoundListener { + public FeatureDecreaseExplosionSound() { + super("Misc", "Decrease Explosion sound effect", "Decreases volume of explosions while on skyblock", "qol.explosionsound"); + addParameter("sound", new FeatureParameter("sound", "Sound Multiplier %", "The volume of explosion effect will be multiplied by this value. 0~100", 10.0f, "float")); + } + + @Override + public void onSound(PlaySoundEvent soundEvent) { + if (!SkyblockStatus.isOnSkyblock()) return; + + if (soundEvent.name.equalsIgnoreCase("random.explode") && soundEvent.result instanceof PositionedSoundRecord) { + PositionedSoundRecord positionedSoundRecord = (PositionedSoundRecord) soundEvent.result; + PositionedSoundRecord neweff = new PositionedSoundRecord( + positionedSoundRecord.getSoundLocation(), + positionedSoundRecord.getVolume() * (this.getParameter("sound").getValue() / 100), + positionedSoundRecord.getPitch(), + positionedSoundRecord.getXPosF(), + positionedSoundRecord.getYPosF(), + positionedSoundRecord.getZPosF() + ); + + soundEvent.result = neweff; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureDisableMessage.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureDisableMessage.java new file mode 100644 index 00000000..afce7bc7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureDisableMessage.java @@ -0,0 +1,77 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.regex.Pattern; + +public class FeatureDisableMessage extends SimpleFeature implements ChatListener { + @Data + @AllArgsConstructor + public static class MessageData { + private Pattern pattern; + private String name; + private String description; + private String key; + } + + private static final MessageData[] PRE_DEFINED = new MessageData[] { + new MessageData(Pattern.compile("ยงrยงcThere are blocks in the way!ยงr"), "Aote block message", "\"There are blocks in the way!\"", "aote"), + new MessageData(Pattern.compile("ยงrยงcThis ability is currently on cooldown for .+ more seconds?\\.ยงr"), "Ability cooldown message", "\"This ability is currently on cooldown for 3 more seconds.\"", "cooldown"), + new MessageData(Pattern.compile("ยงrยงcThis ability is on cooldown for .+s\\.ยงr"), "Ability cooldown message2", "\"This ability is on cooldown for 3s.\"", "cooldown2"), + new MessageData(Pattern.compile("ยงrยงcWhow! Slow down there!ยงr"), "Grappling hook cooldown", "\"Whow! Slow down there!\"", "grappling"), + new MessageData(Pattern.compile("ยงrยงcNo more charges, next one in ยงrยงe.+ยงrยงcs!ยงr"), "Zombie Sword Charging", "\"No more charges, next one in 3s!\"", "zombie"), + new MessageData(Pattern.compile("ยงrยง7Your .+ hit ยงrยงc.+ ยงrยง7enem(?:y|ies) for ยงrยงc.+ ยงrยง7damage\\.ยงr"), "Ability Damage", "\"Your blahblah hit 42 enemy for a lots of damage\"", "ability"), + new MessageData(Pattern.compile("ยงrยงcYou do not have enough mana to do this!ยงr"), "Not enough mana", "\"You do not have enough mana to do this!\"", "mana"), + new MessageData(Pattern.compile("ยงrยงaUsed ยงr.+ยงrยงa!ยงr"), "Dungeon Ability Usage", "\"Used Guided Sheep!\" and such", "dungeonability"), + new MessageData(Pattern.compile("ยงr.+ยงrยงa is ready to use! Press ยงr.+ยงrยงa to activate it!ยงr"), "Ready to use message", "\"Blah is ready to use! Press F to activate it!", "readytouse"), + new MessageData(Pattern.compile("ยงr.+ ยงrยงais now available!ยงr"), "Ability Available","\"blah is now available!\"", "available"), + new MessageData(Pattern.compile("ยงrยงcThe Stone doesn't seem to do anything here\\.ยงr"), "Stone Message", "\"The Stone doesn't seem to do anything here\"", "stone"), + new MessageData(Pattern.compile("ยงrยงcNo target found!ยงr"), "Voodoo Doll No Target", "\"No target found!\"", "voodotarget") + }; + + public FeatureDisableMessage() { + super("Misc.Chat", "Disable ability messages", "Do not let ability messages show up in chatbox\nclick on Edit for more precise settings", "fixes.messagedisable", true); + for (MessageData messageData : PRE_DEFINED) { + addParameter(messageData.key, new FeatureParameter(messageData.key, messageData.name, messageData.description, true, "boolean")); + } + } + + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (clientChatReceivedEvent.type == 2) return; + if (!isEnabled()) return; + if (!SkyblockStatus.isOnSkyblock()) return; + String msg = clientChatReceivedEvent.message.getFormattedText(); + for (MessageData md:PRE_DEFINED) { + if (this.getParameter(md.key).getValue() && md.pattern.matcher(msg).matches()) { + clientChatReceivedEvent.setCanceled(true); + return; + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureEpicCountdown.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureEpicCountdown.java new file mode 100644 index 00000000..f88b2884 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureEpicCountdown.java @@ -0,0 +1,156 @@ +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessResult; +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.utils.ScoreBoardUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TitleRender; +import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.util.Map; +import java.util.Objects; + +import static kr.syeyoung.dungeonsguide.mod.chat.ChatProcessResult.NONE; +import static kr.syeyoung.dungeonsguide.mod.chat.ChatProcessResult.REMOVE_CHAT; + +/** + * CREDITS FOR THE COUNTDOWN SOUNDTRACK: ... + */ +public class FeatureEpicCountdown extends SimpleFeature { + + static volatile long updatedAt; + static volatile int secondsLeft; + private static boolean cleanChat; + private boolean sfxenabled; + + int actualSecondsLeft; + + public FeatureEpicCountdown() { + super("Dungeon.HUDs", "Epic Dungeon Start Countdown", "Shows a cool dungeon start instead of the chat messages", "etc.dungeoncountdown", true); + addParameter("cleanchat", new FeatureParameter<>("cleanchat", "Clean Dungeon Chat", "^^^", true, "boolean", nval -> cleanChat = nval)); + addParameter("sounds", new FeatureParameter<>("sounds", "Countdown SFX", "^^^", true, "boolean", nval -> sfxenabled = nval)); + + lastSec = GO_TEXT; + + ChatProcessor.INSTANCE.subscribe(FeatureEpicCountdown::processChat); + MinecraftForge.EVENT_BUS.register(this); + } + + public static ChatProcessResult processChat(String txt, Map context) { + if(cleanChat){ + if(txt.startsWith("ยงe[NPC] ยงbMortยงf: ยงrTalk to me to change your class and ready up.ยงr")){ + return REMOVE_CHAT; + } + if(txt.startsWith("ยงrยงaYour active Potion Effects have been paused and stored.")){ + return REMOVE_CHAT; + } + if(txt.startsWith("ยงe[NPC] ยงbMortยงf: ยงrGood luck.ยงr")){ + return REMOVE_CHAT; + } + if(txt.startsWith("ยงe[NPC] ยงbMortยงf: ยงrYou should find it useful if you get lost.ยงr")){ + return REMOVE_CHAT; + } + if(TextUtils.stripColor(txt).contains("[NPC] Mort: Here, I found this map")){ + return REMOVE_CHAT; + } + if(txt.startsWith("ยงrยงa[Berserk] ยงrยงf")){ + return REMOVE_CHAT; + } + } + + + if (txt.startsWith("ยงrยงaDungeon starts in")) { + String striped = TextUtils.stripColor(txt); + + String secondsStr = striped.replace("Dungeon starts in ", ""); + secondsStr = secondsStr.replace(" seconds.", ""); + secondsStr = secondsStr.replace(" second.", ""); + + secondsLeft = Integer.parseInt(secondsStr); + updatedAt = System.currentTimeMillis(); + + return REMOVE_CHAT; + } + + return NONE; + + } + + static final String GO_TEXT = "GO!!!"; + String lastSec; + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent e){ + if(e.phase != TickEvent.Phase.START || !isEnabled() || !DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + + + ScoreBoardUtils.forEachLineClean(line -> { + if(line.contains("Starting in:")){ + String time = line.replace("Starting in: ", "").replace("ยงr", "").replace("0:", ""); + if(!time.isEmpty()){ + secondsLeft = Integer.parseInt(time); + updatedAt = System.currentTimeMillis(); + } + } + }); + + +// www.hypixel.netยงr +// ยงr +// Starting in: 0:57ยงr +// ยงr +// B kokoniara Lv25ยงr +// ยงr +// The Catacombs F3ยงr +// Late Winter 3rdยงr +// ยงr +// 10/22/22 m65G 28266ยงr + + } + + + @SubscribeEvent + public void onRender(RenderGameOverlayEvent.Post postRender) { + if (!isEnabled()) return; + if (!(postRender.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || postRender.type == RenderGameOverlayEvent.ElementType.JUMPBAR)) + return; + + long timepassed = System.currentTimeMillis() - updatedAt; + + long secs = timepassed / 1000; + + int actualSecondspassed = (int) secs; + actualSecondsLeft = secondsLeft - actualSecondspassed; + if (actualSecondsLeft <= 0) { + if(!Objects.equals(lastSec, GO_TEXT)){ + lastSec = GO_TEXT; + TitleRender.displayTitle(lastSec, "", 2, 25, 15); + } + return; + } + + String string = "ยงc" + actualSecondsLeft; + + if(!Objects.equals(string, lastSec)){ + if(actualSecondsLeft == 3 && sfxenabled){ + Minecraft.getMinecraft().thePlayer.playSound("skyblock_dungeons_guide:readysetgo", 1F, 1F); + } + if(actualSecondsLeft > 5){ + TitleRender.displayTitle(string, "", 1, 10, 8); + }else{ + TitleRender.displayTitle(string, "", 1, 6, 4); + } + lastSec = string; + } + + } + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeaturePenguins.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeaturePenguins.java new file mode 100644 index 00000000..64f2bfe8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeaturePenguins.java @@ -0,0 +1,168 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import com.google.common.collect.ImmutableMap; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.PlayerRenderListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.TextureStichListener; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.*; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.client.model.obj.OBJLoader; +import net.minecraftforge.client.model.obj.OBJModel; + +import java.io.IOException; + + +public class FeaturePenguins extends SimpleFeature implements PlayerRenderListener, TextureStichListener { + public FeaturePenguins() { + super("Misc", "Penguins", "Awwww", "etc.penguin", false); + OBJLoader.instance.addDomain("dungeonsguide"); + + } + @Override + public void onTextureStitch(TextureStitchEvent event) { + if (event instanceof TextureStitchEvent.Pre) { + objModel = null; + ResourceLocation modelResourceLocation = new ResourceLocation("dungeonsguide:models/penguin.obj"); + try { + objModel = (OBJModel) OBJLoader.instance.loadModel(modelResourceLocation); + objModel = (OBJModel) objModel.process(new ImmutableMap.Builder().put("flip-v", "true").build()); + for (String obj : objModel.getMatLib().getMaterialNames()) { + ResourceLocation resourceLocation = objModel.getMatLib().getMaterial(obj).getTexture().getTextureLocation(); + event.map.registerSprite(resourceLocation); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + if (objModel != null && event instanceof TextureStitchEvent.Post) { + model = objModel.bake(objModel.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); + } + } + + + private OBJModel objModel; + private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + private IBakedModel model; + + @Override + public void onEntityRenderPre(RenderPlayerEvent.Pre renderPlayerEvent) { + + if (!isEnabled()) return; + if (renderPlayerEvent.entityPlayer.isInvisible()) return; + renderPlayerEvent.setCanceled(true); + GlStateManager.pushMatrix(); + GlStateManager.color(1,1,1,1); + GlStateManager.translate(renderPlayerEvent.x, renderPlayerEvent.y, renderPlayerEvent.z); + if (renderPlayerEvent.entityPlayer.isSneaking()) + { + GlStateManager.translate(0.0F, -0.203125F, 0.0F); + } + float f1 = renderPlayerEvent.entityPlayer.prevRotationYawHead + (renderPlayerEvent.entityPlayer.rotationYawHead - renderPlayerEvent.entityPlayer.prevRotationYawHead) * renderPlayerEvent.partialRenderTick; + GlStateManager.rotate(f1+180,0,-1,0); + Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + + Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor( + model, 1,1,1,1 + ); + GlStateManager.popMatrix(); + + + EntityPlayer entitylivingbaseIn = renderPlayerEvent.entityPlayer; + { + ItemStack itemstack = entitylivingbaseIn.getHeldItem(); + + if (itemstack != null) + { + GlStateManager.pushMatrix(); + GlStateManager.translate(renderPlayerEvent.x, renderPlayerEvent.y, renderPlayerEvent.z); + if (renderPlayerEvent.entityPlayer.isSneaking()) + { + GlStateManager.translate(0.0F, -0.203125F, 0.0F); + } + GlStateManager.rotate(f1+180, 0.0f, -1.0f, 0.0f); + GlStateManager.translate(0,1.30 ,-0.5); + + + + if (entitylivingbaseIn.fishEntity != null) + { + itemstack = new ItemStack(Items.fishing_rod, 0); + } + + Item item = itemstack.getItem(); + Minecraft minecraft = Minecraft.getMinecraft(); + + GlStateManager.rotate(180, 0.0f, 0.0f, 1.0f); + if (item.isFull3D()) { + GlStateManager.translate(0.05,0,0); + GlStateManager.rotate(90, 0.0f, 0.0f, 1.0f); + GlStateManager.rotate(-45, 1.0f, 0.0f, 0.0f); + } else if (item instanceof ItemBow) { + GlStateManager.translate(0,0.1, -0); + GlStateManager.rotate(90, 0.0f, 1.0f, 0.0f); + GlStateManager.rotate(-90, 0.0f, 0.0f, 1.0f); + } else if (item instanceof ItemBlock && Block.getBlockFromItem(item).getRenderType() == 2) { + GlStateManager.translate(0,-0.20,0.1); + GlStateManager.translate(0.0F, 0.1875F, -0.3125F); + GlStateManager.rotate(-25.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F); + f1 = 0.375F; + GlStateManager.scale(-f1, -f1, f1); + } else if (item instanceof ItemBlock) { + GlStateManager.translate(0.0F, 0.05, 0.1); + GlStateManager.rotate(-25.0F, 1.0F, 0.0F, 0.0F); + } else { + GlStateManager.translate(0,-0.1, 0.1); + } + + GlStateManager.scale(0.8,0.8,0.8); + + minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON); + GlStateManager.popMatrix(); + } + } + + + renderPlayerEvent.renderer.renderName((AbstractClientPlayer) renderPlayerEvent.entityPlayer, renderPlayerEvent.x, renderPlayerEvent.y, renderPlayerEvent.z); + + + } + + @Override + public void onEntityRenderPost(RenderPlayerEvent.Post renderPlayerEvent) { + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureRepartyCommand.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureRepartyCommand.java new file mode 100644 index 00000000..0392d663 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureRepartyCommand.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureRepartyCommand extends SimpleFeature { + public FeatureRepartyCommand() { + super("Party.Reparty", "Enable Reparty Command From DG", "if you disable, /dg reparty will still work, Auto reparty will still work\nRequires Restart to get applied", "qol.reparty"); + addParameter("command", new FeatureParameter("command", "The Command", "Command that the reparty will be bound to", "reparty", "string")); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureTooltipDungeonStat.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureTooltipDungeonStat.java new file mode 100644 index 00000000..c58143d5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureTooltipDungeonStat.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.TooltipListener; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +public class FeatureTooltipDungeonStat extends SimpleFeature implements TooltipListener { + public FeatureTooltipDungeonStat() { + super("Misc", "Dungeon Item Stats", "Shows quality of dungeon items (floor, percentage)", "tooltip.dungeonitem"); + } + + @Override + public void onTooltip(ItemTooltipEvent event) { + if (!isEnabled()) return; + + ItemStack hoveredItem = event.itemStack; + NBTTagCompound compound = hoveredItem.getTagCompound(); + if (compound == null) + return; + if (!compound.hasKey("ExtraAttributes")) + return; + NBTTagCompound nbtTagCompound = compound.getCompoundTag("ExtraAttributes"); + + int floor = nbtTagCompound.getInteger("item_tier"); + int percentage = nbtTagCompound.getInteger("baseStatBoostPercentage"); + + if (nbtTagCompound.hasKey("item_tier")) + event.toolTip.add("ยง7Obtained in: ยงc"+(floor == 0 ? "Entrance" : "Floor "+floor)); + if (nbtTagCompound.hasKey("baseStatBoostPercentage")) + event.toolTip.add("ยง7Stat Percentage: ยง"+(percentage == 50 ? "6ยงl":"c")+(percentage * 2)+"%"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureTooltipPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureTooltipPrice.java new file mode 100644 index 00000000..419db805 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureTooltipPrice.java @@ -0,0 +1,111 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.TooltipListener; +import kr.syeyoung.dungeonsguide.mod.utils.AhUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import org.lwjgl.input.Keyboard; + +import java.util.Comparator; +import java.util.Set; +import java.util.TreeSet; + +public class FeatureTooltipPrice extends SimpleFeature implements TooltipListener { + public FeatureTooltipPrice() { + super("Misc.API Features", "Item Price", "Shows price of items", "tooltip.price"); + addParameter("reqShift", new FeatureParameter("reqShift", "Require Shift", "If shift needs to be pressed in order for this feature to be activated", false, "boolean")); + setEnabled(false); + } + + @Override + public void onTooltip(ItemTooltipEvent event) { + if (!isEnabled()) return; + + boolean activated = !this.getParameter("reqShift").getValue() || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + + ItemStack hoveredItem = event.itemStack; + NBTTagCompound compound = hoveredItem.getTagCompound(); + if (compound == null) + return; + if (!compound.hasKey("ExtraAttributes")) + return; + if (!activated) { + event.toolTip.add("ยง7Shift to view price"); + return; + } + + final String id = compound.getCompoundTag("ExtraAttributes").getString("id"); + if (id.equals("ENCHANTED_BOOK")) { + final NBTTagCompound enchants = compound.getCompoundTag("ExtraAttributes").getCompoundTag("enchantments"); + Set keys = enchants.getKeySet(); + Set actualKeys = new TreeSet(new Comparator() { + public int compare(String o1, String o2) { + String id2 = id + "::" + o1 + "-" + enchants.getInteger(o1); + AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); + long price1 = (auctionData == null) ? 0 : auctionData.lowestBin; + String id3 = id + "::" + o2 + "-" + enchants.getInteger(o2); + AhUtils.AuctionData auctionData2 = AhUtils.auctions.get(id3); + long price2 = (auctionData2 == null) ? 0 : auctionData2.lowestBin; + return (compare2(price1, price2) == 0) ? o1.compareTo(o2) : compare2(price1, price2); + } + + public int compare2(long y, long x) { + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } + }); + actualKeys.addAll(keys); + int totalLowestPrice = 0; + int iterations = 0; + for (String key : actualKeys) { + iterations++; + String id2 = id + "::" + key + "-" + enchants.getInteger(key); + AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); + if (auctionData == null) { + if (iterations < 10) + event.toolTip.add("ยงf"+ key + " " + enchants.getInteger(key) + "ยง7: ยงcn/a"); + continue; + } + if (iterations < 10) + event.toolTip.add("ยงf"+ key + " " + enchants.getInteger(key) + "ยง7: ยงe"+ TextUtils.format( auctionData.lowestBin)); + totalLowestPrice += auctionData.lowestBin; + } + if (iterations >= 10) + event.toolTip.add("ยง7"+ (iterations - 10) + " more enchants... "); + event.toolTip.add("ยงfTotal Lowestยง7: ยงe"+ TextUtils.format(totalLowestPrice)); + } else { + AhUtils.AuctionData auctionData = AhUtils.auctions.get(id); + event.toolTip.add(""); + if (auctionData == null) { + event.toolTip.add("ยงfLowest ah ยง7: ยงcn/a"); + event.toolTip.add("ยงfBazaar sell price ยง7: ยงcn/a"); + event.toolTip.add("ยงfBazaar buy price ยง7: ยงcn/a"); + } else { + event.toolTip.add("ยงfLowest ah ยง7: " + ((auctionData.lowestBin != -1) ? ("ยงe"+ TextUtils.format(auctionData.lowestBin)) : "ยงcn/a")); + event.toolTip.add("ยงfBazaar sell price ยง7: " + ((auctionData.sellPrice == -1) ? "ยงcn/a": ("ยงe"+ TextUtils.format(auctionData.sellPrice)))); + event.toolTip.add("ยงfBazaar buy price ยง7: " + ((auctionData.buyPrice == -1) ? "ยงcn/a": ("ยงe"+ TextUtils.format(auctionData.buyPrice)))); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureUpdateAlarm.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureUpdateAlarm.java new file mode 100644 index 00000000..74b8eed8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/FeatureUpdateAlarm.java @@ -0,0 +1,56 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.events.impl.StompConnectedEvent; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.StompConnectedListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.TickListener; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ChatComponentText; + +public class FeatureUpdateAlarm extends SimpleFeature implements StompConnectedListener, TickListener { + public FeatureUpdateAlarm() { + super("Misc", "Update Alarm","Show a warning in chat when a version has been released.", "etc.updatealarm", true); + } + + private String stompPayload; + @Override + public void onTick() { + if (stompPayload != null) { + ChatTransmitter.addToQueue(new ChatComponentText(stompPayload)); + stompPayload = null; + Minecraft.getMinecraft().thePlayer.playSound("random.successful_hit", 1f,1f); + } + } + + @Override + public void onStompConnected(StompConnectedEvent event) { + + event.getStompInterface().subscribe("/topic/updates", (stompClient ,payload) -> { + this.stompPayload = payload; + }); + + event.getStompInterface().subscribe("/user/queue/messages", (stompClient ,payload) -> { + this.stompPayload = payload; + }); + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/FeatureAbilityCooldown.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/FeatureAbilityCooldown.java new file mode 100644 index 00000000..c19b42b2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/FeatureAbilityCooldown.java @@ -0,0 +1,402 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc.ability; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.TickListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class FeatureAbilityCooldown extends TextHUDFeature implements ChatListener, TickListener { + + public FeatureAbilityCooldown() { + super("Misc", "View Ability Cooldowns", "A handy hud for viewing cooldown abilities", "etc.abilitycd2", false, 100, getFontRenderer().FONT_HEIGHT * 5); + getStyles().add(new TextStyle("abilityname", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("unit",new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("ready",new AColor(0xDF, 0x00,0x67,255), new AColor(0, 0,0,0), false)); + addParameter("disable", new FeatureParameter("disable", "Disable outside of dungeon", "Disable the feature when out of dungeon", false, "boolean")); + addParameter("decimal", new FeatureParameter("decimal", "Decimal places", "ex) 2 -> Cooldown: 3.21 3-> Cooldown: 3.210", 0, "integer")); + } + + @Override + public boolean isHUDViewable() { + return SkyblockStatus.isOnSkyblock() && (!this.getParameter("disable").getValue() || (this.getParameter("disable").getValue() && SkyblockStatus.isOnSkyblock())); + } + + @Override + public boolean doesScaleWithHeight() { + return false; + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("abilityname", "separator", "number", "unit", "ready"); + } + + private static final List dummy = new ArrayList<>(); + + static { + dummy.add(new StyledText("Random Ability", "abilityname")); + dummy.add(new StyledText(": ", "separator")); + dummy.add(new StyledText("10", "number")); + dummy.add(new StyledText("s\n", "unit")); + dummy.add(new StyledText("Random Ability2", "abilityname")); + dummy.add(new StyledText(": ", "separator")); + dummy.add(new StyledText("10", "number")); + dummy.add(new StyledText("m ", "unit")); + dummy.add(new StyledText("9", "number")); + dummy.add(new StyledText("s\n", "unit")); + dummy.add(new StyledText("Random Ability", "abilityname")); + dummy.add(new StyledText(": ", "separator")); + dummy.add(new StyledText("READY", "ready")); + } + + @Override + public List getDummyText() { + return dummy; + } + + private static final Map skyblockAbilities = new HashMap<>(); + private static final Map> skyblockAbilitiesByItemID = new HashMap<>(); + + static { + register(new SkyblockAbility("Disgusting Healing", -1, -1, "REAPER_MASK")); + register(new SkyblockAbility("Spirit Leap", -1, 5, "SPIRIT_LEAP")); + register(new SkyblockAbility("Farmer's Grace", -1, -1, "RANCHERS_BOOTS")); + register(new SkyblockAbility("Raise Souls", -1, 1, "SUMMONING_RING")); + register(new SkyblockAbility("Instant Heal", 70, -1, "FLORID_ZOMBIE_SWORD")); + register(new SkyblockAbility("Phantom Impel", -1, -1, "PHANTOM_ROD")); + register(new SkyblockAbility("Implosion", 300, 10, "IMPLOSION_SCROLL")); + register(new SkyblockAbility("Parley", -1, 5, "ASPECT_OF_THE_JERRY")); + register(new SkyblockAbility("Guided Bat", 250, -1, "BAT_WAND")); + register(new SkyblockAbility("Bat Swarm", -1, -1, "WITCH_MASK")); + register(new SkyblockAbility("Flay", -1, -1, "SOUL_WHIP")); + register(new SkyblockAbility("Instant Heal", 70, -1, "ZOMBIE_SWORD")); + register(new SkyblockAbility("Mithril's Protection", -1, -1, "MITHRIL_COAT")); + register(new SkyblockAbility("Second Wind", -1, 30, "SPIRIT_MASK")); + register(new SkyblockAbility("Love Tap", -1, -1, "ZOMBIE_SOLDIER_CUTLASS")); + register(new SkyblockAbility("Spiky", -1, -1, "PUFFERFISH_HAT")); + register(new SkyblockAbility("Jingle Bells", -1, 1, "JINGLE_BELLS")); + register(new SkyblockAbility("Wither Shield", 150, 10, "WITHER_SHIELD_SCROLL")); + register(new SkyblockAbility("Wither Impact", 150, 5, "WITHER_SHIELD_SCROLL")); + register(new SkyblockAbility("Brute Force", -1, -1, "WARDEN_HELMET")); + register(new SkyblockAbility("Growth", -1, 4, "GROWTH_LEGGINGS")); + register(new SkyblockAbility("Shadowstep", -1, 60, "SILENT_DEATH")); + register(new SkyblockAbility("Creeper Veil", -1, -1, "WITHER_CLOAK")); + register(new SkyblockAbility("Ice Bolt", 50, -1, "FROZEN_SCYTHE")); + register(new SkyblockAbility("Rapid-fire", 10, -1, "JERRY_STAFF")); + register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_HELMET_NEW")); + register(new SkyblockAbility("Mist Aura", -1, -1, "SORROW_BOOTS")); + register(new SkyblockAbility("Deploy", -1, -1, "RADIANT_POWER_ORB")); + register(new SkyblockAbility("Ice Spray", 50, 5, "ICE_SPRAY_WAND")); + register(new SkyblockAbility("Grand... Zapper?", -1, -1, "BLOCK_ZAPPER")); + register(new SkyblockAbility("Seek the King", -1, 5, "ROYAL_PIGEON")); + register(new SkyblockAbility("Mist Aura", -1, -1, "SORROW_CHESTPLATE")); + register(new SkyblockAbility("Healing Boost", -1, -1, "REVIVED_HEART")); + register(new SkyblockAbility("Deploy", -1, -1, "OVERFLUX_POWER_ORB")); + register(new SkyblockAbility("Swing", -1, -1, "BONE_BOOMERANG")); + register(new SkyblockAbility("Growth", -1, 4, "GROWTH_CHESTPLATE")); + register(new SkyblockAbility("Squash 'em", -1, -1, "RECLUSE_FANG")); + register(new SkyblockAbility("Roll em'", -1, -1, "PUMPKIN_DICER")); + register(new SkyblockAbility("Cleave", -1, -1, "SUPER_CLEAVER")); + register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_BOOTS_NEW")); + register(new SkyblockAbility("Farmer's Delight", -1, -1, "BASKET_OF_SEEDS")); + register(new SkyblockAbility("Block Damage", -1, 60, "GUARDIAN_CHESTPLATE")); + register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_LEGGINGS")); + register(new SkyblockAbility("Bone Shield", -1, -1, "SKELETON_HELMET")); + register(new SkyblockAbility("Iron Punch", 70, 3, "GOLEM_SWORD")); + register(new SkyblockAbility("Built-in Storage", -1, -1, "BUILDERS_WAND")); + register(new SkyblockAbility("Nasty Bite", -1, -1, "MOSQUITO_BOW")); + register(new SkyblockAbility("Ender Warp", 50, 45, "ENDER_BOW")); + register(new SkyblockAbility("Cleave", -1, -1, "CLEAVER")); + register(new SkyblockAbility("Party Time!", -1, -1, "PARTY_HAT_CRAB")); + register(new SkyblockAbility("Giant's Slam", 100, 30, "GIANTS_SWORD")); + register(new SkyblockAbility("Snow Placer", -1, -1, "SNOW_SHOVEL")); + register(new SkyblockAbility("Greed", -1, -1, "MIDAS_SWORD")); + register(new SkyblockAbility("Clownin' Around", -1, 316, "STARRED_BONZO_MASK")); + register(new SkyblockAbility("Weather", -1, 5, "WEATHER_STICK")); + register(new SkyblockAbility("ME SMASH HEAD", 100, -1, "EDIBLE_MACE")); + register(new SkyblockAbility("Splash", 10, 1, "FISH_HAT")); + register(new SkyblockAbility("Deploy", -1, -1, "PLASMAFLUX_POWER_ORB")); + register(new SkyblockAbility("Dragon Rage", 100, -1, "ASPECT_OF_THE_DRAGON")); + register(new SkyblockAbility("Burning Souls", 400, -1, "PIGMAN_SWORD")); + register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_CHESTPLATE_NEW")); + register(new SkyblockAbility("Fire Blast", 150, 30, "EMBER_ROD")); + register(new SkyblockAbility("Commander Whip", -1, -1, "ZOMBIE_COMMANDER_WHIP")); + register(new SkyblockAbility("Spooktacular", -1, -1, "GHOUL_BUSTER")); + register(new SkyblockAbility("Cleave", -1, -1, "HYPER_CLEAVER")); + register(new SkyblockAbility("Leap", 50, 1, "SILK_EDGE_SWORD")); + register(new SkyblockAbility("Throw", 150, 5, "LIVID_DAGGER")); + register(new SkyblockAbility("Raise Souls", -1, 1, "NECROMANCER_SWORD")); + register(new SkyblockAbility("Double Jump", 50, -1, "SPIDER_BOOTS")); + register(new SkyblockAbility("Speed Boost", 50, -1, "ROGUE_SWORD")); + register(new SkyblockAbility("Spirit Glide", 250, 60, "THORNS_BOOTS")); + register(new SkyblockAbility("Sting", 100, -1, "STINGER_BOW")); + register(new SkyblockAbility("Roll em'", -1, -1, "MELON_DICER")); + register(new SkyblockAbility("Explosive Shot", -1, -1, "EXPLOSIVE_BOW")); + register(new SkyblockAbility("Heat-Seeking Rose", 35, 1, "FLOWER_OF_TRUTH")); + register(new SkyblockAbility("Small Heal", 60, 1, "WAND_OF_HEALING")); + register(new SkyblockAbility("Dreadlord", 40, -1, "CRYPT_DREADLORD_SWORD")); + register(new SkyblockAbility("Shadow Fury", -1, 15, "STARRED_SHADOW_FURY")); + register(new SkyblockAbility("Double Jump", 40, -1, "TARANTULA_BOOTS")); + register(new SkyblockAbility("Acupuncture", 200, 5, "VOODOO_DOLL")); + register(new SkyblockAbility("Showtime", 100, -1, "STARRED_BONZO_STAFF")); + register(new SkyblockAbility("Heartstopper", -1, -1, "SCORPION_FOIL")); + register(new SkyblockAbility("Rapid Fire", -1, 100, "MACHINE_GUN_BOW")); + register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_HELMET")); + register(new SkyblockAbility("Alchemist's Bliss", -1, -1, "NETHER_WART_POUCH")); + register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_CHESTPLATE")); + register(new SkyblockAbility("Instant Heal", 70, -1, "ORNATE_ZOMBIE_SWORD")); + register(new SkyblockAbility("Shadow Fury", -1, 15, "SHADOW_FURY")); + register(new SkyblockAbility("Healing Boost", -1, -1, "ZOMBIE_HEART")); + register(new SkyblockAbility("Witherlord", 40, 3, "CRYPT_WITHERLORD_SWORD")); + register(new SkyblockAbility("Revive", -1, -1, "REVIVE_STONE")); + register(new SkyblockAbility("Raise Souls", -1, 1, "REAPER_SCYTHE")); + register(new SkyblockAbility("Rejuvenate", -1, -1, "VAMPIRE_MASK")); + register(new SkyblockAbility("Mist Aura", -1, -1, "SORROW_HELMET")); + register(new SkyblockAbility("Place Dirt", -1, -1, "INFINIDIRT_WAND")); + register(new SkyblockAbility("Clownin' Around", -1, 360, "BONZO_MASK")); + register(new SkyblockAbility("Shadow Warp", 300, 10, "SHADOW_WARP_SCROLL")); + register(new SkyblockAbility("Molten Wave", 500, 1, "MIDAS_STAFF")); + register(new SkyblockAbility("Growth", -1, 4, "GROWTH_HELMET")); + register(new SkyblockAbility("Howl", 150, 20, "WEIRD_TUBA")); + register(new SkyblockAbility("Medium Heal", 80, 1, "WAND_OF_MENDING")); + register(new SkyblockAbility("Throw", 20, -1, "AXE_OF_THE_SHREDDED")); + register(new SkyblockAbility("Ink Bomb", 60, 30, "INK_WAND")); + register(new SkyblockAbility("Whassup?", -1, -1, "AATROX_BATPHONE")); + register(new SkyblockAbility("Deploy", -1, -1, "MANA_FLUX_POWER_ORB")); + register(new SkyblockAbility("Extreme Focus", -1, -1, "END_STONE_BOW")); + register(new SkyblockAbility("Healing Boost", -1, -1, "CRYSTALLIZED_HEART")); + register(new SkyblockAbility("Mist Aura", -1, -1, "SORROW_LEGGINGS")); + register(new SkyblockAbility("Showtime", 100, -1, "BONZO_STAFF")); + register(new SkyblockAbility("Triple Shot", -1, -1, "RUNAANS_BOW")); + register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_LEGGINGS_NEW")); + register(new SkyblockAbility("Rejuvenate", -1, -1, "VAMPIRE_WITCH_MASK")); + register(new SkyblockAbility("Terrain Toss", 250, 1, "YETI_SWORD")); + register(new SkyblockAbility("Instant Transmission", 50, -1, "ASPECT_OF_THE_END")); + register(new SkyblockAbility("Ether Transmission", 180, -1, "ASPECT_OF_THE_END")); + register(new SkyblockAbility("Ether Transmission", 180, -1, "ASPECT_OF_THE_VOID")); + register(new SkyblockAbility("Detonate", -1, 60, "CREEPER_LEGGINGS")); + register(new SkyblockAbility("Extreme Focus", -1, -1, "END_STONE_SWORD")); + register(new SkyblockAbility("Leap", 50, 1, "LEAPING_SWORD")); + register(new SkyblockAbility("Fun Guy Bonus", -1, -1, "FUNGI_CUTTER")); + register(new SkyblockAbility("Cleave", -1, -1, "GIANT_CLEAVER")); + register(new SkyblockAbility("Tempest", -1, -1, "HURRICANE_BOW")); + register(new SkyblockAbility("Big Heal", 100, 1, "WAND_OF_RESTORATION")); + register(new SkyblockAbility("Growth", -1, 4, "GROWTH_BOOTS")); + register(new SkyblockAbility("Stinger", 150, -1, "SCORPION_BOW")); + register(new SkyblockAbility("Eye Beam", -1, -1, "PRECURSOR_EYE")); + register(new SkyblockAbility("Water Burst", 20, -1, "SALMON_BOOTS")); + register(new SkyblockAbility("Mining Speed Boost", -1, 120, null)); + register(new SkyblockAbility("Pikobulus", -1, 110, null)); + // abilities + + register(new SkyblockAbility("Healing Circle", -1, 2, "DUNGEON_STONE")); + register(new SkyblockAbility("Wish", -1, 120, "DUNGEON_STONE")); + register(new SkyblockAbility("Guided Sheep", -1, 30, "DUNGEON_STONE")); + register(new SkyblockAbility("Thunderstorm", -1, 500, "DUNGEON_STONE")); + register(new SkyblockAbility("Throwing Axe", -1, 10, "DUNGEON_STONE")); + register(new SkyblockAbility("Ragnarok", -1, 60, "DUNGEON_STONE")); + register(new SkyblockAbility("Explosive Shot", -1, 40, "DUNGEON_STONE")); + register(new SkyblockAbility("Rapid Fire", -1, 100, "DUNGEON_STONE")); + register(new SkyblockAbility("Seismic Wave", -1, 15, "DUNGEON_STONE")); + register(new SkyblockAbility("Castle of Stone", -1, 150, "DUNGEON_STONE")); + } + + static void register(SkyblockAbility skyblockAbility) { + if (!skyblockAbilities.containsKey(skyblockAbility.getName())) + skyblockAbilities.put(skyblockAbility.getName(), skyblockAbility); + if (skyblockAbility.getItemId() != null && skyblockAbility.getCooldown() != -1) { + List skyblockAbility1 = skyblockAbilitiesByItemID.computeIfAbsent(skyblockAbility.getItemId(), (a) -> new ArrayList<>()); + skyblockAbility1.add(skyblockAbilities.get(skyblockAbility.getName())); + skyblockAbilitiesByItemID.put(skyblockAbility.getItemId(), skyblockAbility1); + } + } + + private final TreeSet usedAbilities = new TreeSet((c1, c2) -> { + int a = Comparator.comparingLong(UsedAbility::getCooldownEnd).compare(c1,c2); + return c1.getAbility().getName().equals(c2.getAbility().getName()) ? 0 : a; + }); + + @Override + public List getText() { + List cooldowns = new ArrayList<>(); + + for (UsedAbility usedAbility : usedAbilities) { + long end = usedAbility.getCooldownEnd(); + if (System.currentTimeMillis() >= end) { + if (System.currentTimeMillis() <= end + 20000) { + cooldowns.add(new StyledText(usedAbility.getAbility().getName(), "abilityname")); + cooldowns.add(new StyledText(": ", "separator")); + cooldowns.add(new StyledText("READY\n", "ready")); + } + } else { + cooldowns.add(new StyledText(usedAbility.getAbility().getName(), "abilityname")); + cooldowns.add(new StyledText(": ", "separator")); + long millies = end-System.currentTimeMillis(); + double decimalPlaces = (double ) Math.pow(10, 3- this.getParameter("decimal").getValue()); + if (decimalPlaces == 0) { + cooldowns.add(new StyledText( this.getParameter("decimal").getValue()+" decimal places? You'd be joking\n", "unit")); + continue; + } + millies = (long) (((millies-1) / decimalPlaces + 1) * decimalPlaces); + long hr = (long) (millies / (1000 * 60 * 60)); + long min = (long) (( millies / (1000*60)) % 60); + double seconds = (millies/1000.0 ) % 60; + String secondStr = String.format("%."+(this.getParameter("decimal").getValue())+"f", seconds); + + if (hr > 0) { + cooldowns.add(new StyledText(String.valueOf(hr), "number")); + cooldowns.add(new StyledText("h ", "unit")); + } + if (hr > 0 || min > 0) { + cooldowns.add(new StyledText(String.valueOf(min), "number")); + cooldowns.add(new StyledText("m ", "unit")); + } + if (hr > 0 || min > 0 || seconds > 0) { + cooldowns.add(new StyledText(secondStr, "number")); + cooldowns.add(new StyledText("s ", "unit")); + } + cooldowns.add(new StyledText("\n", "unit")); + } + } + return cooldowns; + } + + Pattern thePattern = Pattern.compile("ยงb-(\\d+) Mana \\(ยง6(.+)ยงb\\)"); + Pattern thePattern2 = Pattern.compile("ยงrยงaUsed (.+)ยงrยงa! ยงrยงb\\((1194) Mana\\)ยงr"); + Pattern thePattern3 = Pattern.compile("ยงrยงaUsed (.+)ยงrยงa!ยงr"); + + private String lastActionbarAbility; + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (clientChatReceivedEvent.type == 2) { + Matcher m = thePattern.matcher(clientChatReceivedEvent.message.getFormattedText()); + if (m.find()) { + String name = m.group(2); + if (!name.equalsIgnoreCase(lastActionbarAbility)) { + used(name); + } + lastActionbarAbility = name; + } else { + lastActionbarAbility = null; + } + } else { + String message = clientChatReceivedEvent.message.getFormattedText(); + if (message.equals("ยงrยงaYour ยงrยง9Bonzo's Mask ยงrยงasaved your life!ยงr")) { + used("Clownin' Around"); + } else { + Matcher m = thePattern2.matcher(message); + if (m.matches()) { + String abilityName = TextUtils.stripColor(m.group(1)); + used(abilityName); + } else { + Matcher m2 = thePattern3.matcher(message); + if (m2.matches()) { + String abilityName = TextUtils.stripColor(m2.group(1)); + used(abilityName); + } else if (message.startsWith("ยงrยงaYou used your ") || message.endsWith("ยงrยงaPickaxe Ability!ยงr")) { + String nocolor = TextUtils.stripColor(message); + String abilityName = nocolor.substring(nocolor.indexOf("your") + 5, nocolor.indexOf("Pickaxe") - 1); + used(abilityName); + } + } + } + } + } + + private void used(String ability) { + if (skyblockAbilities.containsKey(ability)) { + SkyblockAbility skyblockAbility = skyblockAbilities.get(ability); + if (skyblockAbility.getCooldown() > 0) { + UsedAbility usedAbility = new UsedAbility(skyblockAbility, System.currentTimeMillis() + skyblockAbility.getCooldown() * 1000); + for (int i = 0; i < 3; i++) usedAbilities.remove(usedAbility); + usedAbilities.add(usedAbility); + } + } else { + System.out.println("Unknown ability: "+ability); + } + } + + public void checkForCooldown(ItemStack itemStack) { + if (itemStack == null) return; + NBTTagCompound nbt = itemStack.getTagCompound(); + if (nbt == null) return; + NBTTagCompound extra = nbt.getCompoundTag("ExtraAttributes"); + if (extra == null) return; + String id = extra.getString("id"); + if (!skyblockAbilitiesByItemID.containsKey(id)) return; + List skyblockAbility = skyblockAbilitiesByItemID.get(id); + + NBTTagCompound display = nbt.getCompoundTag("display"); + if (display == null) return; + NBTTagList lore = display.getTagList("Lore", 8); + int thecd = -1; + SkyblockAbility currentAbility = null; + for (int i = 0; i < lore.tagCount(); i++) { + String specific = lore.getStringTagAt(i); + if (specific.startsWith("ยง8Cooldown: ยงa") && currentAbility != null) { + String thecdstr = TextUtils.stripColor(specific).substring(10).trim(); + thecdstr = thecdstr.substring(0, thecdstr.length() - 1); + thecd = Integer.parseInt(thecdstr); + currentAbility.setCooldown(thecd); + currentAbility = null; + } else if (specific.startsWith("ยง6Item Ability: ")) { + String ability = TextUtils.stripColor(specific).substring(14).trim(); + + for (SkyblockAbility skyblockAbility1 : skyblockAbility) { + if (skyblockAbility1.getName().equals(ability)) { + currentAbility = skyblockAbility1; + break; + } + } + } + } + } + + @Override + public void onTick() { + EntityPlayerSP sp = Minecraft.getMinecraft().thePlayer; + if (sp == null) return; + if (sp.inventory == null || sp.inventory.armorInventory == null) return; + for (ItemStack itemStack : sp.inventory.armorInventory) { + checkForCooldown(itemStack); + } + for (ItemStack itemStack : sp.inventory.mainInventory) { + checkForCooldown(itemStack); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/SkyblockAbility.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/SkyblockAbility.java new file mode 100644 index 00000000..95dd76a6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/SkyblockAbility.java @@ -0,0 +1,32 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc.ability; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class SkyblockAbility { + private String name; + private int manaCost; + private int cooldown; + + private String itemId; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/UsedAbility.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/UsedAbility.java new file mode 100644 index 00000000..c25d8fd9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/etc/ability/UsedAbility.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.etc.ability; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@AllArgsConstructor +public class UsedAbility { + private SkyblockAbility ability; + @EqualsAndHashCode.Exclude + private long cooldownEnd; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/APIKey.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/APIKey.java new file mode 100644 index 00000000..82d15d62 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/APIKey.java @@ -0,0 +1,56 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListenerGlobal; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +public class APIKey extends SimpleFeature implements ChatListenerGlobal { + + public APIKey() { + super("Misc.API Features", "API KEY", "Sets api key","partykicker.apikey"); + addParameter("apikey", new FeatureParameter("apikey", "API Key", "API key", "","string")); + } + + public String getAPIKey() { + return this.getParameter("apikey").getValue(); + } + + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + if (clientChatReceivedEvent.type == 2) return; + String str = clientChatReceivedEvent.message.getFormattedText(); + if (str.startsWith("ยงaYour new API key is ยงrยงb")) { + String apiKeys = TextUtils.stripColor(str.split(" ")[5]); + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfAutomatically Configured Hypixel API Key")); + this.getParameter("apikey").setValue(apiKeys); + } + } + + @Override + public boolean isDisyllable() { + return false; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java new file mode 100644 index 00000000..4d4087ae --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeatureGoodParties.java @@ -0,0 +1,121 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party; + +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.GuiPostRenderListener; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.client.event.GuiScreenEvent; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +public class FeatureGoodParties extends SimpleFeature implements GuiPostRenderListener { + public FeatureGoodParties() { + super("Party Kicker", "Highlight parties in party viewer", "Highlight parties you can't join with red", "partykicker.goodparty",true); + } + + @Override + public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { + if (!isEnabled()) return; + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cont = (ContainerChest) chest.inventorySlots; + String name = cont.getLowerChestInventory().getName(); + if (!"Party Finder".equals(name)) return; + + + int i = 222; + int j = i - 108; + int ySize = j + (((ContainerChest)(((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots)).getLowerChestInventory().getSizeInventory() / 9) * 18; + int left = (rendered.gui.width - 176) / 2; + int top = (rendered.gui.height - ySize ) / 2; + GlStateManager.pushMatrix(); + GlStateManager.disableDepth(); + GlStateManager.disableLighting(); + GlStateManager.colorMask(true, true, true, false); + GlStateManager.translate(left, top, 0); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + try { + + for (int i1 = 0; i1 < Integer.min(54, cont.inventorySlots.size()); i1++) { + Slot s = cont.inventorySlots.get(i1); + if (s.getStack() == null) continue; + if (s.getStack().getItem() != Items.skull) continue; + NBTTagCompound nbt = s.getStack().getTagCompound(); + if (nbt == null || nbt.hasNoTags()) continue; + NBTTagCompound display = nbt.getCompoundTag("display"); + if (display.hasNoTags()) return; + NBTTagList lore = display.getTagList("Lore", 8); + int classLvReq = 0; + int cataLvReq = 0; + boolean Req = false; + String note = ""; + for (int n = 0; n < lore.tagCount(); n++) { + String str = lore.getStringTagAt(n); + if (str.startsWith("ยง7Dungeon Level Required: ยงb")) cataLvReq = Integer.parseInt(str.substring(28)); + if (str.startsWith("ยง7Class Level Required: ยงb")) classLvReq = Integer.parseInt(str.substring(26)); + if (str.startsWith("ยง7ยง7Note:")) note = TextUtils.stripColor(str.substring(10)); + if (str.startsWith("ยงcRequires")) Req = true; + } + + int x = s.xDisplayPosition; + int y = s.yDisplayPosition; + if (Req) { + Gui.drawRect(x, y, x + 16, y + 16, 0x77AA0000); + } else { + + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (note.toLowerCase().contains("car")) { + fr.drawStringWithShadow("C", x + 1, y + 1, 0xFFFF0000); + } else if (note.toLowerCase().replace(" ", "").contains("s/s+")) { + fr.drawStringWithShadow("S+", x + 1, y + 1, 0xFFFFFF00); + } else if (note.toLowerCase().contains("s+")) { + fr.drawStringWithShadow("S+", x + 1, y + 1, 0xFF00FF00); + } else if (note.toLowerCase().contains(" s") || note.toLowerCase().contains(" s ")) { + fr.drawStringWithShadow("S", x + 1, y + 1, 0xFFFFFF00); + } else if (note.toLowerCase().contains("rush")) { + fr.drawStringWithShadow("R", x + 1, y + 1, 0xFFFF0000); + } + fr.drawStringWithShadow("ยงe"+Integer.max(classLvReq, cataLvReq), x + 1, y + fr.FONT_HEIGHT, 0xFFFFFFFF); + } + + + } + } catch (Throwable e) { + e.printStackTrace(); + } + GlStateManager.colorMask(true, true, true, true); + GlStateManager.popMatrix(); + GlStateManager.enableBlend(); + GlStateManager.enableLighting(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyList.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyList.java new file mode 100644 index 00000000..c7912d9c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyList.java @@ -0,0 +1,97 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party; + +import kr.syeyoung.dungeonsguide.mod.party.PartyContext; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeaturePartyList extends TextHUDFeature { + public FeaturePartyList() { + super("Party","Party List", "Party List as GUI", "party.list", false, getFontRenderer().getStringWidth("Watcher finished spawning all mobs!"), getFontRenderer().FONT_HEIGHT*4); + getStyles().add(new TextStyle("name", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("player", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("allinvite", new AColor(0xAA,0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + setEnabled(false); + } + + @Override + public boolean isHUDViewable() { + return PartyManager.INSTANCE.getPartyContext() != null; + } + + @Override + public java.util.List getUsedTextStyle() { + return Arrays.asList("name" ,"separator", "player", "allinvite"); + } + + private static final List dummyText = new ArrayList(); + static { + dummyText.add(new StyledText("Leader","name")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("syeyoung","player")); + dummyText.add(new StyledText("\nModerator","name")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("rioho, RaidShadowLegends, Tricked","player")); + dummyText.add(new StyledText("\nMember","name")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("Everyone","player")); + dummyText.add(new StyledText("\nAll invite Off","allinvite")); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public boolean doesScaleWithHeight() { + return false; + } + + @Override + public List getText() { + PartyContext pc = PartyManager.INSTANCE.getPartyContext(); + List text= new ArrayList<>(); + text.add(new StyledText("Leader","name")); + text.add(new StyledText(": ","separator")); + text.add(new StyledText(pc.getPartyOwner()+"","player")); + text.add(new StyledText("\nModerator","name")); + text.add(new StyledText(": ","separator")); + text.add(new StyledText(pc.getPartyModerator() == null ? "????" : String.join(", ", pc.getPartyModerator()) + (pc.isModeratorComplete() ? "" : " ?"),"player")); + text.add(new StyledText("\nMember","name")); + text.add(new StyledText(": ","separator")); + text.add(new StyledText(pc.getPartyMember() == null ? "????" : String.join(", ", pc.getPartyMember()) + (pc.isMemberComplete() ? "" : " ?"),"player")); + if (pc.getAllInvite() != null && !pc.getAllInvite()) + text.add(new StyledText("\nAll invite Off","allinvite")); + else if (pc.getAllInvite() != null) + text.add(new StyledText("\nAll invite On","allinvite")); + else + text.add(new StyledText("\nAll invite Unknown","allinvite")); + return text; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyReady.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyReady.java new file mode 100644 index 00000000..bf8d8f65 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/FeaturePartyReady.java @@ -0,0 +1,180 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.features.listener.ChatListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.DungeonStartListener; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.party.PartyContext; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.*; + +public class FeaturePartyReady extends TextHUDFeature implements ChatListener, DungeonStartListener { + public FeaturePartyReady() { + super("Party","Party Ready List", "Check if your party member have said r or not", "party.readylist", false, getFontRenderer().getStringWidth("Watcher finished spawning all mobs!"), getFontRenderer().FONT_HEIGHT*4); + getStyles().add(new TextStyle("player", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("ready", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("notready", new AColor(0xFF, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("terminal", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + setEnabled(true); + } + + @Override + public boolean isHUDViewable() { + return PartyManager.INSTANCE.getPartyContext() != null && PartyManager.INSTANCE.getPartyContext().isPartyExistHypixel() && "Dungeon Hub".equals(DungeonContext.getDungeonName()); + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("separator", "player", "ready", "notready", "terminal"); + } + + private static final List dummyText = new ArrayList(); + static { + dummyText.add(new StyledText("syeyoung","player")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("Ready","ready")); + dummyText.add(new StyledText(" 4","terminal")); + dummyText.add(new StyledText("\nrioho","player")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("Ready","ready")); + dummyText.add(new StyledText(" 3","terminal")); + dummyText.add(new StyledText("\nRaidShadowLegends","player")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("Not Ready","notready")); + dummyText.add(new StyledText(" 2t","terminal")); + dummyText.add(new StyledText("\nTricked","player")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("Ready","ready")); + dummyText.add(new StyledText(" ss","terminal")); + dummyText.add(new StyledText("\nMr. Penguin","player")); + dummyText.add(new StyledText(": ","separator")); + dummyText.add(new StyledText("Not Ready","notready")); + dummyText.add(new StyledText(" 2b","terminal")); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public boolean doesScaleWithHeight() { + return false; + } + + private Set ready = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + private Map terminal = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + + @Override + public List getText() { + PartyContext pc = PartyManager.INSTANCE.getPartyContext(); + List text= new ArrayList<>(); + boolean first = true; + for (String partyRawMember : pc.getPartyRawMembers()) { + text.add(new StyledText((first ? "":"\n") + partyRawMember, "player")); + text.add(new StyledText(": ","separator")); + if (ready.contains(partyRawMember)) + text.add(new StyledText("Ready","ready")); + else + text.add(new StyledText("Not Ready","notready")); + if (terminal.get(partyRawMember) != null) { + text.add(new StyledText(" "+ terminal.get(partyRawMember), "terminal")); + } + first =false; + } + return text; + } + + private static final List readyPhrase = Arrays.asList("r", "rdy", "ready"); + private static final List negator = Arrays.asList("not ", "not", "n", "n "); + private static final List terminalPhrase = Arrays.asList("ss", "s1", "1", "2b", "2t", "3", "4", "s3", "s4", "s2", "2"); + private static final Map readynessIndicator = new HashMap<>(); + static { + readyPhrase.forEach(val -> readynessIndicator.put(val, true)); + for (String s : negator) { + readyPhrase.forEach(val -> readynessIndicator.put(s+val, false)); + } + readynessIndicator.put("dont start", false); + readynessIndicator.put("don't start", false); + readynessIndicator.put("dont go", false); + readynessIndicator.put("don't go", false); + readynessIndicator.put("start", true); + readynessIndicator.put("go", true); + } + + + @Override + public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { + String txt = clientChatReceivedEvent.message.getFormattedText(); + if (!txt.startsWith("ยงrยง9Party ยง8>")) return; + + String chat = TextUtils.stripColor(txt.substring(txt.indexOf(":")+1)).trim().toLowerCase(); + + + + String usernamearea = TextUtils.stripColor(txt.substring(13, txt.indexOf(":"))); + String username = null; + for (String s : usernamearea.split(" ")) { + if (s.isEmpty()) continue; + if (s.startsWith("[")) continue; + username = s; + break; + } + + + Boolean status = null; + String longestMatch = ""; + for (Map.Entry stringBooleanEntry : readynessIndicator.entrySet()) { + if (chat.startsWith(stringBooleanEntry.getKey()) || chat.endsWith(stringBooleanEntry.getKey()) || (stringBooleanEntry.getKey().length()>=3 && chat.contains(stringBooleanEntry.getKey()))) { + if (stringBooleanEntry.getKey().length() > longestMatch.length()) { + longestMatch = stringBooleanEntry.getKey(); + status = stringBooleanEntry.getValue(); + } + } + } + if (status == null); + else if (status) ready.add(username); + else ready.remove(username); + + + String term = ""; + for (String s : terminalPhrase) { + if (chat.equals(s) || chat.startsWith(s+" ") || chat.endsWith(" "+s) || chat.contains(" "+s+" ")) { + term += s+" "; + } + } + if (!term.isEmpty()) + terminal.put(username, term); + } + + @Override + public void onDungeonStart() { + ready.clear(); + terminal.clear(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/FeatureCustomPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/FeatureCustomPartyFinder.java new file mode 100644 index 00000000..87b071bc --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/FeatureCustomPartyFinder.java @@ -0,0 +1,110 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.mod.events.impl.WindowUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.*; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.client.event.GuiOpenEvent; + +public class FeatureCustomPartyFinder extends SimpleFeature implements GuiOpenListener, GuiUpdateListener { + public FeatureCustomPartyFinder() { + super("Party","Custom Party Finder","Custom Party Finder", "party.customfinder", true); + } + + @Getter + @Setter + private String whitelist = "", blacklist = "", highlight ="", blacklistClass = ""; + @Getter + @Setter + private int minimumCata; + + @Getter @Setter + private String lastClass = ""; + + GuiCustomPartyFinder guiCustomPartyFinder; + @Override + public void onGuiOpen(GuiOpenEvent event) { + if (event.gui == null) guiCustomPartyFinder = null; + if (!isEnabled()) return; + if (!(event.gui instanceof GuiChest)) return; + GuiChest chest = (GuiChest) event.gui; + if (!(chest.inventorySlots instanceof ContainerChest)) return; + ContainerChest containerChest = (ContainerChest) chest.inventorySlots; + IInventory lower = containerChest.getLowerChestInventory(); + if (lower == null || !lower.getName().equals("Party Finder")) return; + + if (guiCustomPartyFinder == null) { + guiCustomPartyFinder = new GuiCustomPartyFinder(); + } + guiCustomPartyFinder.setGuiChest(chest); + + event.gui = guiCustomPartyFinder; + } + + @Override + public void onGuiUpdate(WindowUpdateEvent windowUpdateEvent) { + if (guiCustomPartyFinder != null) { + guiCustomPartyFinder.onChestUpdate(windowUpdateEvent); + } + + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + + if (!(chest.inventorySlots instanceof ContainerChest)) return; + ContainerChest containerChest = (ContainerChest) chest.inventorySlots; + IInventory lower = containerChest.getLowerChestInventory(); + if (lower == null || !lower.getName().equals("Catacombs Gate")) return; + + ItemStack item = null; + if (windowUpdateEvent.getWindowItems() != null) { + item = windowUpdateEvent.getWindowItems().getItemStacks()[47]; + } else if (windowUpdateEvent.getPacketSetSlot() != null) { + if (windowUpdateEvent.getPacketSetSlot().func_149173_d() != 47) return; + item = windowUpdateEvent.getPacketSetSlot().func_149174_e(); + } + if (item == null) return; + + NBTTagCompound stackTagCompound = item.getTagCompound(); + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("ยงaCurrently Selected")) { + lastClass = str.substring(24); + } + } + } + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/GuiCustomPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/GuiCustomPartyFinder.java new file mode 100644 index 00000000..d6ab22b9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/GuiCustomPartyFinder.java @@ -0,0 +1,75 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.mod.events.impl.WindowUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.gui.MGui; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiChest; + +import java.awt.*; + +public class GuiCustomPartyFinder extends MGui { + @Getter + private GuiChest guiChest; + + public void setGuiChest(GuiChest guiChest) { + if (this.guiChest != null) this.guiChest.onGuiClosed(); + this.guiChest = guiChest; + panelPartyFinder.onChestUpdate(null); + guiChest.setWorldAndResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); + guiChest.initGui(); + } + + public void onChestUpdate(WindowUpdateEvent windowUpdateEvent) { + panelPartyFinder.onChestUpdate(windowUpdateEvent); + } + + private PanelPartyFinder panelPartyFinder; + public GuiCustomPartyFinder() { + panelPartyFinder = new PanelPartyFinder(this); + getMainPanel().add(panelPartyFinder); + } + + @Override + public void initGui() { + super.initGui(); + int width = 3*Minecraft.getMinecraft().displayWidth/5; + width = Math.max(width, 1000); + int height = 3*Minecraft.getMinecraft().displayHeight/5; + height = Math.max(height, 600); + + panelPartyFinder.setBounds(new Rectangle((Minecraft.getMinecraft().displayWidth-width)/2, (Minecraft.getMinecraft().displayHeight-height)/2, width, height)); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + } + + @Override + public void onGuiClosed() { + guiChest.onGuiClosed(); + guiChest = null; + super.onGuiClosed(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinder.java new file mode 100644 index 00000000..634d3ff1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinder.java @@ -0,0 +1,341 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.GuiConfigV2; +import kr.syeyoung.dungeonsguide.mod.events.impl.WindowUpdateEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.impl.discord.invteTooltip.MTooltipInvite; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.discord.rpc.RichPresenceManager; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +import java.awt.*; +import java.util.HashMap; +import java.util.Map; + +public class PanelPartyFinder extends MPanel { + @Getter + private GuiCustomPartyFinder guiCustomPartyFinder; + + private PanelPartyFinderSettings panelPartyFinderSettings; + + private MScrollablePanel scrollablePanel; + private MList list; + + private MButton goBack; + + private MPanelScaledGUI navigation; + + private MButton previous; + private MButton next; + private MButton settings, discordInvite; + private int page = 1; + + private Map panelPartyListElementMap = new HashMap<>(); + + public PanelPartyFinder(GuiCustomPartyFinder guiCustomPartyFinder) { + this.guiCustomPartyFinder = guiCustomPartyFinder; + + scrollablePanel = new MScrollablePanel(1); + panelPartyFinderSettings = new PanelPartyFinderSettings(this); + + + list = new MList() { + @Override + public void resize(int parentWidth, int parentHeight) { + setSize(new Dimension(parentWidth, 9999)); + realignChildren(); + } + }; + list.setGap(1); + + scrollablePanel.add(list); + + add(scrollablePanel); + add(panelPartyFinderSettings); + + previous = new MButton(); next = new MButton(); + previous.setText("Prev"); next.setText("Next"); + previous.setEnabled(false); next.setEnabled(false); + next.setOnActionPerformed(() -> { + GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*2+8, 0, 0, Minecraft.getMinecraft().thePlayer); + }); + previous.setOnActionPerformed(() -> { + GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*2, 0, 0, Minecraft.getMinecraft().thePlayer); + }); + goBack = new MButton(); + goBack.setBackground(RenderUtils.blendAlpha(0xFF141414, 0.05f)); + goBack.setText("<"); + goBack.setOnActionPerformed(() -> { + GuiChest chest = getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+3, 0, 0, Minecraft.getMinecraft().thePlayer); + }); + add(goBack); + settings = new MButton(); + settings.setBackground(RenderUtils.blendAlpha(0xFF141414, 0.05f)); + settings.setText("Settings"); + settings.setOnActionPerformed(() -> { + GuiConfigV2 guiConfigV2 = new GuiConfigV2(); + guiConfigV2.getRootConfigPanel().setCurrentPageAndPushHistory("ROOT."+ FeatureRegistry.PARTYKICKER_CUSTOM.getCategory()); + Minecraft.getMinecraft().displayGuiScreen(guiConfigV2); + }); + discordInvite = new MButton(); + discordInvite.setText("Invite Discord Friends"); + discordInvite.setOnActionPerformed(() -> { + if (RichPresenceManager.INSTANCE.getLastSetupCode() == -9999) { + MModalMessage mTooltipInvite = new MModalMessage("Error", "Discord GameSDK has been disabled, or it failed to load", () -> {}); + mTooltipInvite.setScale( new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor()); + mTooltipInvite.open(this); + } else if (PartyManager.INSTANCE.getAskToJoinSecret() != null) { + MTooltipInvite mTooltipInvite = new MTooltipInvite(); + mTooltipInvite.setScale( new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor()); + mTooltipInvite.open(this); + } else { + MModalMessage mTooltipInvite = new MModalMessage("Error", "You need to have Ask To Join Enabled to use this feature. Run /dg atj to enable ask to join", () -> {}); + mTooltipInvite.setScale( new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor()); + mTooltipInvite.open(this); + } + }); + discordInvite.setBackground(RenderUtils.blendAlpha(0xFF141414, 0.05f)); + add(discordInvite); + add(settings); + navigation = new MPanelScaledGUI() { + @Override + public void onBoundsUpdate() { + super.onBoundsUpdate(); + Dimension dimension = getEffectiveDimension(); + previous.setBounds(new Rectangle(0,0,50,dimension.height)); + next.setBounds(new Rectangle(dimension.width-50,0,50,dimension.height)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + Gui.drawRect(0,0,getEffectiveDimension().width, getEffectiveDimension().height, RenderUtils.blendAlpha(0xFF141414, 0.08f)); + fr.drawString("Page "+page, (getEffectiveDimension().width-fr.getStringWidth("Page "+page))/2, (getEffectiveDimension().height-fr.FONT_HEIGHT)/2, -1); + } + }; + navigation.add(next); navigation.add(previous); + add(navigation); + } + + public String getHighlightNote() { + return panelPartyFinderSettings.getHighlightText(); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + panelPartyFinderSettings.setBounds(new Rectangle(3*bounds.width/5+1, fr.FONT_HEIGHT*2+21, 2*bounds.width/5 -1, (bounds.height-fr.FONT_HEIGHT*2-21))); + panelPartyFinderSettings.setScale(scaledResolution.getScaleFactor()); + + navigation.setBounds(new Rectangle(0,fr.FONT_HEIGHT*2 + 21, 3*bounds.width/5, 20*scaledResolution.getScaleFactor())); + navigation.setScale(scaledResolution.getScaleFactor()); + scrollablePanel.setBounds(new Rectangle(0, navigation.getBounds().y+navigation.getBounds().height, 3*bounds.width/5, bounds.height - (navigation.getBounds().y+navigation.getBounds().height))); + goBack.setBounds(new Rectangle(0,0, fr.FONT_HEIGHT*2+20, fr.FONT_HEIGHT*2+20)); + settings.setBounds(new Rectangle(bounds.width - 75, 0, 75, fr.FONT_HEIGHT*2+20)); + discordInvite.setBounds(new Rectangle(bounds.width-275, 0, 200, fr.FONT_HEIGHT*2+20)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + // background + Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0xFF141414, 0.0f)); + // top bar + Gui.drawRect(0,0,getBounds().width, fr.FONT_HEIGHT*2+21, RenderUtils.blendAlpha(0xFF141414, 0.05f)); + // lines + Gui.drawRect(0,fr.FONT_HEIGHT*2+20,getBounds().width, fr.FONT_HEIGHT*2+21, -1); + Gui.drawRect(panelPartyFinderSettings.getBounds().x-1,fr.FONT_HEIGHT*2+20,panelPartyFinderSettings.getBounds().x, getBounds().height, -1); + // prev next bar + + GlStateManager.pushMatrix(); + GlStateManager.translate(fr.FONT_HEIGHT*2+21, 0,0); + GlStateManager.scale(2,2,1); + fr.drawString("Party Finder", 5,5,-1); + GlStateManager.popMatrix(); + } + + public synchronized void onChestUpdate(WindowUpdateEvent windowUpdateEvent) { + if (windowUpdateEvent == null) { + GuiChest guiChest = guiCustomPartyFinder.getGuiChest(); + if (guiChest == null) { + panelPartyListElementMap.clear(); + } else { + for (int x = 1; x<=7; x++) { + for (int y = 1; y <= 3; y++) { + int i = y * 9 + x; + Slot s = guiChest.inventorySlots.getSlot(i); + PanelPartyListElement prev = panelPartyListElementMap.remove(i); + if (s == null || !s.getHasStack()) { continue; } + if (!filter(s.getStack())) continue; + + if (prev == null) prev = new PanelPartyListElement(this, i); + panelPartyListElementMap.put(i, prev); + } + } + + { + Slot next = guiChest.inventorySlots.getSlot(9 * 2 + 8); + if (next.getStack() != null && next.getStack().getItem() == Items.arrow) { + this.next.setEnabled(true); + extractPage(next.getStack()); + } else { + this.next.setEnabled(false); + } + + Slot prev = guiChest.inventorySlots.getSlot(9 * 2 + 0); + if (prev.getStack() != null && prev.getStack().getItem() == Items.arrow) { + this.previous.setEnabled(true); + extractPage(prev.getStack()); + } else { + this.previous.setEnabled(false); + } + + Slot delist = guiChest.inventorySlots.getSlot(9 * 5 + 7); + panelPartyFinderSettings.setDelistable(delist.getStack() != null && delist.getStack().getItem() == Item.getItemFromBlock(Blocks.bookshelf)); + } + } + } else { + if (windowUpdateEvent.getPacketSetSlot() != null) { + int i = windowUpdateEvent.getPacketSetSlot().func_149173_d(); + + ItemStack stack = windowUpdateEvent.getPacketSetSlot().func_149174_e(); + if (i == 9*2+8) { + if (stack != null && stack.getItem() == Items.arrow) { + this.next.setEnabled(true); + extractPage(stack); + } else { + this.next.setEnabled(false); + } + } else if (i == 9*2) { + if (stack != null && stack.getItem() == Items.arrow) { + this.previous.setEnabled(true); + extractPage(stack); + } else { + this.previous.setEnabled(false); + } + } else if (i == 9*5+7) { + panelPartyFinderSettings.setDelistable(stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)); + } + + if (i%9 == 0 || i%9 == 8 || i/9 == 0 || i/9 >= 4) { + return; + } + + PanelPartyListElement prev = panelPartyListElementMap.remove(i); + if (filter(stack)) { + if (prev == null) prev = new PanelPartyListElement(this, i); + panelPartyListElementMap.put(i, prev); + } + } else if (windowUpdateEvent.getWindowItems() != null) { + for (int x = 1; x<=7; x++) { + for (int y = 1; y <= 3; y++) { + int i = y * 9 + x; + ItemStack item = windowUpdateEvent.getWindowItems().getItemStacks()[i]; + PanelPartyListElement prev = panelPartyListElementMap.remove(i); + if (!filter(item)) continue; + + if (prev == null) prev = new PanelPartyListElement(this, i); + panelPartyListElementMap.put(i, prev); + } + } + + { + ItemStack next = windowUpdateEvent.getWindowItems().getItemStacks()[9 * 2 + 8]; + if (next != null && next.getItem() == Items.arrow) { + this.next.setEnabled(true); + extractPage(next); + } else { + this.next.setEnabled(false); + } + + ItemStack prev = windowUpdateEvent.getWindowItems().getItemStacks()[9 * 2]; + if (prev != null && prev.getItem() == Items.arrow) { + this.previous.setEnabled(true); + extractPage(prev); + } else { + this.previous.setEnabled(false); + } + + ItemStack delist = windowUpdateEvent.getWindowItems().getItemStacks()[9*5+7]; + panelPartyFinderSettings.setDelistable(delist != null && delist.getItem() == Item.getItemFromBlock(Blocks.bookshelf)); + } + } + } + + addItems(); + } + + public boolean filter(ItemStack item) { + return !(item == null || item.getItem() == null || item.getItem() == Item.getItemFromBlock(Blocks.air)) && panelPartyFinderSettings.filter(item); + } + + public void extractPage(ItemStack itemStack) { + NBTTagCompound stackTagCompound = itemStack.getTagCompound(); + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("ยงePage ")) { + int pg = Integer.parseInt(str.substring(7)); + if (itemStack.getDisplayName().equals("ยงaPrevious Page")) page = pg+1; + else page = pg-1; + } + } + } + } + } + + public void addItems() { + for (MPanel childComponent : list.getChildComponents()) { + list.remove(childComponent); + } + for (Map.Entry value : panelPartyListElementMap.entrySet()) { + list.add(value.getValue()); + } + scrollablePanel.evalulateContentArea(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java new file mode 100644 index 00000000..fa27b517 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyFinderSettings.java @@ -0,0 +1,293 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.gui.elements.*; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Items; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; + +import java.awt.*; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class PanelPartyFinderSettings extends MPanelScaledGUI { + private PanelPartyFinder panelPartyFinder; + + private MButton refresh = new MButton(), createNew = new MButton(), settings = new MButton(); + private MPassiveLabelAndElement filterCantjoin, filterWhitelistNote, filterBlacklistNote, plaeHighlightNote, cataLv,blacklistClass; private MToggleButton filterCantjoinButton; + private MTextField filterWhitelist, filterBlacklist, highlightNote, blacklistClassTxt; + private MIntegerSelectionButton integerSelection; + + @Getter + boolean delistable = false; + + public void setDelistable(boolean delistable) { + this.delistable = delistable; + updateCreateNew(); + } + + public void updateCreateNew() { + createNew.setText((PartyManager.INSTANCE.getPartyContext() != null && !PartyManager.INSTANCE.isLeader()) ? "Leave Party" : (delistable ? "De-list" : "Create New")); + } + + public PanelPartyFinderSettings(PanelPartyFinder panelPartyFinder) { + this.panelPartyFinder = panelPartyFinder; + + createNew.setOnActionPerformed(this::createNew); + createNew.setBackground(0xFF00838F); + createNew.setHover(0xFF00ACC1); + createNew.setClicked(0xFF0097A7); + add(createNew); + updateCreateNew(); + refresh.setText("Refresh"); + refresh.setOnActionPerformed(this::refresh); + add(refresh); + + settings.setText("Search Settings"); + settings.setOnActionPerformed(this::settings); + add(settings); + + { + filterCantjoinButton = new MToggleButton(); + filterCantjoin = new MPassiveLabelAndElement("Filter Unjoinable", filterCantjoinButton); + filterCantjoin.setDivideRatio(0.7); + filterCantjoinButton.setOnToggle(() -> panelPartyFinder.onChestUpdate(null)); + add(filterCantjoin); + } + { + filterWhitelist = new MTextField() { + @Override + public void edit(String str) { + panelPartyFinder.onChestUpdate(null); + FeatureRegistry.PARTYKICKER_CUSTOM.setWhitelist(str); + } + }; + filterBlacklist = new MTextField() { + @Override + public void edit(String str) { + FeatureRegistry.PARTYKICKER_CUSTOM.setBlacklist(str); + panelPartyFinder.onChestUpdate(null); + } + }; + highlightNote = new MTextField() { + @Override + public void edit(String str) { + super.edit(str); + FeatureRegistry.PARTYKICKER_CUSTOM.setHighlight(str); + } + }; + blacklistClassTxt = new MTextField() { + @Override + public void edit(String str) { + super.edit(str); + FeatureRegistry.PARTYKICKER_CUSTOM.setBlacklistClass(str); + panelPartyFinder.onChestUpdate(null); + } + }; + + filterWhitelist.setText(FeatureRegistry.PARTYKICKER_CUSTOM.getWhitelist()); + filterBlacklist.setText(FeatureRegistry.PARTYKICKER_CUSTOM.getBlacklist()); + highlightNote.setText(FeatureRegistry.PARTYKICKER_CUSTOM.getHighlight()); + blacklistClassTxt.setText(FeatureRegistry.PARTYKICKER_CUSTOM.getBlacklistClass()); + + filterWhitelistNote = new MPassiveLabelAndElement("Whitelist Note", filterWhitelist); + filterBlacklistNote = new MPassiveLabelAndElement("Blacklist Note", filterBlacklist); + plaeHighlightNote = new MPassiveLabelAndElement("Highlight Note", highlightNote); + blacklistClass = new MPassiveLabelAndElement("Blacklist Class", blacklistClassTxt); + + filterWhitelistNote.setDivideRatio(0.5); + filterBlacklistNote.setDivideRatio(0.5); + plaeHighlightNote.setDivideRatio(0.5); + blacklistClass.setDivideRatio(0.5); + add(filterWhitelistNote); + add(filterBlacklistNote); + add(plaeHighlightNote); + add(blacklistClass); + } + { + integerSelection = new MIntegerSelectionButton(FeatureRegistry.PARTYKICKER_CUSTOM.getMinimumCata()); + integerSelection.setOnUpdate(() -> { + FeatureRegistry.PARTYKICKER_CUSTOM.setMinimumCata(integerSelection.getData()); + panelPartyFinder.onChestUpdate(null); + }); + cataLv = new MPassiveLabelAndElement("Minimum Cata Lv", integerSelection); + cataLv.setDivideRatio(0.5); add(cataLv); + } + } + + private void createNew() { + if (PartyManager.INSTANCE.getPartyContext() != null && !PartyManager.INSTANCE.isLeader()) { + ChatProcessor.INSTANCE.addToChatQueue("/p leave ", () -> {}, true); + return; + } + GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); + if (delistable) + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+7, 0, 0, Minecraft.getMinecraft().thePlayer); + else + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+0, 0, 0, Minecraft.getMinecraft().thePlayer); + + } + + public String getHighlightText() { + return highlightNote.getText(); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + + GuiCustomPartyFinder guiCustomPartyFinder = panelPartyFinder.getGuiCustomPartyFinder(); + if (guiCustomPartyFinder.getGuiChest() == null) return; + Slot s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(9*5+5); + ItemStack itemStack = s.getStack(); + if (itemStack == null) return; + + String dungeon="", floor="", text=""; + { + NBTTagCompound stackTagCompound = itemStack.getTagCompound(); + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("ยงaDungeon: ")) { + dungeon = str.substring(11); + } else if (str.startsWith("ยงaFloor: ")) { + floor = str.substring(9); + } else if (str.startsWith("ยงaSearch text: ")) { + text = str.substring(15); + } + } + } + } + } + fontRenderer.drawString("ยงaSearching: "+dungeon+" ยง7- "+floor, 5,155,-1); + fontRenderer.drawString("ยงaSearch text: "+text, 5,155+fontRenderer.FONT_HEIGHT,-1); + + Gui.drawRect(0,160+fontRenderer.FONT_HEIGHT*2,getBounds().width, 161+fontRenderer.FONT_HEIGHT*2, -1); + GlStateManager.translate(5,165+fontRenderer.FONT_HEIGHT*2,0); + + s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(9*5+8); + itemStack = s.getStack(); + if (itemStack == null || itemStack.getItem() != Items.skull) return; + + List list = itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { + list.set(i, itemStack.getRarity().rarityColor + list.get(i)); + } else { + list.set(i, EnumChatFormatting.GRAY + list.get(i)); + } + } + for (int i = 0; i < list.size(); i++) { + fontRenderer.drawString(list.get(i), 0, (i)*fontRenderer.FONT_HEIGHT, -1); + } + } + + public void refresh() { + GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+1, 0, 0, Minecraft.getMinecraft().thePlayer); + } + public void settings() { + GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, 9*5+5, 0, 0, Minecraft.getMinecraft().thePlayer); + } + + @Override + public void onBoundsUpdate() { + Dimension bounds = getEffectiveDimension(); + refresh.setBounds(new Rectangle(5,5,(bounds.width-10)/2,15)); + createNew.setBounds(new Rectangle(bounds.width/2,5,(bounds.width-10)/2,15)); + filterCantjoin.setBounds(new Rectangle(5,22,bounds.width-10,15)); + filterWhitelistNote.setBounds(new Rectangle(5,39,bounds.width-10,15)); + filterBlacklistNote.setBounds(new Rectangle(5,56,bounds.width-10,15)); + plaeHighlightNote.setBounds(new Rectangle(5,73,bounds.width-10,15)); + cataLv.setBounds(new Rectangle(5,90,bounds.width-10,15)); + blacklistClass.setBounds(new Rectangle(5,107,bounds.width-10,15)); + settings.setBounds(new Rectangle(5,124,bounds.width-10,15)); + } + + public boolean filter(ItemStack itemStack) { + NBTTagCompound stackTagCompound = itemStack.getTagCompound(); + String note = ""; + int dLV = 0; + Set invalidClasses = new HashSet<>(); + for (String s : blacklistClassTxt.getText().split(",")) { + invalidClasses.add(s.toLowerCase()); + } + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("ยงcRequires ") && filterCantjoinButton.isEnabled()) return false; + if (str.startsWith("ยง7ยง7Note:")) { + note = str.substring(12); + } + if (str.startsWith("ยง7Dungeon Level Required: ยงb")) { + dLV = Integer.parseInt(str.substring(28)); + } + if (str.startsWith(" ") && str.contains(":")) { + String clazz = TextUtils.stripColor(str).trim().split(" ")[1]; + if (invalidClasses.contains(clazz.toLowerCase())) return false; + } + } + } + } + if (integerSelection.getData() >dLV) return false; + + if (!filterBlacklist.getText().isEmpty()) { + for (String s1 : filterBlacklist.getText().split(",")) { + if (note.toLowerCase().contains(s1.toLowerCase())) return false; + } + } + if (!filterWhitelist.getText().isEmpty()) { + boolean s = false; + for (String s1 : filterWhitelist.getText().split(",")) { + if (note.toLowerCase().contains(s1.toLowerCase())) { + s = true; break; + } + } + if (!s) return false; + } + return true; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java new file mode 100644 index 00000000..154c5e8d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/customgui/PanelPartyListElement.java @@ -0,0 +1,236 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.customgui; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltip; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltipText; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; + +import java.awt.*; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class PanelPartyListElement extends MPanel { + private PanelPartyFinder panelPartyFinder; + private int slot; + + public PanelPartyListElement(PanelPartyFinder panelPartyFinder, int slot) { + this.panelPartyFinder = panelPartyFinder; + this.slot = slot; + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(-1, 32); + } + + private MTooltip mTooltip; + + private ItemStack lastStack; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + GuiCustomPartyFinder guiCustomPartyFinder = panelPartyFinder.getGuiCustomPartyFinder(); + if (guiCustomPartyFinder.getGuiChest() == null) return; + Slot s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(slot); + ItemStack itemStack = s.getStack(); + if (itemStack == null && lastStack == null) return; + if (itemStack != null) + lastStack = itemStack; + else + itemStack = lastStack; + int color = RenderUtils.blendAlpha(0x141414, 0.0f); + + String note = ""; + boolean notfound = false; + boolean cantjoin = false; + if (itemStack.getItem() == Item.getItemFromBlock(Blocks.bedrock)) { + cantjoin = true; + notfound = true; + } + int minClass = -1, minDungeon = -1; + int pplIn = 0; + Set dungeonClasses = new HashSet<>(); + { + NBTTagCompound stackTagCompound = itemStack.getTagCompound(); + if (stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.getTagId("Lore") == 9) { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + for (int i = 0; i < nbttaglist1.tagCount(); i++) { + String str = nbttaglist1.getStringTagAt(i); + if (str.startsWith("ยง7ยง7Note:")) { + note = str.substring(12); + } else if (str.startsWith("ยง7Class Level Required: ยงb")) { + minClass = Integer.parseInt(str.substring(26)); + } else if (str.startsWith("ยง7Dungeon Level Required: ยงb")) { + minDungeon = Integer.parseInt(str.substring(28)); + } else if (str.startsWith("ยงcRequires ")) cantjoin = true; + if (str.endsWith("ยงb)")) pplIn ++; + + if (str.startsWith(" ") && str.contains(":")) { + String clazz = TextUtils.stripColor(str).trim().split(" ")[1]; + dungeonClasses.add(clazz); + } + } + } + } + } + + boolean nodupe = note.toLowerCase().contains("nodupe") || note.toLowerCase().contains("no dupe") || (note.toLowerCase().contains("nd") && (note.toLowerCase().indexOf("nd") == 0 || note.charAt(note.toLowerCase().indexOf("nd")-1) == ' ')); + + note = note.replaceAll("(?i)(S\\+)", "ยง6$1ยงr"); + note = note.replaceAll("(?i)(carry)", "ยง4$1ยงr"); + + try { + if (!panelPartyFinder.getHighlightNote().isEmpty()) { + for (String s1 : panelPartyFinder.getHighlightNote().split(",")) { + note = note.replaceAll("(?i)(" + s1 + ")", "ยงeยงl$1ยงr"); + } + } + } catch (Exception e) {} + + if (cantjoin) {} + else if (clicked) { + color = RenderUtils.blendAlpha(0x141414, 0.10f); + } else if (lastAbsClip.contains(absMousex, absMousey) && (getTooltipsOpen() == 0 || (mTooltip != null && mTooltip.isOpen()))) { + color = RenderUtils.blendAlpha(0x141414, 0.12f); + } + if (cantjoin) {} + else if (note.contains("ยงe")) { + color = RenderUtils.blendTwoColors(color, 0x44FFFF00); + } else if (note.contains("ยง6")){ + color = RenderUtils.blendTwoColors(color, 0x44FFAA00); + } + + if (nodupe && dungeonClasses.contains(FeatureRegistry.PARTYKICKER_CUSTOM.getLastClass())) { + color = RenderUtils.blendTwoColors(color, 0x44FF0000); + note = note.replace("nodupe", "ยงcnodupeยงr").replace("no dupe", "ยงcno dupeยงr").replace("nd", "ยงcndยงr"); + } + Gui.drawRect(0,0,getBounds().width,getBounds().height,color); + + RenderItem renderItem= Minecraft.getMinecraft().getRenderItem(); + GlStateManager.pushMatrix(); + RenderHelper.disableStandardItemLighting(); + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.scale(2,2,1); + GlStateManager.enableDepth(); + renderItem.renderItemAndEffectIntoGUI(itemStack, 0,0); + GlStateManager.popMatrix(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.pushMatrix(); + GlStateManager.translate(37,(32 - 2*fr.FONT_HEIGHT)/2,0); + GlStateManager.scale(2,2,1); + String name = itemStack.getDisplayName(); + if (name.contains("'")) + name = name.substring(0, name.indexOf("'")); + fr.drawString(name, 0,0,-1); + + if (!notfound) + note = "ยง7("+pplIn+") ยงf"+note; + fr.drawString(note, fr.getStringWidth("AAAAAAAAAAAAAAAA")+5, 0,-1); + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + String sideNote = ""; + if (minClass != -1) sideNote += "ยง7CLv โ‰ฅยงb"+minClass+" "; + if (minDungeon != -1) sideNote += "ยง7DLv โ‰ฅยงb"+minDungeon+" "; + if (cantjoin && !notfound) sideNote = "ยงcCan't join"; + sideNote = sideNote.trim(); + + GlStateManager.translate(getBounds().width,(32 - 2*fr.FONT_HEIGHT)/2,0); + GlStateManager.scale(2,2,0); + GlStateManager.translate(-fr.getStringWidth(sideNote), 0,0); + fr.drawString(sideNote, 0,0,-1); + + GlStateManager.popMatrix(); + if (lastAbsClip.contains(absMousex, absMousey) && (mTooltip == null || !mTooltip.isOpen()) && getTooltipsOpen() == 0) { + if (mTooltip != null) mTooltip.close(); + List list = itemStack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { + list.set(i, itemStack.getRarity().rarityColor + list.get(i)); + } else { + list.set(i, EnumChatFormatting.GRAY + list.get(i)); + } + } + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + mTooltip = new MTooltipText(list); + mTooltip.setScale(scaledResolution.getScaleFactor()); + mTooltip.open(this); + } else if (!lastAbsClip.contains(absMousex, absMousey)){ + if (mTooltip != null) + mTooltip.close(); + mTooltip = null; + } + } + + @Override + public void setParent(MPanel parent) { + super.setParent(parent); + if (parent == null && mTooltip != null) { + mTooltip.close(); + mTooltip = null; + } + } + + boolean clicked = false; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY)&& (getTooltipsOpen() == 0 || (mTooltip != null && mTooltip.isOpen()))) { + clicked = true; + + GuiChest chest = panelPartyFinder.getGuiCustomPartyFinder().getGuiChest(); + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, slot, 0, 0, Minecraft.getMinecraft().thePlayer); + } + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + clicked = false; + } + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY) && (getTooltipsOpen() == 0 || (mTooltip != null && mTooltip.isOpen()))) { + setCursor(EnumCursor.POINTING_HAND); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FakePlayer.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FakePlayer.java new file mode 100644 index 00000000..4304ea8a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FakePlayer.java @@ -0,0 +1,101 @@ +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview; + +import com.google.common.base.Objects; +import com.mojang.authlib.GameProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.SkinFetcher; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Team; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class FakePlayer extends EntityOtherPlayerMP { + @Setter + @Getter + private PlayerProfile skyblockProfile; + private final SkinFetcher.SkinSet skinSet; + private final PlayerProfile.Armor armor; + @Getter + private final int profileNumber; + + private FakePlayer(World w) { + super(w, null); + throw new UnsupportedOperationException("what"); + } + + public FakePlayer(GameProfile playerProfile, SkinFetcher.SkinSet skinSet, PlayerProfile skyblockProfile, int profileNumber) { + super(Minecraft.getMinecraft().theWorld, playerProfile); + this.profileNumber = profileNumber; + this.skyblockProfile = skyblockProfile; + this.skinSet = skinSet; + armor = skyblockProfile.getCurrentArmor(); + this.inventory.armorInventory = skyblockProfile.getCurrentArmor().getArmorSlots(); + + int highestDungeonScore = Integer.MIN_VALUE; + if (skyblockProfile.getInventory() != null) { + ItemStack highestItem = null; + for (ItemStack itemStack : skyblockProfile.getInventory()) { + if (itemStack == null) continue; + NBTTagCompound display = itemStack.getTagCompound().getCompoundTag("display"); + if (display == null) continue; + NBTTagList nbtTagList = display.getTagList("Lore", 8); + if (nbtTagList == null) continue; + for (int i = 0; i < nbtTagList.tagCount(); i++) { + String str = nbtTagList.getStringTagAt(i); + if (TextUtils.stripColor(str).startsWith("Gear")) { + int dungeonScore = Integer.parseInt(TextUtils.keepIntegerCharactersOnly(TextUtils.stripColor(str).split(" ")[2])); + if (dungeonScore > highestDungeonScore) { + highestItem = itemStack; + highestDungeonScore = dungeonScore; + } + } + } + } + + this.inventory.mainInventory[0] = highestItem; + this.inventory.currentItem = 0; + } + } + + public String getSkinType() { + return this.skinSet == null ? DefaultPlayerSkin.getSkinType(getGameProfile().getId()) : this.skinSet.getSkinType(); + } + + public ResourceLocation getLocationSkin() { + return Objects.firstNonNull(skinSet.getSkinLoc(), DefaultPlayerSkin.getDefaultSkin(getGameProfile().getId())); + } + + public ResourceLocation getLocationCape() { + return skinSet.getCapeLoc(); + } + + @Override + public ItemStack[] getInventory() { + return this.inventory.armorInventory; + } + + @Override + public boolean isInvisibleToPlayer(EntityPlayer player) { + return true; + } + + @Override + public Team getTeam() { + return new ScorePlayerTeam(null, null) { + @Override + public EnumVisible getNameTagVisibility() { + return EnumVisible.NEVER; + } + }; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java new file mode 100644 index 00000000..1be93cdf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java @@ -0,0 +1,706 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview; + +import com.mojang.authlib.GameProfile; +import io.github.moulberry.hychat.HyChat; +import io.github.moulberry.hychat.chat.ChatManager; +import io.github.moulberry.hychat.gui.GuiChatBox; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessResult; +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.ApiFetcher; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.PlayerSkyblockData; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.SkinFetcher; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.DataRendererEditor; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.DataRendererRegistry; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import kr.syeyoung.dungeonsguide.mod.features.listener.GuiClickListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.GuiPostRenderListener; +import kr.syeyoung.dungeonsguide.mod.party.PartyContext; +import kr.syeyoung.dungeonsguide.mod.party.PartyManager; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.HoverEvent; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.fml.client.config.GuiUtils; +import net.minecraftforge.fml.common.Loader; +import org.jetbrains.annotations.NotNull; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.List; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +public class FeatureViewPlayerStatsOnJoin extends SimpleFeature implements GuiPostRenderListener, GuiClickListener { + + static Minecraft mc = Minecraft.getMinecraft(); + protected Rectangle popupRect; + ChangeProfileWidget profileButtonWidget = new ChangeProfileWidget(); + private String lastuid; // actually current uid + private CompletableFuture> profileFuture; + private Future> gameProfileFuture; + private Future skinFuture; + private FakePlayer fakePlayer; + private boolean shouldDraw = false; + public FeatureViewPlayerStatsOnJoin() { + super("Party", "View player stats when join", "view player rendering when joining/someone joins the party", "partykicker.viewstats", true); + + + addParameter("datarenderers", new FeatureParameter>("datarenderers", "DataRenderers", "Datarenderssdasd", new ArrayList<>(Arrays.asList( + "catalv", "selected_class_lv", "dungeon_catacombs_higheststat", "dungeon_master_catacombs_higheststat", "skill_combat_lv", "skill_foraging_lv", "skill_mining_lv", "fairysouls", "dummy" + )), "stringlist")); + + + ChatProcessor.INSTANCE.subscribe(((txt, messageContext) -> { + + if (isEnabled() && txt.contains("ยงrยงejoined the dungeon group! (ยงrยงb")) { + String username = TextUtils.stripColor(txt).split(" ")[3]; + if (username.equalsIgnoreCase(mc.getSession().getUsername())) { + PartyManager.INSTANCE.requestPartyList(context -> { + if (context == null) { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงcBugged Dungeon Party ")); + } else { + processPartyMembers(context); + } + }); + } else { + processMemberJoin(username); + } + + + } + + + return ChatProcessResult.NONE; + })); + + } + + public static void clip(ScaledResolution resolution, int x, int y, int width, int height) { + if (width < 0 || height < 0) return; + + int scale = resolution.getScaleFactor(); + GL11.glScissor((x) * scale, mc.displayHeight - (y + height) * scale, (width) * scale, height * scale); + } + + public static void processPartyMembers(PartyContext context) { + for (String member : context.getPartyRawMembers()) { + processMemberJoin(member); + } + } + + private static void processMemberJoin(@NotNull String username) { + ApiFetcher.fetchUUIDAsync(username) + .thenAccept(a -> { + if (a == null) { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + username + "ยงf's Profile ยงcCouldn't fetch uuid")); + return; + } + + + ApiFetcher.fetchMostRecentProfileAsync(a.get(), FeatureRegistry.PARTYKICKER_APIKEY.getAPIKey()); + + IChatComponent comp = new ChatComponentText("ยงeDungeons Guide ยง7:: ยงe" + username + "ยงf's Profile ") + .appendSibling(new ChatComponentText("ยง7view").setChatStyle(new ChatStyle().setChatHoverEvent(new HoverEventRenderPlayer(a.orElse(null))))); + + + IChatComponent kickText = new ChatComponentText(" ยงcKICK").setChatStyle( + new ChatStyle() + .setChatClickEvent( + new ClickEvent(ClickEvent.Action.RUN_COMMAND, "") { + + boolean fuse = false; + @Override + public Action getAction() { + if(!fuse) { + ChatProcessor.INSTANCE.addToChatQueue("/p kick " + username, null, false); + fuse = true; + } + + return Action.RUN_COMMAND; + } + } + ) + ); + + + comp.appendSibling(kickText); + + + ChatTransmitter.addToQueue((ChatComponentText) comp); + + + }); + } + + @Override + public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { + if (!(mc.currentScreen instanceof GuiChat)) { + cancelRender(); + return; + } + + ScaledResolution scaledResolution = new ScaledResolution(mc); + + IChatComponent ichatcomponent = getHoveredComponent(scaledResolution); + String uid = null; + if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() instanceof HoverEventRenderPlayer) { + uid = ((HoverEventRenderPlayer) ichatcomponent.getChatStyle().getChatHoverEvent()).getUuid(); + } + + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * width / mc.displayWidth; + int mouseY = height - Mouse.getY() * height / mc.displayHeight - 1; + + shouldCancelRendering(uid, mouseX, mouseY); + + if (lastuid == null) return; + + + if (popupRect == null) { + popupRect = new Rectangle(mouseX, mouseY, 220, 220); + if (popupRect.y + popupRect.height > scaledResolution.getScaledHeight()) { + popupRect.y -= popupRect.y + popupRect.height - scaledResolution.getScaledHeight(); + } + } + + if (profileFuture == null) { + profileFuture = ApiFetcher.fetchMostRecentProfileAsync(lastuid, FeatureRegistry.PARTYKICKER_APIKEY.getAPIKey()); + } + + if (gameProfileFuture == null) { + gameProfileFuture = ApiFetcher.getSkinGameProfileByUUIDAsync(lastuid); + } + boolean plsSetAPIKEY = false; + if (skinFuture == null && gameProfileFuture.isDone()) { + try { + skinFuture = SkinFetcher.getSkinSet(gameProfileFuture.get().orElse(null)); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + + try { + if (fakePlayer == null && skinFuture != null && profileFuture != null && skinFuture.isDone() && profileFuture.isDone() && profileFuture.get().isPresent()) { + if (profileButtonWidget.getCurrentrySelectedProfile(profileFuture.get().get()) != null) { + if (skinFuture.get() != null) { + profileButtonWidget.setCurrentyselectedprofile(profileFuture.get().get().getLastestprofileArrayIndex()); + fakePlayer = new FakePlayer(gameProfileFuture.get().orElse(null), skinFuture.get(), profileButtonWidget.getCurrentrySelectedProfile(profileFuture.get().get()), profileButtonWidget.getCurrentyselectedprofile()); + } + } + } else if (fakePlayer != null) { + if (fakePlayer.getProfileNumber() != profileButtonWidget.getCurrentyselectedprofile()) { + fakePlayer = new FakePlayer(gameProfileFuture.get().orElse(null), skinFuture.get(), profileButtonWidget.getCurrentrySelectedProfile(profileFuture.get().get()), profileButtonWidget.getCurrentyselectedprofile()); + } + } + } catch (InterruptedException | ExecutionException e) { + plsSetAPIKEY = true; + } + + + Optional playerProfile; + if (plsSetAPIKEY || !profileFuture.isDone()) { + playerProfile = null; + } else { + PlayerSkyblockData data = null; + try { + data = profileFuture.get().get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + PlayerProfile currentlySelectedProfile = profileButtonWidget.getCurrentrySelectedProfile(data); + playerProfile = Optional.ofNullable(currentlySelectedProfile); + } + + + draw(scaledResolution, mouseX, mouseY, plsSetAPIKEY, playerProfile); + } + + private void draw(ScaledResolution scaledResolution, int mouseX, int mouseY, boolean plsSetAPIKEY, Optional playerProfile) { + GlStateManager.pushMatrix(); + GlStateManager.translate(popupRect.x, popupRect.y, 0); + int backroundGuiColor = 0xFF23272a; + Gui.drawRect(0, 0, popupRect.width, popupRect.height, backroundGuiColor); + Gui.drawRect(2, 2, popupRect.width - 2, popupRect.height - 2, 0XFF2c2f33); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (plsSetAPIKEY) { + mc.fontRendererObj.drawString("Please set API KEY on /dg -> Party Kicker", 5, 5, 0xFFFFFFFF); + GlStateManager.popMatrix(); + } else if (playerProfile == null) { + mc.fontRendererObj.drawString("Fetching data...", 5, 5, 0xFFFFFFFF); + GlStateManager.popMatrix(); + } else if (!playerProfile.isPresent()) { + mc.fontRendererObj.drawString("User could not be found", 5, 5, 0xFFFFFFFF); + GlStateManager.popMatrix(); + } else { + int relX = mouseX - popupRect.x; + int relY = mouseY - popupRect.y; + FontRenderer fr = mc.fontRendererObj; + GL11.glEnable(GL11.GL_SCISSOR_TEST); + clip(scaledResolution, popupRect.x, popupRect.y, popupRect.width, popupRect.height); + + Gui.drawRect(0, 168, 90, 195, backroundGuiColor); + Gui.drawRect(2, 170, 88, 193, new Rectangle(2, 170, 86, 23).contains(relX, relY) ? 0xFFff7777 : 0xFFFF3333); + + Gui.drawRect(0, 193, 90, 220, backroundGuiColor); + Gui.drawRect(2, 195, 88, 218, new Rectangle(2, 195, 86, 23).contains(relX, relY) ? 0xFF859DF0 : 0xFF7289da); + + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Kick", (90 - fr.getStringWidth("Kick")) / 2, (364 - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + fr.drawString("Invite", (90 - fr.getStringWidth("Invite")) / 2, (414 - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + + GlStateManager.pushMatrix(); + GlStateManager.translate(95, 5, 0); + int culmutativeY = 5; + IDataRenderer dataRendererToHover = null; + for (String datarenderers : this.>getParameter("datarenderers").getValue()) { + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + Dimension dim; + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0, 0, 0xFFFF0000); + fr.drawString(datarenderers, 0, fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderData(playerProfile.get()); + GlStateManager.popMatrix(); + } + if (relX >= 95 && relX <= popupRect.width && relY >= culmutativeY && relY < culmutativeY + dim.height && dataRenderer != null) { + dataRendererToHover = dataRenderer; + } + culmutativeY += dim.height; + GlStateManager.translate(0, dim.height, 0); + } + GlStateManager.popMatrix(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + Gui.drawRect(0, 0, 90, 170, backroundGuiColor); + Gui.drawRect(2, 2, 88, 168, 0xFF444444); + + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + + profileButtonWidget.drawChangeProfileButton(relX, relY); + + + Gui.drawRect(78, 156, 90, 170, backroundGuiColor); + fr.drawString("ยงeI", 82, 159, -1); + + + GlStateManager.color(1, 1, 1, 1.0F); + if (fakePlayer != null) { + drawFakePlayer(scaledResolution, mouseX, mouseY, playerProfile, relX, relY, fr); + } else { + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Loading", 5, 35, 0xFFEFFF00); + } + GlStateManager.popMatrix(); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + if (dataRendererToHover != null && !shouldDraw) { + dataRendererToHover.onHover(playerProfile.get(), mouseX, mouseY); + } + GL11.glEnable(GL11.GL_SCISSOR_TEST); + GlStateManager.pushMatrix(); + GlStateManager.translate(popupRect.x, popupRect.y, 0); + if (shouldDraw) { + int startX = 81; + int startY = 86; + clip(scaledResolution, popupRect.x + startX - 1, popupRect.y + startY - 1, 164, 74); + GlStateManager.translate(startX, startY, 1); + Gui.drawRect(-1, -1, 163, 73, 0xFF000000); + GlStateManager.disableLighting(); + ItemStack toHover = null; + int rx = relX - startX; + int ry = relY - startY; + + if (playerProfile.get().getInventory() != null) { + GlStateManager.disableRescaleNormal(); + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.disableLighting(); + for (int i = 0; i < playerProfile.get().getInventory().length; i++) { + int x = (i % 9) * 18; + int y = (i / 9) * 18; + if (x <= rx && rx < x + 18 && y <= ry && ry < y + 18) { + toHover = playerProfile.get().getInventory()[(i + 9) % 36]; + } + Gui.drawRect(x, y, x + 18, y + 18, 0xFF000000); + Gui.drawRect(x + 1, y + 1, x + 17, y + 17, 0xFF666666); + GlStateManager.color(1, 1, 1, 1.0F); + + mc.getRenderItem().renderItemAndEffectIntoGUI(playerProfile.get().getInventory()[(i + 9) % 36], (i % 9) * 18 + 1, (i / 9) * 18 + 1); + } + + if (toHover != null) { + drawItemStackToolTip(scaledResolution, mouseX, mouseY, fr, toHover); + } + } else { + Gui.drawRect(0, 0, 162, 72, 0xFF666666); + fr.drawSplitString("Player has disabled Inventory API", 5, 5, 142, -1); + } + + } + GL11.glDisable(GL11.GL_SCISSOR_TEST); + GlStateManager.popMatrix(); // 33 66 108 130 154 // 5 75 + } + + + } + + private void drawFakePlayer(ScaledResolution scaledResolution, int mouseX, int mouseY, Optional playerProfile, int relX, int relY, FontRenderer fr) { + clip(scaledResolution, popupRect.x + 2, popupRect.y + 2, 86, 166); + GuiInventory.drawEntityOnScreen(45, 150, 60, -(mouseX - popupRect.x - 75), 0, fakePlayer); + + String toDraw = fakePlayer.getName(); + List activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayer().get(UUID.fromString(TextUtils.insertDashUUID(playerProfile.get().getMemberUID()))); + CosmeticData prefix = null; + CosmeticData color = null; + if (activeCosmetics != null) { + for (ActiveCosmetic activeCosmetic : activeCosmetics) { + CosmeticData cosmeticData = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData != null) { + if (cosmeticData.getCosmeticType().equals("prefix")) prefix = cosmeticData; + if (cosmeticData.getCosmeticType().equals("color")) color = cosmeticData; + } + } + } + toDraw = (color == null ? "ยงe" : color.getData().replace("&", "ยง")) + toDraw; + if (prefix != null) toDraw = prefix.getData().replace("&", "ยง") + " " + toDraw; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + + + String profileName = "on ยง6" + playerProfile.get().getProfileName(); + fr.drawString(profileName, (90 - fr.getStringWidth(profileName)) / 2, 15, -1); + + + fr.drawString(toDraw, (90 - fr.getStringWidth(toDraw)) / 2, 10 - (fr.FONT_HEIGHT / 2), -1); + + ItemStack toHover = null; + if (relX > 20 && relX < 70) { + if (33 <= relY && relY <= 66) { + toHover = fakePlayer.getInventory()[3]; + } else if (66 <= relY && relY <= 108) { + toHover = fakePlayer.getInventory()[2]; + } else if (108 <= relY && relY <= 130) { + toHover = fakePlayer.getInventory()[1]; + } else if (130 <= relY && relY <= 154) { + toHover = fakePlayer.getInventory()[0]; + } + } else if (relX > 0 && relX <= 20) { + if (80 <= relY && relY <= 120) { + toHover = fakePlayer.inventory.mainInventory[fakePlayer.inventory.currentItem]; + } + } + + if (toHover != null) { + drawItemStackToolTip(scaledResolution, mouseX, mouseY, fr, toHover); + GlStateManager.translate(popupRect.x, popupRect.y, 0); + } + clip(scaledResolution, popupRect.x, popupRect.y, popupRect.width, popupRect.height); + } + + public void drawItemStackToolTip(ScaledResolution scaledResolution, int mouseX, int mouseY, FontRenderer fr, ItemStack toHover) { + List list = toHover.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips); + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { + list.set(i, toHover.getRarity().rarityColor + list.get(i)); + } else { + list.set(i, EnumChatFormatting.GRAY + list.get(i)); + } + } + FontRenderer font = toHover.getItem().getFontRenderer(toHover); + GlStateManager.popMatrix(); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + FontRenderer theRenderer = (font == null ? fr : font); + GuiUtils.drawHoveringText(list, mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, theRenderer); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + GlStateManager.pushMatrix(); + } + + private void shouldCancelRendering(String uid, int mouseX, int mouseY) { + if (!((popupRect != null && (popupRect.contains(mouseX, mouseY) || shouldDraw)) || uid != null && uid.equals(lastuid))) { + cancelRender(); + } + + if (uid != null && !uid.equals(lastuid) && (popupRect == null || (!popupRect.contains(mouseX, mouseY) && !shouldDraw))) { + cancelRender(); + lastuid = uid; + } + } + + public void cancelRender() { + popupRect = null; + profileFuture = null; + lastuid = null; + gameProfileFuture = null; + skinFuture = null; + fakePlayer = null; + shouldDraw = false; + } + + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + ScaledResolution scaledResolution = new ScaledResolution(mc); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * width / mc.displayWidth; + int mouseY = height - Mouse.getY() * height / mc.displayHeight - 1; + + if (Mouse.getEventButton() != -1 && Mouse.isButtonDown(Mouse.getEventButton()) && shouldDraw) + shouldDraw = false; + if (popupRect == null || !popupRect.contains(mouseX, mouseY)) return; + + mouseInputEvent.setCanceled(true); + + int relX = mouseX - popupRect.x; + int relY = mouseY - popupRect.y; + + try { + PlayerSkyblockData playerData; + + if (profileFuture.isDone()) { + playerData = profileFuture.get().orElse(null); + } else { + return; + } + + if (playerData == null) { + return; + } + + if (Mouse.getEventButton() == -1 && !Mouse.isButtonDown(Mouse.getEventButton())) return; + + if (new Rectangle(2, 195, 86, 23).contains(relX, relY)) { + // invite + ChatProcessor.INSTANCE.addToChatQueue("/p invite " + ApiFetcher.fetchNicknameAsync(profileButtonWidget.getCurrentrySelectedProfile(playerData).getMemberUID()).get().orElse("-"), () -> { + }, true); + } else if (new Rectangle(2, 170, 86, 23).contains(relX, relY)) { + // kick + ChatProcessor.INSTANCE.addToChatQueue("/p kick " + ApiFetcher.fetchNicknameAsync(profileButtonWidget.getCurrentrySelectedProfile(playerData).getMemberUID()).get().orElse("-"), () -> { + }, true); + } else if (new Rectangle(80, 159, 10, 11).contains(relX, relY)) { + shouldDraw = true; + } + + + this.profileButtonWidget.handleClickProfileButton(playerData); + + + } catch (InterruptedException | ExecutionException e) { + } + + + } + + public IChatComponent getHoveredComponent(ScaledResolution scaledResolution) { + IChatComponent ichatcomponent = null; + if (Loader.isModLoaded("hychat")) { + try { + ChatManager chatManager = HyChat.getInstance().getChatManager(); + GuiChatBox guiChatBox = chatManager.getFocusedChat(); + + int x = guiChatBox.getX(scaledResolution); + int y = guiChatBox.getY(scaledResolution); + ichatcomponent = guiChatBox.chatArray.getHoveredComponent(guiChatBox.getSelectedTab().getChatLines(), Mouse.getX(), Mouse.getY(), x, y); + } catch (Throwable t) { + } + } + if (ichatcomponent == null) { + ichatcomponent = Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY()); + } + return ichatcomponent; + } + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey(), () -> { + + MFeatureEdit featureEdit = new MFeatureEdit(FeatureViewPlayerStatsOnJoin.this, rootConfigPanel); + featureEdit.addParameterEdit("datarenderers", new DataRendererEditor(FeatureViewPlayerStatsOnJoin.this)); + for (FeatureParameter parameter : getParameters()) { + if (parameter.getKey().equals("datarenderers")) continue; + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureViewPlayerStatsOnJoin.this, parameter, rootConfigPanel)); + } + return featureEdit; + }); + return "base." + getKey(); + } + + public static class HoverEventRenderPlayer extends HoverEvent { + @Getter + private final String uuid; + private IChatComponent cached; + + public HoverEventRenderPlayer(String uuid) { + super(Action.SHOW_TEXT, new ChatComponentText("")); + this.uuid = uuid; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + HoverEventRenderPlayer that = (HoverEventRenderPlayer) o; + return Objects.equals(uuid, that.uuid); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), uuid); + } + + @Override + public IChatComponent getValue() { + if (cached == null) { + cached = new ChatComponentText("") + .setChatStyle( + new ChatStyle() + .setChatHoverEvent( + new HoverEvent( + Action.SHOW_TEXT, + new ChatComponentText(uuid) + ) + ) + ); + return cached; + } + return cached; + } + } + + class ChangeProfileWidget { + FontRenderer fr; + @Getter + @Setter + int currentyselectedprofile = 0; + String buttonText = "Switch Profile"; + int stringWidth; + int textx; + int texty; + int blockWidth; + int blockHeight; + long clickDeBounce = 0; + + public ChangeProfileWidget() { + fr = Minecraft.getMinecraft().fontRendererObj; + stringWidth = fr.getStringWidth(buttonText); + textx = ((83 - stringWidth) / 2); + texty = (324 - fr.FONT_HEIGHT) / 2; + blockWidth = stringWidth + 3; + blockHeight = fr.FONT_HEIGHT + 2; + } + + void drawChangeProfileButton(float relX, float relY) { + + boolean contains = isWithinButtonRec(relX, relY); + + Gui.drawRect(textx - 5, texty - 1, textx + blockWidth, texty + blockHeight, contains ? 0xFFFFFFFF : 0xFF30afd3); + + fr.drawString(buttonText, textx, texty + 2, contains ? 0x30afd3 : 0xFFFFFF); + } + + Rectangle getButtonRec() { + return new Rectangle(textx - 5, texty - 1, blockWidth, blockHeight); + } + + boolean isWithinButtonRec(float relX, float relY) { + return getButtonRec().contains(relX, relY); + } + + void handleClickProfileButton(PlayerSkyblockData playerData) { + + if (System.currentTimeMillis() <= clickDeBounce) { + return; + } else { + clickDeBounce = System.currentTimeMillis() + 200; + } + + ScaledResolution scaledResolution = new ScaledResolution(mc); + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * width / mc.displayWidth; + int mouseY = height - Mouse.getY() * height / mc.displayHeight - 1; + + int relX = mouseX - popupRect.x; + int relY = mouseY - popupRect.y; + + if (isWithinButtonRec(relX, relY)) { + if (profileButtonWidget.currentyselectedprofile + 1 >= playerData.getPlayerProfiles().length) { + profileButtonWidget.currentyselectedprofile = 0; + } else { + profileButtonWidget.currentyselectedprofile++; + } + } + } + + PlayerProfile getCurrentrySelectedProfile(PlayerSkyblockData data) { + if (data == null) return null; + if (data.getPlayerProfiles() == null) return null; + if (data.getPlayerProfiles().length == 0) return null; + if (data.getPlayerProfiles().length < currentyselectedprofile) return null; + return data.getPlayerProfiles()[currentyselectedprofile]; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java new file mode 100644 index 00000000..32c38440 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java @@ -0,0 +1,387 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.mojang.authlib.GameProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfileParser; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import org.apache.commons.io.IOUtils; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ApiFetcher { + + private ApiFetcher(){} + + private static final Gson gson = new Gson(); + + private static final Map> playerProfileCache = new ConcurrentHashMap<>(); + private static final Map> nicknameToUID = new ConcurrentHashMap<>(); + private static final Map> UIDtoNickname = new ConcurrentHashMap<>(); + private static final Map> UIDtoGameProfile = new ConcurrentHashMap<>(); + + private static final ExecutorService ex = Executors.newFixedThreadPool(4); + + private static final Set invalidKeys = new HashSet<>(); + + public static void purgeCache() { + playerProfileCache.clear(); + nicknameToUID.clear(); + UIDtoNickname.clear(); + UIDtoGameProfile.clear(); + + completableFutureMap.clear(); + completableFutureMap2.clear(); + completableFutureMap3.clear(); + completableFutureMap4.clear(); + invalidKeys.clear(); + PlayerProfileParser.constants = null; + + ex.submit(PlayerProfileParser::getLilyWeightConstants); + } + + static { + ex.submit(PlayerProfileParser::getLilyWeightConstants); + } + + public static JsonObject getJson(String url) throws IOException { + URLConnection connection = new URL(url).openConnection(); + connection.setConnectTimeout(10000); + connection.setReadTimeout(10000); + InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream()); + String serverres = IOUtils.toString(inputStreamReader); + return gson.fromJson(serverres, JsonObject.class); + } + + public static JsonArray getJsonArr(String url) throws IOException { + URLConnection connection = new URL(url).openConnection(); + connection.setConnectTimeout(10000); + connection.setReadTimeout(10000); + return gson.fromJson(new InputStreamReader(connection.getInputStream()), JsonArray.class); + } + + private static final Map>> completableFutureMap4 = new ConcurrentHashMap<>(); + + public static CompletableFuture> getSkinGameProfileByUUIDAsync(String uid) { + if (UIDtoGameProfile.containsKey(uid)) { + CachedData cachedData = UIDtoGameProfile.get(uid); + if (cachedData.getExpire() > System.currentTimeMillis()) { + return CompletableFuture.completedFuture(Optional.ofNullable(cachedData.getData())); + } + UIDtoGameProfile.remove(uid); + } + if (completableFutureMap4.containsKey(uid)) return completableFutureMap4.get(uid); + + CompletableFuture> completableFuture = new CompletableFuture<>(); + fetchNicknameAsync(uid).thenAccept(nick -> { + if (!nick.isPresent()) { + completableFuture.complete(Optional.empty()); + return; + } + ex.submit(() -> { + try { + Optional playerProfile = getSkinGameProfileByUUID(uid, nick.get()); + UIDtoGameProfile.put(uid, new CachedData(System.currentTimeMillis() + 1000 * 60 * 30, playerProfile.orElse(null))); + completableFuture.complete(playerProfile); + completableFutureMap4.remove(uid); + return; + } catch (IOException e) { + e.printStackTrace(); + } + completableFuture.complete(Optional.empty()); + completableFutureMap4.remove(uid); + }); + }); + completableFutureMap4.put(uid, completableFuture); + return completableFuture; + } + + public static Optional getSkinGameProfileByUUID(String uid, String nickname) throws IOException { + GameProfile gameProfile = new GameProfile(UUID.fromString(uid), nickname); + GameProfile newProf = Minecraft.getMinecraft().getSessionService().fillProfileProperties(gameProfile, true); + return newProf == gameProfile ? Optional.empty() : Optional.of(newProf); + } + + + private static final Map>> completableFutureMap = new ConcurrentHashMap<>(); + + public static CompletableFuture> fetchMostRecentProfileAsync(String uid, String apiKey) { + if (playerProfileCache.containsKey(uid)) { + CachedData cachedData = playerProfileCache.get(uid); + if (cachedData.getExpire() > System.currentTimeMillis()) { + return CompletableFuture.completedFuture(Optional.ofNullable(cachedData.getData())); + } + playerProfileCache.remove(uid); + } + if (completableFutureMap.containsKey(uid)) { + return completableFutureMap.get(uid); + } + if (invalidKeys.contains(apiKey)) { + CompletableFuture cf = new CompletableFuture(); + cf.completeExceptionally(new IOException("403 for url")); + return cf; + } + CompletableFuture> completableFuture = new CompletableFuture<>(); + ex.submit(() -> { + try { + Optional playerProfile = fetchPlayerProfiles(uid, apiKey); + playerProfileCache.put(uid, new CachedData<>(System.currentTimeMillis() + 1000 * 60 * 30, playerProfile.orElse(null))); + completableFuture.complete(playerProfile); + completableFutureMap.remove(uid); + } catch (IOException e) { + if (e.getMessage().contains("403 for URL")) { + completableFuture.completeExceptionally(e); + completableFutureMap.remove(uid); + invalidKeys.add(apiKey); + } else { + completableFuture.completeExceptionally(e); + completableFutureMap.remove(uid); + } + e.printStackTrace(); + } + }); + completableFutureMap.put(uid, completableFuture); + return completableFuture; + } + + private static final Map>> completableFutureMap3 = new ConcurrentHashMap<>(); + + public static CompletableFuture> fetchNicknameAsync(String uid) { + if (UIDtoNickname.containsKey(uid)) { + CachedData cachedData = UIDtoNickname.get(uid); + if (cachedData.getExpire() > System.currentTimeMillis()) { + return CompletableFuture.completedFuture(Optional.ofNullable(cachedData.getData())); + } + UIDtoNickname.remove(uid); + } + if (completableFutureMap3.containsKey(uid)) return completableFutureMap3.get(uid); + + + CompletableFuture> completableFuture = new CompletableFuture<>(); + + ex.submit(() -> { + try { + Optional playerProfile = fetchNickname(uid); + UIDtoNickname.put(uid, new CachedData(System.currentTimeMillis() + 1000 * 60 * 60 * 12, playerProfile.orElse(null))); + if (playerProfile.isPresent()) + nicknameToUID.put(playerProfile.orElse(null), new CachedData<>(System.currentTimeMillis() + 1000 * 60 * 60 * 12, uid)); + completableFuture.complete(playerProfile); + completableFutureMap3.remove(uid); + return; + } catch (IOException e) { + e.printStackTrace(); + } + completableFuture.complete(Optional.empty()); + completableFutureMap3.remove(uid); + }); + completableFutureMap3.put(uid, completableFuture); + + return completableFuture; + } + + private static final Map>> completableFutureMap2 = new ConcurrentHashMap<>(); + + public static CompletableFuture> fetchUUIDAsync(String nickname) { + if (nicknameToUID.containsKey(nickname)) { + CachedData cachedData = nicknameToUID.get(nickname); + if (cachedData.getExpire() > System.currentTimeMillis()) { + return CompletableFuture.completedFuture(Optional.ofNullable(cachedData.getData())); + } + nicknameToUID.remove(nickname); + } + if (completableFutureMap2.containsKey(nickname)) return completableFutureMap2.get(nickname); + + + CompletableFuture> completableFuture = new CompletableFuture<>(); + + ex.submit(() -> { + try { + Optional playerProfile = fetchUUID(nickname); + nicknameToUID.put(nickname, new CachedData(System.currentTimeMillis() + 1000 * 60 * 60 * 12, playerProfile.orElse(null))); + if (playerProfile.isPresent()) + UIDtoNickname.put(playerProfile.orElse(null), new CachedData<>(System.currentTimeMillis() + 1000 * 60 * 60 * 12, nickname)); + + completableFuture.complete(playerProfile); + completableFutureMap2.remove(nickname); + return; + } catch (IOException e) { + e.printStackTrace(); + } + completableFuture.complete(Optional.empty()); + completableFutureMap2.remove(nickname); + }); + completableFutureMap2.put(nickname, completableFuture); + + return completableFuture; + } + + public static Optional fetchUUID(String nickname) throws IOException { + JsonObject json = getJson("https://api.mojang.com/users/profiles/minecraft/" + nickname); + if (json.has("error")) return Optional.empty(); + return Optional.of(TextUtils.insertDashUUID(json.get("id").getAsString())); + } + + public static Optional fetchNickname(String uuid) throws IOException { + try { + JsonArray json = getJsonArr("https://api.mojang.com/user/profiles/" + uuid.replace("-", "") + "/names"); + return Optional.of(json.get(json.size() - 1).getAsJsonObject().get("name").getAsString()); + } catch (Exception e) { + return Optional.empty(); + } + } + + + public static Optional getNumberOfSecretsFromAchievement(String uid, String apiKey) throws IOException { + JsonObject responce = getJson("https://api.hypixel.net/player?uuid=" + uid + "&key=" + apiKey); + if (responce.has("player")) { + JsonObject treasures = responce.getAsJsonObject("player"); + if (treasures.has("achievements")) { + treasures = treasures.getAsJsonObject("achievements"); + if (treasures.has("skyblock_treasure_hunter")) { + return Optional.of(treasures.get("skyblock_treasure_hunter").getAsInt()); + } + } + } + return Optional.empty(); + } + + + public static int getArrayIndex(Object[] arr,Object value) { + int k=0; + for(int i=0;i fetchPlayerProfiles(String uid, String apiKey) throws IOException { + System.out.println("Featching player profiles"); + JsonObject json = getJson("https://api.hypixel.net/skyblock/profiles?uuid=" + uid + "&key=" + apiKey); + if (!json.get("success").getAsBoolean()) return Optional.empty(); + System.out.println("Downloaded data from api"); + JsonArray profiles = json.getAsJsonArray("profiles"); + String dashTrimmed = uid.replace("-", ""); + + + PlayerSkyblockData pp = new PlayerSkyblockData(); + ArrayList playerProfiles = new ArrayList<>(); + System.out.println("Saving and parsing data"); + float lastSave = Long.MIN_VALUE; + PlayerProfile lastest = null; + for (JsonElement jsonElement : profiles) { + JsonObject semiProfile = jsonElement.getAsJsonObject(); + if (!semiProfile.get("members").getAsJsonObject().has(dashTrimmed)) { + System.out.println("Profile does not appear to have the player???"); + continue; + } + + System.out.println("Parsing profile"); + PlayerProfile e = PlayerProfileParser.parseProfile(semiProfile, dashTrimmed); + + System.out.println("Finished Parsing Profile"); + + + System.out.println("Getting nm of secrets from achivment"); + getNumberOfSecretsFromAchievement(uid, apiKey).ifPresent(e::setTotalSecrets); + System.out.println("finished getting secrets from achivment"); + + + System.out.println("Gettign last save"); + JsonElement last_save = semiProfile.get("last_save"); + if(last_save != null){ + float lastSave2 = last_save.getAsLong(); + if (lastSave2 > lastSave) { + lastest = e; + lastSave = lastSave2; + } + } + System.out.println("Finished getting last save"); + + playerProfiles.add(e); + } + System.out.println("THE AMMOUT OF PLAYER PROFILES: " + playerProfiles.size()); + PlayerProfile[] p = new PlayerProfile[playerProfiles.size()]; + pp.setLastestprofileArrayIndex(getArrayIndex(p, lastest)); + pp.setPlayerProfiles(playerProfiles.toArray(p)); + return Optional.of(pp); + } + + public static Optional fetchMostRecentProfile(String uid, String apiKey) throws IOException { + JsonObject json = getJson("https://api.hypixel.net/skyblock/profiles?uuid=" + uid + "&key=" + apiKey); + if (!json.get("success").getAsBoolean()) return Optional.empty(); + JsonArray profiles = json.getAsJsonArray("profiles"); + String dashTrimmed = uid.replace("-", ""); + + JsonObject profile = null; + float lastSave = Long.MIN_VALUE; + for (JsonElement jsonElement : profiles) { + JsonObject semiProfile = jsonElement.getAsJsonObject(); + if (!semiProfile.getAsJsonObject("members").has(dashTrimmed)) { + continue; + } + JsonElement last_save = semiProfile.get("last_save"); + + JsonElement cute_name = semiProfile.get("cute_name"); + if (cute_name != null) { + System.out.println(cute_name.getAsString()); + } else { + System.out.println("THIS SHOULD NOT HAPPEN"); + } + + if (last_save == null) { + return Optional.empty(); + } + float lastSave2 = last_save.getAsLong(); + if (lastSave2 > lastSave) { + + profile = semiProfile; + lastSave = lastSave2; + } + } + + + if (profile == null) { + return Optional.empty(); + } + + PlayerProfile pp = PlayerProfileParser.parseProfile(profile, dashTrimmed); + + getNumberOfSecretsFromAchievement(uid, apiKey).ifPresent(pp::setTotalSecrets); + + return Optional.of(pp); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/CachedData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/CachedData.java new file mode 100644 index 00000000..fd70ec4d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/CachedData.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class CachedData { + private final long expire; + private final T data; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/PlayerSkyblockData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/PlayerSkyblockData.java new file mode 100644 index 00000000..2525183b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/PlayerSkyblockData.java @@ -0,0 +1,10 @@ +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import lombok.Data; + +@Data +public class PlayerSkyblockData { + PlayerProfile[] playerProfiles; + int lastestprofileArrayIndex; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/SkinFetcher.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/SkinFetcher.java new file mode 100644 index 00000000..00f0925d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/SkinFetcher.java @@ -0,0 +1,90 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.client.resources.SkinManager; +import net.minecraft.util.ResourceLocation; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; + +public class SkinFetcher { + + private SkinFetcher(){} + + private static final Map> skinSetMap = new ConcurrentHashMap<>(); + + private static final Map> currentReq = new HashMap<>(); + + public static CompletableFuture getSkinSet(GameProfile gameProfile) { + if (gameProfile == null) { + return CompletableFuture.completedFuture(new SkinSet(DefaultPlayerSkin.getDefaultSkinLegacy(), null, "default")); + } + if (skinSetMap.containsKey(gameProfile.getId().toString())) { + CachedData ss = skinSetMap.get(gameProfile.getId().toString()); + if (ss.getExpire() > System.currentTimeMillis()) + CompletableFuture.completedFuture(skinSetMap.get(gameProfile.getId().toString()).getData()); + skinSetMap.remove(gameProfile.getId().toString()); + } + if (currentReq.containsKey(gameProfile.getId().toString())) + return currentReq.get(gameProfile.getId().toString()); + + SkinSet skinSet = new SkinSet(); + CompletableFuture skinSet2 = new CompletableFuture<>(); + currentReq.put(gameProfile.getId().toString(), skinSet2); + Minecraft.getMinecraft().getSkinManager().loadProfileTextures(gameProfile, new SkinManager.SkinAvailableCallback() { + public void skinAvailable(MinecraftProfileTexture.Type p_180521_1_, ResourceLocation location, MinecraftProfileTexture profileTexture) { + switch (p_180521_1_) { + case SKIN: + skinSet.setSkinLoc(location); + skinSet.setSkinType(profileTexture.getMetadata("model")); + if (skinSet.getSkinType() == null) { + skinSet.setSkinType("default"); + } + skinSet2.complete(skinSet); + skinSetMap.put(gameProfile.getId().toString(), new CachedData<>(System.currentTimeMillis() + 1000*60*60*3, skinSet)); + currentReq.get(gameProfile.getId().toString()); + break; + case CAPE: + skinSet.setCapeLoc(location); + } + } + }, true); + + return skinSet2; + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class SkinSet { + private ResourceLocation skinLoc; + private ResourceLocation capeLoc; + private String skinType; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/PlayerProfile.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/PlayerProfile.java new file mode 100644 index 00000000..61140679 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/PlayerProfile.java @@ -0,0 +1,92 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.*; +import lombok.Data; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Data +public class PlayerProfile { + private String profileUID; + private String memberUID; + private String profileName; + + private long lastSave; + + private int fairySouls; + private int fairyExchanges; + + private Armor currentArmor; + private List wardrobe = new ArrayList<>(); + private int selectedWardrobe = -1; + + private ItemStack[] inventory; + private ItemStack[] enderchest; + private ItemStack[] talismans; + + private int totalSecrets; + + @Data + public static class Armor { + private final ItemStack[] armorSlots = new ItemStack[4]; + + public ItemStack getHelmet() { return armorSlots[3]; } + public ItemStack getChestPlate() { return armorSlots[2]; } + public ItemStack getLeggings() { return armorSlots[1]; } + public ItemStack getBoots() { return armorSlots[0]; } + } + + private Map> dungeonStats = new HashMap<>(); + + private Map> playerClassData = new HashMap<>(); + private DungeonClass selectedClass; + @Data + public static class PlayerClassData { + private double experience; + } + + private Map skillXp; + + private List pets = new ArrayList<>(); + + + private Map additionalProperties = new HashMap<>(); + + private LilyWeight lilyWeight; + + @Data + public static class LilyWeight { + private double skill_base; + private double skill_overflow; + private double catacombs_base; + private double catacombs_master; + private double catacombs_exp; + private double slayer; + + public double getTotal() { + return skill_base + skill_overflow + catacombs_base + catacombs_exp + catacombs_master + slayer; + } + } +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/PlayerProfileParser.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/PlayerProfileParser.java new file mode 100644 index 00000000..1ad26bc8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/PlayerProfileParser.java @@ -0,0 +1,449 @@ +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.ApiFetcher; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.*; +import kr.syeyoung.dungeonsguide.mod.utils.XPUtils; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.function.BiFunction; +import java.util.stream.Collectors; + +public class PlayerProfileParser { + + public static volatile JsonObject constants; + + public static JsonObject getLilyWeightConstants() { + if (constants != null) return constants; + try { + JsonObject jsonObject = ApiFetcher.getJson("https://raw.githubusercontent.com/Antonio32A/lilyweight/master/lib/constants.json"); + constants = jsonObject; + } catch (Exception e) { + throw new RuntimeException(e); + } + return constants; + } + + public static int getOrDefault(JsonObject jsonObject, String key, int value) { + if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; + return jsonObject.get(key).getAsInt(); + } + + public static long getOrDefault(JsonObject jsonObject, String key, long value) { + if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; + return jsonObject.get(key).getAsLong(); + } + + public static double getOrDefault(JsonObject jsonObject, String key, double value) { + if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; + return jsonObject.get(key).getAsDouble(); + } + + public static String getOrDefault(JsonObject jsonObject, String key, String value) { + if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; + return jsonObject.get(key).getAsString(); + } + + public static Double getOrDefaultNullable(JsonObject jsonObject, String key, Double value) { + if (jsonObject == null || !jsonObject.has(key) || jsonObject.get(key) instanceof JsonNull) return value; + return jsonObject.get(key).getAsDouble(); + } + + public static NBTTagCompound parseBase64NBT(String nbt) throws IOException { + return CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(nbt))); + } + + public static ItemStack deserializeNBT(NBTTagCompound nbtTagCompound) { + if (nbtTagCompound.hasNoTags()) return null; + ItemStack itemStack = new ItemStack(Blocks.stone); + itemStack.deserializeNBT(nbtTagCompound); + return itemStack; + } + + public static PlayerProfile parseProfile(JsonObject profile, String dashTrimmed) throws IOException { + PlayerProfile playerProfile = new PlayerProfile(); + playerProfile.setProfileUID(getOrDefault(profile, "profile_id", "")); + playerProfile.setMemberUID(dashTrimmed); + playerProfile.setProfileName(getOrDefault(profile, "cute_name", "")); + + JsonObject playerData = profile.getAsJsonObject("members").getAsJsonObject(dashTrimmed); + playerProfile.setLastSave(getOrDefault(playerData, "last_save", 0L)); + playerProfile.setFairySouls(getOrDefault(playerData, "fairy_souls_collected", 0)); + playerProfile.setFairyExchanges(getOrDefault(playerData, "fairy_exchanges", 0)); + + if (playerData.has("inv_armor")) { + playerProfile.setCurrentArmor(new PlayerProfile.Armor()); + NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("inv_armor") + .get("data") + .getAsString()); + NBTTagList array = armor.getTagList("i", 10); + for (int i = 0; i < 4; i++) { + NBTTagCompound item = array.getCompoundTagAt(i); + playerProfile.getCurrentArmor().getArmorSlots()[i] = deserializeNBT(item); + } + } + + if (playerData.has("wardrobe_contents")) { + NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("wardrobe_contents").get("data").getAsString()); + NBTTagList array = armor.getTagList("i", 10); + for (int i = 0; i < array.tagCount(); i++) { + if (i % 4 == 0) playerProfile.getWardrobe().add(new PlayerProfile.Armor()); + NBTTagCompound item = array.getCompoundTagAt(i); + playerProfile.getWardrobe().get(i / 4).getArmorSlots()[i % 4] = deserializeNBT(item); + } + + } + playerProfile.setSelectedWardrobe(getOrDefault(playerData, "wardrobe_equipped_slot", -1)); + + if (playerData.has("inv_contents")) { + NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("inv_contents").get("data").getAsString()); + NBTTagList array = armor.getTagList("i", 10); + playerProfile.setInventory(new ItemStack[array.tagCount()]); + for (int i = 0; i < array.tagCount(); i++) { + NBTTagCompound item = array.getCompoundTagAt(i); + playerProfile.getInventory()[i] = deserializeNBT(item); + } + } + if (playerData.has("ender_chest_contents")) { + NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("ender_chest_contents").get("data").getAsString()); + NBTTagList array = armor.getTagList("i", 10); + playerProfile.setEnderchest(new ItemStack[array.tagCount()]); + for (int i = 0; i < array.tagCount(); i++) { + NBTTagCompound item = array.getCompoundTagAt(i); + playerProfile.getEnderchest()[i] = deserializeNBT(item); + } + } + if (playerData.has("talisman_bag")) { + NBTTagCompound armor = parseBase64NBT(playerData.getAsJsonObject("talisman_bag").get("data").getAsString()); + NBTTagList array = armor.getTagList("i", 10); + playerProfile.setTalismans(new ItemStack[array.tagCount()]); + for (int i = 0; i < array.tagCount(); i++) { + NBTTagCompound item = array.getCompoundTagAt(i); + playerProfile.getTalismans()[i] = deserializeNBT(item); + } + } + + playerProfile.setSkillXp(new HashMap<>()); + for (Skill value : Skill.values()) { + playerProfile.getSkillXp().put(value, getOrDefaultNullable(playerData, "experience_skill_" + value.getJsonName(), null)); + } + + if (playerData.has("pets")) { + for (JsonElement pets : playerData.getAsJsonArray("pets")) { + JsonObject pet = pets.getAsJsonObject(); + Pet petObj = new Pet(); + petObj.setActive(pet.get("active").getAsBoolean()); + petObj.setExp(getOrDefault(pet, "exp", 0.0)); + petObj.setHeldItem(getOrDefault(pet, "heldItem", null)); + petObj.setSkin(getOrDefault(pet, "skin", null)); + petObj.setType(getOrDefault(pet, "type", null)); + petObj.setUuid(getOrDefault(pet, "uuid", null)); + + playerProfile.getPets().add(petObj); + } + } + + if (playerData.has("dungeons") && playerData.getAsJsonObject("dungeons").has("dungeon_types")) { + JsonObject types = playerData.getAsJsonObject("dungeons") + .getAsJsonObject("dungeon_types"); + for (DungeonType value : DungeonType.values()) { + DungeonStat dungeonStat = new DungeonStat(); + DungeonSpecificData dungeonSpecificData = new DungeonSpecificData<>(value, dungeonStat); + playerProfile.getDungeonStats().put(value, dungeonSpecificData); + + if (!types.has(value.getJsonName())) continue; + + JsonObject dungeonObj = types.getAsJsonObject(value.getJsonName()); + + dungeonStat.setHighestCompleted(getOrDefault(dungeonObj, "highest_tier_completed", -1)); + + for (Integer validFloor : value.getValidFloors()) { + DungeonStat.PlayedFloor playedFloor = new DungeonStat.PlayedFloor(); + playedFloor.setBestScore(getOrDefault(dungeonObj.getAsJsonObject("best_score"), "" + validFloor, 0)); + playedFloor.setCompletions(getOrDefault(dungeonObj.getAsJsonObject("tier_completions"), "" + validFloor, 0)); + playedFloor.setFastestTime(getOrDefault(dungeonObj.getAsJsonObject("fastest_time"), "" + validFloor, -1)); + playedFloor.setFastestTimeS(getOrDefault(dungeonObj.getAsJsonObject("fastest_time_s"), "" + validFloor, -1)); + playedFloor.setFastestTimeSPlus(getOrDefault(dungeonObj.getAsJsonObject("fastest_time_s_plus"), "" + validFloor, -1)); + playedFloor.setMobsKilled(getOrDefault(dungeonObj.getAsJsonObject("mobs_killed"), "" + validFloor, 0)); + playedFloor.setMostMobsKilled(getOrDefault(dungeonObj.getAsJsonObject("most_mobs_killed"), "" + validFloor, 0)); + playedFloor.setMostHealing(getOrDefault(dungeonObj.getAsJsonObject("most_healing"), "" + validFloor, 0)); + playedFloor.setTimes_played(getOrDefault(dungeonObj.getAsJsonObject("times_played"), "" + validFloor, 0)); + playedFloor.setWatcherKills(getOrDefault(dungeonObj.getAsJsonObject("watcher_kills"), "" + validFloor, 0)); + + for (DungeonClass dungeonClass : DungeonClass.values()) { + DungeonStat.PlayedFloor.ClassStatistics classStatistics = new DungeonStat.PlayedFloor.ClassStatistics(); + classStatistics.setMostDamage(getOrDefault(dungeonObj.getAsJsonObject("most_damage_" + dungeonClass.getJsonName()), "" + validFloor, 0)); + ClassSpecificData classStatisticsClassSpecificData = new ClassSpecificData<>(dungeonClass, classStatistics); + + playedFloor.getClassStatistics().put(dungeonClass, classStatisticsClassSpecificData); + } + + FloorSpecificData playedFloorFloorSpecificData = new FloorSpecificData<>(validFloor, playedFloor); + dungeonStat.getPlays().put(validFloor, playedFloorFloorSpecificData); + } + + dungeonStat.setExperience(getOrDefault(dungeonObj, "experience", 0)); + + + } + } + if (playerData.has("dungeons") && playerData.getAsJsonObject("dungeons").has("player_classes")) { + JsonObject classes = playerData.getAsJsonObject("dungeons") + .getAsJsonObject("player_classes"); + for (DungeonClass dungeonClass : DungeonClass.values()) { + PlayerProfile.PlayerClassData classStatistics = new PlayerProfile.PlayerClassData(); + classStatistics.setExperience(getOrDefault(classes.getAsJsonObject(dungeonClass.getJsonName()), "experience", 0)); + ClassSpecificData classStatisticsClassSpecificData = new ClassSpecificData<>(dungeonClass, classStatistics); + + playerProfile.getPlayerClassData().put(dungeonClass, classStatisticsClassSpecificData); + } + } + if (playerData.has("dungeons")) { + String id = getOrDefault(playerData.getAsJsonObject("dungeons"), "selected_dungeon_class", null); + DungeonClass dungeonClass = DungeonClass.getClassByJsonName(id); + playerProfile.setSelectedClass(dungeonClass); + } + try { + calculateLilyWeight(playerProfile, playerData); + } catch (Exception e) { + e.printStackTrace(); + } + return playerProfile; + } + + private static void calculateLilyWeight(PlayerProfile playerProfile, JsonObject playerData) throws ExecutionException, InterruptedException { + JsonObject constants = getLilyWeightConstants(); + double[] slayerXP = new double[4]; + if (playerData.has("slayer_bosses")) { + slayerXP[0] = getOrDefault(playerData.getAsJsonObject("slayer_bosses").getAsJsonObject("zombie"), "xp", 0); + slayerXP[1] = getOrDefault(playerData.getAsJsonObject("slayer_bosses").getAsJsonObject("spider"), "xp", 0); + slayerXP[2] = getOrDefault(playerData.getAsJsonObject("slayer_bosses").getAsJsonObject("wolf"), "xp", 0); + slayerXP[3] = getOrDefault(playerData.getAsJsonObject("slayer_bosses").getAsJsonObject("enderman"), "xp", 0); + } + double skillWeight = 0; + double overflowWeight = 0; + { + JsonObject srw = constants.getAsJsonObject("skillRatioWeight"); + int skillMaxXP = constants.get("skillMaxXP").getAsInt(); + JsonArray overflowMultiplier = constants.getAsJsonArray("skillOverflowMultipliers"); + JsonArray skillFactor = constants.getAsJsonArray("skillFactors"); + + double skillAvg = playerProfile.getSkillXp().entrySet().stream() + .filter(a -> a.getValue() != null) + .filter(a -> srw.has(a.getKey().getJsonName())) + .map(a -> XPUtils.getSkillXp(a.getKey(), a.getValue()).getLevel()).collect(Collectors.averagingInt(a -> a)); + + double n = 12 * (skillAvg / 60) * (skillAvg / 60); + double r2 = Math.sqrt(2); + + for (Map.Entry skillDoubleEntry : playerProfile.getSkillXp().entrySet()) { + String jsonName = skillDoubleEntry.getKey().getJsonName(); + JsonArray temp_srw = srw.getAsJsonArray(jsonName); + if (temp_srw == null) continue; + int lv = XPUtils.getSkillXp(skillDoubleEntry.getKey(), skillDoubleEntry.getValue()).getLevel(); + skillWeight += n * temp_srw.get(lv).getAsDouble() + * temp_srw.get(temp_srw.size() - 1).getAsDouble(); + skillWeight += temp_srw.get(temp_srw.size() - 1).getAsDouble() * Math.pow(lv / 60.0, r2); + } + + int cnt = 0; + for (Map.Entry skillNames : constants.getAsJsonObject("skillNames").entrySet()) { + Skill s = getSkillByLilyName(skillNames.getKey()); + double factor = skillFactor.get(cnt).getAsDouble(); + double effectiveOver; + Double xp = playerProfile.getSkillXp().get(s); + if (xp == null) continue; + xp -= skillMaxXP; + { + if (xp < skillMaxXP) effectiveOver = xp; + else { + double remainingXP = xp; + double z = 0; + for (int i = 0; i <= xp / skillMaxXP; i++) { + if (remainingXP >= skillMaxXP) { + remainingXP -= skillMaxXP; + z += Math.pow(factor, i); + } + } + effectiveOver = z * skillMaxXP; + } + } + double rating = effectiveOver / skillMaxXP; + double overflowMult = overflowMultiplier.get(cnt).getAsDouble(); + double t = rating * overflowMult; + if (t > 0) overflowWeight += t; + cnt++; + } + } + double cataCompWeight, masterCompWeight; + { + JsonArray completionFactor = constants.getAsJsonArray("dungeonCompletionWorth"); + JsonObject dungeonCompletionBuffs = constants.getAsJsonObject("dungeonCompletionBuffs"); + double max1000 = 0; + double mMax1000 = 0; + for (int i = 0; i < completionFactor.size(); i++) { + if (i < 8) max1000 += completionFactor.get(i).getAsDouble(); + else mMax1000 += completionFactor.get(i).getAsDouble(); + } + + max1000 *= 1000; + mMax1000 *= 1000; + + double upperBound = 1500; + double score = 0; + + DungeonStat dStat = playerProfile.getDungeonStats().get(DungeonType.CATACOMBS).getData(); + for (FloorSpecificData value : dStat.getPlays().values()) { + int runs = value.getData().getCompletions(); + int excess = 0; + if (runs > 1000) { + excess = runs - 1000; + runs = 1000; + } + + double floorScore = runs * completionFactor.get(value.getFloor()).getAsDouble(); + if (excess > 0) + floorScore *= Math.log10(excess / 1000.0 + 1) / Math.log10(7.5) + 1; + score += floorScore; + } + cataCompWeight = (score / max1000 * upperBound); + + dStat = playerProfile.getDungeonStats().get(DungeonType.MASTER_CATACOMBS).getData(); + for (FloorSpecificData value : dStat.getPlays().values()) { + if (dungeonCompletionBuffs.has(value.getFloor() + "")) { + double threshold = 20; + if (value.getData().getCompletions() >= threshold) + upperBound += dungeonCompletionBuffs.get(value.getFloor() + "").getAsDouble(); + else + upperBound += dungeonCompletionBuffs.get(value.getFloor() + "").getAsDouble() * Math.pow(value.getData().getCompletions() / threshold, 1.840896416); + } + } + score = 0; + for (FloorSpecificData value : dStat.getPlays().values()) { + int runs = value.getData().getCompletions(); + int excess = 0; + if (runs > 1000) { + excess = runs - 1000; + runs = 1000; + } + + double floorScore = runs * completionFactor.get(value.getFloor() + 7).getAsDouble(); + if (excess > 0) + floorScore *= Math.log10(excess / 1000.0 + 1) / Math.log10(5) + 1; + score += floorScore; + } + + masterCompWeight = score / mMax1000 * upperBound; + } + double dungeonXPWeight = 0; + { + double dungeonOverall = constants.get("dungeonOverall").getAsDouble(); + double dungeonMaxXP = constants.get("dungeonMaxXP").getAsDouble(); + + double cataXP = playerProfile.getDungeonStats().get(DungeonType.CATACOMBS).getData().getExperience(); + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(cataXP); + double level = xpCalcResult.getLevel(); + if (xpCalcResult.getLevel() != 50) { + double progress = Math.floor(xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp() * 1000) / 1000.0; + level += progress; + } + + double n; + double tempLevel = 0; + if (cataXP < dungeonMaxXP) + n = 0.2 * Math.pow(level / 50.0, 2.967355422); + else { + double part = 142452410; + tempLevel = 50 + (cataXP - dungeonMaxXP) / part; + n = 0.2 * Math.pow(1 + ((tempLevel - 50) / 50), 2.967355422); + } + if (level != 0) { + if (cataXP < 569809640) + dungeonXPWeight = dungeonOverall * (Math.pow(1.18340401286164044, (level + 1)) - 1.05994990217254) * (1 + n); + else dungeonXPWeight = 4000 * (n / 0.15465244570598540); + } else dungeonXPWeight = 0; + } + double slayerWeight = 0; + { + JsonArray slayerDeprecationScaling = constants.getAsJsonArray("slayerDeprecationScaling"); + BiFunction getSlayerWeight = (xp, type) -> { + double score = 0; + { + double d = xp / 100000; + if (xp >= 6416) { + double D = (d - Math.pow(3, (-5 / 2.0))) * (d + Math.pow(3, -5 / 2.0)); + double u = Math.cbrt(3 * (d + Math.sqrt(D))); + double v = Math.cbrt(3 * (d - Math.sqrt(D))); + score = u + v - 1; + } else { + score = Math.sqrt(4 / 3.0) * Math.cos(Math.acos(d * Math.pow(3, 5 / 2.0)) / 3) - 1; + } + } + score = Math.floor(score); + double scaling = slayerDeprecationScaling.get(type).getAsDouble(); + double effectiveXP = 0; + for (int i = 1; i <= score; i++) + effectiveXP += (i * i + i) * Math.pow(scaling, i); + effectiveXP = Math.round((1000000 * effectiveXP * (0.05 / scaling)) * 100) / 100.0; + double actualXP = ((score * score * score / 6) + (score * score / 2) + (score / 3)) * 100000; + double distance = xp - actualXP; + double effectiveDistance = distance * Math.pow(scaling, score); + return effectiveXP + effectiveDistance; + }; + + double zombie = getSlayerWeight.apply(slayerXP[0], 0); + double spider = getSlayerWeight.apply(slayerXP[1], 1); + double wolf = getSlayerWeight.apply(slayerXP[2], 2); + double enderman = getSlayerWeight.apply(slayerXP[3], 3); + double individual = zombie / 7000 + spider / 4800 + wolf / 2200 + enderman / 1000; + double extra = (slayerXP[0] + 1.6 * slayerXP[1] + 3.6 * slayerXP[2] + 10 * slayerXP[3]) / 900000; + slayerWeight = (individual + extra); + } + + PlayerProfile.LilyWeight lilyWeight = new PlayerProfile.LilyWeight(); + lilyWeight.setCatacombs_base(cataCompWeight); + lilyWeight.setCatacombs_master(masterCompWeight); + lilyWeight.setCatacombs_exp(dungeonXPWeight); + lilyWeight.setSkill_base(skillWeight); + lilyWeight.setSkill_overflow(overflowWeight); + lilyWeight.setSlayer(slayerWeight); + + playerProfile.setLilyWeight(lilyWeight); + } + + private static Skill getSkillByLilyName(String lilyName) { + switch (lilyName) { + case "experience_skill_enchanting": + return Skill.ENCHANTING; + case "experience_skill_taming": + return Skill.TAMING; + case "experience_skill_alchemy": + return Skill.ALCHEMY; + case "experience_skill_mining": + return Skill.MINING; + case "experience_skill_farming": + return Skill.FARMING; + case "experience_skill_foraging": + return Skill.FORAGING; + case "experience_skill_combat": + return Skill.COMBAT; + case "experience_skill_fishing": + return Skill.FISHING; + default: + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/ClassSpecificData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/ClassSpecificData.java new file mode 100644 index 00000000..eff45140 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/ClassSpecificData.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public class ClassSpecificData { + private final DungeonClass dungeonClass; + private final T data; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonClass.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonClass.java new file mode 100644 index 00000000..da32a49b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonClass.java @@ -0,0 +1,46 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +@Getter +@AllArgsConstructor +public enum DungeonClass { + MAGE("mage", "Mage"), ARCHER("archer","Archer"), HEALER("healer", "Healer"), TANK("tank", "Tank"), BERSERK("berserk", "Berserk"); + + + private final String jsonName; + private final String familarName; + private static final Map jsonNameToClazz = new HashMap<>(); + static { + for (DungeonClass value : values()) { + jsonNameToClazz.put(value.getJsonName(), value); + } + } + + public static DungeonClass getClassByJsonName(String name) { + return jsonNameToClazz.get(name); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonSpecificData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonSpecificData.java new file mode 100644 index 00000000..a7f95a9f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonSpecificData.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class DungeonSpecificData { + private final DungeonType type; + private final T data; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonStat.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonStat.java new file mode 100644 index 00000000..4e9dab7f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonStat.java @@ -0,0 +1,54 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class DungeonStat { + private int highestCompleted; + private double experience; + + private Map> plays = new HashMap<>(); + @Data + public static class PlayedFloor { + private int times_played; + private int completions; + private int watcherKills; + + private int fastestTime; + private int fastestTimeS; + private int fastestTimeSPlus; + private int bestScore; + + private int mostMobsKilled; + private int mobsKilled; + + private Map> classStatistics = new HashMap<>(); + @Data + public static class ClassStatistics { + private double mostDamage; + } + + private double mostHealing; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonType.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonType.java new file mode 100644 index 00000000..0b8e8b37 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/DungeonType.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses; + +import com.google.common.collect.Sets; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Set; + +@Getter +@AllArgsConstructor +public enum DungeonType { + CATACOMBS("catacombs", "The Catacombs", + Sets.newHashSet(0,1,2,3,4,5,6,7)), + MASTER_CATACOMBS("master_catacombs", "MasterMode Catacombs", Sets.newHashSet( + 1,2,3,4,5,6 + )); + + private final String jsonName; + private final String familiarName; + private final Set validFloors ; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/FloorSpecificData.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/FloorSpecificData.java new file mode 100644 index 00000000..14ebbcf3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/FloorSpecificData.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class FloorSpecificData { + private final int floor; + private final T data; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/Pet.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/Pet.java new file mode 100644 index 00000000..e4a38fe6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/Pet.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses; + +import lombok.Data; + +@Data +public class Pet { + private String uuid; + private String type; + private double exp; + private boolean active; + private String heldItem; + private String skin; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/Skill.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/Skill.java new file mode 100644 index 00000000..10f1b1f9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/playerprofile/dataclasses/Skill.java @@ -0,0 +1,31 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum Skill { + RUNECRAFTING("runecrafting", "Runecrafting"), COMBAT("combat", "Combat"), MINING("mining", "Mining"), ALCHEMY("alchemy", "Alchemy"), FARMING("farming", "Farming"), TAMING("taming", "Taming"), ENCHANTING("enchanting", "Enchanting"), FISHING("fishing", "Fishing"), FORAGING("foraging", "Foraging"), CARPENTRY("carpentry", "Carpentry"); + + private final String jsonName; + private final String friendlyName; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/DataRendererEditor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/DataRendererEditor.java new file mode 100644 index 00000000..2da623b5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/DataRendererEditor.java @@ -0,0 +1,357 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.FeatureViewPlayerStatsOnJoin; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class DataRendererEditor extends MPanel { + private final FeatureViewPlayerStatsOnJoin feature; + + public DataRendererEditor(FeatureViewPlayerStatsOnJoin featureViewPlayerStatsOnJoin) { + this.feature = featureViewPlayerStatsOnJoin; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10, 260)); + } + + private String currentlySelected; + private int selectedX; + private int selectedY; + private int lastX; + private int lastY; + private int scrollY; + private final int baseWidth = 120; + private final int hamburgerWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth("=="); + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f)); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Available", (310 + baseWidth + hamburgerWidth -fr.getStringWidth("Available")) / 2, 4, 0xFFFFFFFF); + fr.drawString("Current", (baseWidth + hamburgerWidth+10 -fr.getStringWidth("Current")) /2 , 4, 0xFFFFFFFF); + Gui.drawRect(4,4 + fr.FONT_HEIGHT + 3,baseWidth + hamburgerWidth+6 + 1, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); + Gui.drawRect(5,5+ fr.FONT_HEIGHT + 3,baseWidth + hamburgerWidth + 5 + 1, 235+ fr.FONT_HEIGHT + 3, RenderUtils.blendAlpha(0x141414, 0.15f)); + Gui.drawRect(5 + hamburgerWidth,4+ fr.FONT_HEIGHT + 3,6 + hamburgerWidth, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); + + Gui.drawRect(154,4 + fr.FONT_HEIGHT + 3,150 + baseWidth + hamburgerWidth + 6+1, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); + Gui.drawRect(155,5+ fr.FONT_HEIGHT + 3,150 + baseWidth + hamburgerWidth + 5+1, 235+ fr.FONT_HEIGHT + 3, RenderUtils.blendAlpha(0x141414, 0.15f)); + Gui.drawRect(155 + hamburgerWidth,4 + fr.FONT_HEIGHT + 3,156 + hamburgerWidth, 236+ fr.FONT_HEIGHT + 3, 0xFF222222); + + GlStateManager.pushMatrix(); + clip(scissor.x + 6+hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + GlStateManager.translate(6+hamburgerWidth, 5+fr.FONT_HEIGHT+3, 0); + int culmutativeY = 0; + int relSelectedY = selectedY - (5+ fr.FONT_HEIGHT + 3); + boolean drewit = false; + for (String datarenderers : feature.>getParameter("datarenderers").getValue()) { + + if (0 <= selectedX && selectedX <= hamburgerWidth+11 && currentlySelected != null) { + IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); + Dimension dim; + if (dataRenderer == null) dim = new Dimension(0,fr.FONT_HEIGHT*2); + else dim = dataRenderer.getDimension(); + + if (culmutativeY + dim.height > relSelectedY && relSelectedY >= culmutativeY && !drewit) { + clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(currentlySelected, 0,fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + clip(scissor.x, scissor.y, scissor.width, scissor.height); + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFF777777); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.translate(hamburgerWidth+1,dim.height,0); + drewit = true; + } + } + + IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + Dimension dim; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(datarenderers, 0,fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + clip(scissor.x, scissor.y, scissor.width, scissor.height); + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.translate(hamburgerWidth+1,dim.height,0); + + culmutativeY += dim.height; + } + + if (currentlySelected != null && new Rectangle(0,5+fr.FONT_HEIGHT + 3, hamburgerWidth+11, 232).contains(selectedX, selectedY) && !drewit) { + IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); + Dimension dim; + clip(scissor.x + 6 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(currentlySelected, 0,fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + clip(scissor.x, scissor.y, scissor.width, scissor.height); + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFF777777); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.translate(hamburgerWidth+1,dim.height,0); + } + GlStateManager.popMatrix(); + + + GlStateManager.pushMatrix(); + GlStateManager.translate(156+hamburgerWidth, 5+fr.FONT_HEIGHT+3 - scrollY, 0); + + Set rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); + rest.removeAll( feature.>getParameter("datarenderers").getValue()); + rest.remove(currentlySelected); + for (String datarenderers : rest) { + IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + clip(scissor.x + 156 + hamburgerWidth, scissor.y + 5+fr.FONT_HEIGHT+3, baseWidth, 230); + Dimension dim; + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0,0, 0xFFFF0000); + fr.drawString(datarenderers, 0,fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + clip(scissor.x + 155, scissor.y + 5+fr.FONT_HEIGHT+3, hamburgerWidth, 230); + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.translate(hamburgerWidth+1,dim.height,0); + } + GlStateManager.popMatrix(); + clip(0,0,sr.getScaledWidth(), sr.getScaledHeight()); + { + if (currentlySelected != null) { + GlStateManager.pushMatrix(); + GlStateManager.translate(selectedX+hamburgerWidth+1, selectedY, 0); + IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(currentlySelected); + Dimension dim; + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (dataRenderer == null) { + fr.drawString("Couldn't find Datarenderer", 0, 0, 0xFFFF0000); + fr.drawString(currentlySelected, 0, fr.FONT_HEIGHT, 0xFFFF0000); + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.renderDummy(); + GlStateManager.popMatrix(); + } + GlStateManager.translate(-hamburgerWidth-1, 0, 0); + Gui.drawRect(0,0, hamburgerWidth, dim.height-1, 0xFFAAAAAA); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("=",fr.getStringWidth("=")/2,(dim.height - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); + GlStateManager.popMatrix(); + } + } + clip(scissor.x, scissor.y, scissor.width, scissor.height); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + super.mouseClicked(absMouseX, absMouseY, relMouseX, relMouseY, mouseButton); + lastX = relMouseX; + lastY = relMouseY; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int legitRelY = relMouseY - (5+fr.FONT_HEIGHT+3); + if (new Rectangle(155,5+fr.FONT_HEIGHT + 3, hamburgerWidth, 230).contains(relMouseX, relMouseY)) { + Set rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); + rest.removeAll( feature.>getParameter("datarenderers").getValue()); + rest.remove(currentlySelected); + int culmutativeY = -scrollY; + for (String datarenderers : rest) { + IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + Dimension dim; + if (dataRenderer == null) { + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.getDimension(); + GlStateManager.popMatrix(); + } + culmutativeY += dim.height; + + if (legitRelY < culmutativeY) { + currentlySelected = datarenderers; + selectedX = 155; + selectedY = culmutativeY - dim.height + 5+fr.FONT_HEIGHT + 3; + break; + } + } + } + if (new Rectangle(5,5+fr.FONT_HEIGHT + 3, hamburgerWidth, 230).contains(relMouseX, relMouseY)) { + List rest = feature.>getParameter("datarenderers").getValue(); + int culmutativeY = 0; + for (String datarenderers : rest) { + IDataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); + Dimension dim; + if (dataRenderer == null) { + dim = new Dimension(0, fr.FONT_HEIGHT * 2); + } else { + GlStateManager.pushMatrix(); + dim = dataRenderer.getDimension(); + GlStateManager.popMatrix(); + } + culmutativeY += dim.height; + + if (legitRelY < culmutativeY) { + currentlySelected = datarenderers; + selectedX = 5; + selectedY = culmutativeY - dim.height + 5+fr.FONT_HEIGHT + 3; + rest.remove(datarenderers); + break; + } + } + } + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + super.mouseClickMove(absMouseX, absMouseY, relMouseX, relMouseY, clickedMouseButton, timeSinceLastClick); + if (currentlySelected != null) { + int dx = relMouseX - lastX; + int dy = relMouseY - lastY; + selectedX += dx; + selectedY += dy; + } + lastX = relMouseX; + lastY = relMouseY; + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + super.mouseReleased(absMouseX, absMouseY, relMouseX, relMouseY, state); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int legitRelY = selectedY - (5+fr.FONT_HEIGHT+3); + if (currentlySelected != null && new Rectangle(0,5+fr.FONT_HEIGHT + 3, hamburgerWidth+11, 232).contains(selectedX, selectedY)) { + Set rest = new HashSet<>(DataRendererRegistry.getValidDataRenderer()); + int culmutativeY = 0; + List asdasdkasd = feature.>getParameter("datarenderers").getValue(); + int index = asdasdkasd.size(); + for (int i = 0; i 0) scrollY -= 20; + if (scrollY < 0) scrollY = 0; + + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/DataRendererRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/DataRendererRegistry.java new file mode 100644 index 00000000..c0ba020a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/DataRendererRegistry.java @@ -0,0 +1,64 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonClass; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonType; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.Skill; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl.*; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class DataRendererRegistry { + private static final Map dataRendererMap = new HashMap<>(); + + public static IDataRenderer getDataRenderer(String id) { + return dataRendererMap.get(id); + } + + public static Set getValidDataRenderer() { + return dataRendererMap.keySet(); + } + + static { + dataRendererMap.put("catalv", new DataRendererDungeonLv(DungeonType.CATACOMBS)); + for (DungeonClass value : DungeonClass.values()) { + dataRendererMap.put("class_"+value.getJsonName()+"_lv", new DataRendererClassLv(value)); + } + dataRendererMap.put("selected_class_lv", new DataRendererSelectedClassLv()); + for (Skill value : Skill.values()) { + dataRendererMap.put("skill_"+value.getJsonName()+"_lv", new DataRendererSkillLv(value)); + } + for (DungeonType value : DungeonType.values()) { + for (Integer validFloor : value.getValidFloors()) { + dataRendererMap.put("dungeon_"+value.getJsonName()+"_"+validFloor+"_stat", new DataRenderDungeonFloorStat(value, validFloor)); + } + dataRendererMap.put("dungeon_"+value.getJsonName()+"_higheststat", new DataRenderDungeonHighestFloorStat(value)); + } + dataRendererMap.put("fairysouls", new DataRendererFairySouls()); + dataRendererMap.put("secrets", new DataRendererSecrets()); + + dataRendererMap.put("dummy", new DataRendererSetUrOwn()); + + dataRendererMap.put("talismans", new DataRendererTalismans()); + dataRendererMap.put("weight", new DataRendererLilyWeight()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/IDataRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/IDataRenderer.java new file mode 100644 index 00000000..577bdcb5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/IDataRenderer.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; + +import java.awt.*; + +public interface IDataRenderer { + Dimension renderData(PlayerProfile playerProfile); + void onHover(PlayerProfile playerProfile, int mouseX, int mouseY); + + + Dimension renderDummy(); + + Dimension getDimension(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonFloorStat.java new file mode 100644 index 00000000..b4b4b503 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonFloorStat.java @@ -0,0 +1,105 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonSpecificData; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonStat; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonType; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.FloorSpecificData; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.Arrays; + +public class DataRenderDungeonFloorStat implements IDataRenderer { + private final DungeonType dungeonType; + private final int floor; + public DataRenderDungeonFloorStat(DungeonType dungeonType, int floor) { + this.dungeonType = dungeonType; + this.floor = floor; + } + + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; + + boolean flag = false; + DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData != null) { + FloorSpecificData playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(floor); + if (playedFloorFloorSpecificData != null) { + flag = true; + fr.drawString("ยงb" + floorName + " ยงa" + playedFloorFloorSpecificData.getData().getBestScore() + " ยงf" + playedFloorFloorSpecificData.getData().getCompletions() + "ยง7/ยงf" + playedFloorFloorSpecificData.getData().getWatcherKills() + "ยง7/ยงf" + playedFloorFloorSpecificData.getData().getTimes_played() + " ยง7(" + (int) (playedFloorFloorSpecificData.getData().getCompletions()*100 / (double) playedFloorFloorSpecificData.getData().getWatcherKills()) + "%)", 0, 0, -1); + fr.drawString("ยง6S+ ยงe" + (playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "ยง7N/A") + " ยง6S ยงe" + (playedFloorFloorSpecificData.getData().getFastestTimeS() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "ยง7N/A"), 0, fr.FONT_HEIGHT, -1); + } + } + if (!flag) { + fr.drawString("ยงcNo Stat for "+floorName, 0,0,-1); + } + + return getDimension(); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; + + + fr.drawString("ยงb"+floorName+" ยงa305 ยงf10ยง7/ยงf35ยง7/ยงf50 ยง7("+(int)(1000.0/35.0)+"%)", 0,0,-1); + fr.drawString("ยง6S+ ยงe10m 53s ยง6S ยงe15m 13s", 0, fr.FONT_HEIGHT, -1); + return getDimension(); + } + + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + + DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData == null) return; + FloorSpecificData playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(floor); + if (playedFloorFloorSpecificData == null) return; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor; + + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GuiUtils.drawHoveringText(Arrays.asList( + "ยงbFloor "+floorName, + "ยงbBest Scoreยง7: ยงf"+playedFloorFloorSpecificData.getData().getBestScore(), + "ยงbTotal Completionsยง7: ยงf"+playedFloorFloorSpecificData.getData().getCompletions(), + "ยงbTotal Watcher killsยง7: ยงf"+playedFloorFloorSpecificData.getData().getWatcherKills(), + "ยงbTotal Runsยง7: ยงf"+playedFloorFloorSpecificData.getData().getTimes_played(), + "ยงbFastest S+ยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "ยง7N/A"), + "ยงbFastest Sยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTimeS() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "ยง7N/A"), + "ยงbFastest Runยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTime() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTime()) : "ยง7N/A"), + "ยงbMost Mobs Killedยง7: ยงf"+playedFloorFloorSpecificData.getData().getMostMobsKilled(), + "ยงbTotal Mobs Killedยง7: ยงf"+playedFloorFloorSpecificData.getData().getMobsKilled() + ), mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonHighestFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonHighestFloorStat.java new file mode 100644 index 00000000..07d27b28 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRenderDungeonHighestFloorStat.java @@ -0,0 +1,107 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonSpecificData; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonStat; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonType; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.FloorSpecificData; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.Arrays; + +public class DataRenderDungeonHighestFloorStat implements IDataRenderer { + private final DungeonType dungeonType; + public DataRenderDungeonHighestFloorStat(DungeonType dungeonType) { + this.dungeonType = dungeonType; + } + + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + boolean flag = false; + DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData != null) { + if (dungeonStatDungeonSpecificData.getData().getHighestCompleted() != -1) { + FloorSpecificData playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get(dungeonStatDungeonSpecificData.getData().getHighestCompleted()); + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + dungeonStatDungeonSpecificData.getData().getHighestCompleted(); + if (playedFloorFloorSpecificData != null) { + flag = true; + fr.drawString("ยงbH: " + floorName + " ยงa" + playedFloorFloorSpecificData.getData().getBestScore() + " ยงf" + playedFloorFloorSpecificData.getData().getCompletions() + "ยง7/ยงf" + playedFloorFloorSpecificData.getData().getWatcherKills() + "ยง7/ยงf" + playedFloorFloorSpecificData.getData().getTimes_played() + " ยง7(" + (int) (playedFloorFloorSpecificData.getData().getCompletions() *100/ (double) playedFloorFloorSpecificData.getData().getWatcherKills()) + "%)", 0, 0, -1); + fr.drawString("ยง6S+ ยงe" + (playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "ยง7N/A") + " ยง6S ยงe" + (playedFloorFloorSpecificData.getData().getFastestTimeS() != -1 ? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "ยง7N/A"), 0, fr.FONT_HEIGHT, -1); + } + } + } + if (!flag) { + fr.drawString("ยงcNo Highest Floor for ", 0,0,-1); + fr.drawString("ยงc"+dungeonType.getFamiliarName(), 0,fr.FONT_HEIGHT,-1); + } + + return getDimension(); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + "9"; + + + fr.drawString("ยงbH: "+floorName+" ยงa305 ยงf10ยง7/ยงf35ยง7/ยงf50 ยง7("+(int)(1000.0/35.0)+"%)", 0,0,-1); + fr.drawString("ยง6S+ ยงe10m 53s ยง6S ยงe15m 13s", 0, fr.FONT_HEIGHT, -1); + return getDimension(); + } + + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + + DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData == null) return; + if (dungeonStatDungeonSpecificData.getData().getHighestCompleted() == -1) return; + FloorSpecificData playedFloorFloorSpecificData = dungeonStatDungeonSpecificData.getData().getPlays().get( dungeonStatDungeonSpecificData.getData().getHighestCompleted()); + if (playedFloorFloorSpecificData == null) return; + String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + dungeonStatDungeonSpecificData.getData().getHighestCompleted(); + + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GuiUtils.drawHoveringText(Arrays.asList( + "ยงbFloor "+floorName, + "ยงbBest Scoreยง7: ยงf"+playedFloorFloorSpecificData.getData().getBestScore(), + "ยงbTotal Completionsยง7: ยงf"+playedFloorFloorSpecificData.getData().getCompletions(), + "ยงbTotal Watcher killsยง7: ยงf"+playedFloorFloorSpecificData.getData().getWatcherKills(), + "ยงbTotal Runsยง7: ยงf"+playedFloorFloorSpecificData.getData().getTimes_played(), + "ยงbFastest S+ยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTimeSPlus() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeSPlus()) : "ยง7N/A"), + "ยงbFastest Sยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTimeS() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTimeS()) : "ยง7N/A"), + "ยงbFastest Runยง7: ยงf"+(playedFloorFloorSpecificData.getData().getFastestTime() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTime()) : "ยง7N/A"), + "ยงbMost Mobs Killedยง7: ยงf"+playedFloorFloorSpecificData.getData().getMostMobsKilled(), + "ยงbTotal Mobs Killedยง7: ยงf"+playedFloorFloorSpecificData.getData().getMobsKilled() + ), mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererClassLv.java new file mode 100644 index 00000000..d0cdd716 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererClassLv.java @@ -0,0 +1,88 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.ClassSpecificData; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonClass; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import kr.syeyoung.dungeonsguide.mod.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererClassLv implements IDataRenderer { + private final DungeonClass dungeonClass; + public DataRendererClassLv(DungeonClass dungeonClass) { + this.dungeonClass = dungeonClass; + } + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ClassSpecificData dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(dungeonClass); + boolean selected = playerProfile.getSelectedClass() == dungeonClass; + if (dungeonStatDungeonSpecificData == null) { + fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); + fr.drawString("Unknown", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); + if (selected) + fr.drawString("โ˜…", fr.getStringWidth(dungeonClass.getFamilarName()+" Unknown "),0,0xFFAAAAAA); + } else { + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); + fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); + if (selected) + fr.drawString("โ˜…", fr.getStringWidth(dungeonClass.getFamilarName()+" "+xpCalcResult.getLevel()+" "),0,0xFFAAAAAA); + + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp())); + } + + return new Dimension(100, fr.FONT_HEIGHT*2); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString(dungeonClass.getFamilarName(), 0,0, 0xFF55ffff); + fr.drawString("99", fr.getStringWidth(dungeonClass.getFamilarName()+" "),0,0xFFFFFFFF); + fr.drawString("โ˜…", fr.getStringWidth(dungeonClass.getFamilarName()+" 99 "),0,0xFFAAAAAA); + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); + return new Dimension(100, fr.FONT_HEIGHT*2); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + ClassSpecificData dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(dungeonClass); + if (dungeonStatDungeonSpecificData == null) return; + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + + GuiUtils.drawHoveringText(Arrays.asList("ยงbCurrent Lvยง7: ยงe"+xpCalcResult.getLevel(),"ยงbExpยง7: ยงe"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "ยง7/ยงe"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "ยงbTotal Xpยง7: ยงe"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, + scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererDungeonLv.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererDungeonLv.java new file mode 100644 index 00000000..5498a4b3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererDungeonLv.java @@ -0,0 +1,82 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonSpecificData; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonStat; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.DungeonType; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import kr.syeyoung.dungeonsguide.mod.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererDungeonLv implements IDataRenderer { + private final DungeonType dungeonType; + public DataRendererDungeonLv(DungeonType dungeonType) { + this.dungeonType = dungeonType; + } + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData == null) { + fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); + fr.drawString("Unknown", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); + } else { + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); + fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); + + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp())); + } + + return new Dimension(100, fr.FONT_HEIGHT*2); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString(dungeonType.getFamiliarName(), 0,0, 0xFFFF5555); + fr.drawString("99", fr.getStringWidth(dungeonType.getFamiliarName()+" "),0,0xFFFFFFFF); + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); + return new Dimension(100, fr.FONT_HEIGHT*2); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + DungeonSpecificData dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType); + if (dungeonStatDungeonSpecificData == null) return; + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GuiUtils.drawHoveringText(Arrays.asList("ยงbCurrent Lvยง7: ยงe"+xpCalcResult.getLevel(),"ยงbExpยง7: ยงe"+TextUtils.format((long)xpCalcResult.getRemainingXp()) + "ยง7/ยงe"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "ยงbTotal Xpยง7: ยงe"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, + scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererFairySouls.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererFairySouls.java new file mode 100644 index 00000000..1f0c295f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererFairySouls.java @@ -0,0 +1,50 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; + +public class DataRendererFairySouls implements IDataRenderer { + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("ยงeFairy Souls ยงf"+playerProfile.getFairySouls(), 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("ยงeFairy Souls ยงf300", 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererLilyWeight.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererLilyWeight.java new file mode 100644 index 00000000..2ecdc8af --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererLilyWeight.java @@ -0,0 +1,71 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererLilyWeight implements IDataRenderer { + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + if (playerProfile.getLilyWeight() == null) + fr.drawString("ยงeLily Weight ยงcAPI DISABLED", 0,0,-1); + else + fr.drawString("ยงeLily Weight ยงb"+String.format("%.3f", playerProfile.getLilyWeight().getTotal()), 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("ยงeLily Weight ยงb300", 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + PlayerProfile.LilyWeight lilyWeight= playerProfile.getLilyWeight(); + if (lilyWeight == null) return; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GuiUtils.drawHoveringText(Arrays.asList( + "ยงbDungeon Weightsยง7: ยงe"+ String.format("%.3f",lilyWeight.getCatacombs_base()+lilyWeight.getCatacombs_master()+lilyWeight.getCatacombs_exp()), + " ยงbCatacomb Completionยง7: ยงe"+String.format("%.3f",lilyWeight.getCatacombs_base()), + " ยงbMaster Completionยง7: ยงe"+String.format("%.3f", lilyWeight.getCatacombs_master()), + " ยงbExperienceยง7: ยงe"+String.format("%.3f", lilyWeight.getCatacombs_exp()), + "ยงbSkill Weightsยง7: ยงe"+ String.format("%.3f", lilyWeight.getSkill_base() + lilyWeight.getSkill_overflow()), + " ยงbSkill Weightยง7: ยงe"+String.format("%.3f", lilyWeight.getSkill_base()), + " ยงbOverflow Weightยง7: ยงe"+String.format("%.3f", lilyWeight.getSkill_overflow()), + "ยงbSlayer Weightยง7: ยงe"+String.format("%.3f", lilyWeight.getSlayer()), + "ยงbTotalยง7: ยงe"+String.format("%.3f", lilyWeight.getTotal()) + ),mouseX, mouseY, + scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSecrets.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSecrets.java new file mode 100644 index 00000000..8a4904a7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSecrets.java @@ -0,0 +1,53 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; + +public class DataRendererSecrets implements IDataRenderer { + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + double theint = playerProfile.getTotalSecrets()/ (double)playerProfile.getDungeonStats().values().stream().flatMap(s -> s.getData().getPlays().values().stream()) + .map(fs -> fs.getData().getWatcherKills()).reduce(0, Integer::sum); + fr.drawString("ยงeSecrets ยงb"+playerProfile.getTotalSecrets()+" ยง7("+ + String.format("%.2f", theint)+"/run)", 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("ยงeSecrets ยงb99999 ยง7(X/run)", 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSelectedClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSelectedClassLv.java new file mode 100644 index 00000000..832d9a40 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSelectedClassLv.java @@ -0,0 +1,77 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.ClassSpecificData; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import kr.syeyoung.dungeonsguide.mod.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererSelectedClassLv implements IDataRenderer { + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + ClassSpecificData dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(playerProfile.getSelectedClass()); + if (dungeonStatDungeonSpecificData == null) { + fr.drawString("Unknown Selected", 0,0, 0xFF55ffff); + } else { + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + fr.drawString(playerProfile.getSelectedClass().getFamilarName(), 0,0, 0xFF55ffff); + fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(playerProfile.getSelectedClass().getFamilarName()+" "),0,0xFFFFFFFF); + fr.drawString("โ˜…", fr.getStringWidth(playerProfile.getSelectedClass().getFamilarName()+" "+xpCalcResult.getLevel()+" "),0,0xFFAAAAAA); + + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp())); + } + + return new Dimension(100, fr.FONT_HEIGHT*2); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("SelectedClass", 0,0, 0xFF55ffff); + fr.drawString("99", fr.getStringWidth("SelectedClass "),0,0xFFFFFFFF); + fr.drawString("โ˜…", fr.getStringWidth("SelectedClass 99 "),0,0xFFAAAAAA); + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); + return new Dimension(100, fr.FONT_HEIGHT*2); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + ClassSpecificData dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(playerProfile.getSelectedClass()); + if (dungeonStatDungeonSpecificData == null) return; + XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience()); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GuiUtils.drawHoveringText(Arrays.asList("ยงbCurrent Lvยง7: ยงe"+xpCalcResult.getLevel(),"ยงbExpยง7: ยงe"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "ยง7/ยงe"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "ยงbTotal Xpยง7: ยงe"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, + scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSetUrOwn.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSetUrOwn.java new file mode 100644 index 00000000..edff1bc4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSetUrOwn.java @@ -0,0 +1,57 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +import java.awt.*; + +public class DataRendererSetUrOwn implements IDataRenderer { + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("ยงaCustomize at /dg", 0,0,-1); + fr.drawString("ยงa-> Party Kicker", 0,fr.FONT_HEIGHT,-1); + fr.drawString("ยงa-> View Player Stats", 0,fr.FONT_HEIGHT*2,-1); + fr.drawString("ยงa-> Edit", 0,fr.FONT_HEIGHT*3,-1); + return new Dimension(100, fr.FONT_HEIGHT*4); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("ยงaCustomize at /dg", 0,0,-1); + fr.drawString("ยงa-> Party Kicker", 0,fr.FONT_HEIGHT,-1); + fr.drawString("ยงa-> View Player Stats", 0,fr.FONT_HEIGHT*2,-1); + fr.drawString("ยงa-> Edit", 0,fr.FONT_HEIGHT*3,-1); + return new Dimension(100, fr.FONT_HEIGHT*4); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*4); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSkillLv.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSkillLv.java new file mode 100644 index 00000000..99787d7c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererSkillLv.java @@ -0,0 +1,80 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.Skill; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import kr.syeyoung.dungeonsguide.mod.utils.XPUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.Arrays; + +public class DataRendererSkillLv implements IDataRenderer { + private final Skill skill; + public DataRendererSkillLv(Skill skill) { + this.skill = skill; + } + @Override + public Dimension renderData(PlayerProfile playerProfile) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + Double xp = playerProfile.getSkillXp().get(skill); + if (xp == null) { + fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); + fr.drawString("ยงcSkill API Disabled", 0, fr.FONT_HEIGHT,0xFFFFFFFF); + } else { + XPUtils.XPCalcResult xpCalcResult = XPUtils.getSkillXp(skill, xp); + fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); + fr.drawString(xpCalcResult.getLevel()+"", fr.getStringWidth(skill.getFriendlyName()+" "),0,0xFFFFFFFF); + + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,xpCalcResult.getRemainingXp() == 0 ? 1 : (float) (xpCalcResult.getRemainingXp() / xpCalcResult.getNextLvXp())); + } + + return new Dimension(100, fr.FONT_HEIGHT*2); + } + + @Override + public Dimension renderDummy() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString(skill.getFriendlyName(), 0,0, 0xFF55ffff); + fr.drawString("99", fr.getStringWidth(skill.getFriendlyName()+" "),0,0xFFFFFFFF); + RenderUtils.renderBar(0, fr.FONT_HEIGHT, 100,1.0f); + return new Dimension(100, fr.FONT_HEIGHT*2); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT*2); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + Double xp = playerProfile.getSkillXp().get(skill); + if (xp == null) return; + XPUtils.XPCalcResult xpCalcResult = XPUtils.getSkillXp(skill, xp); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GuiUtils.drawHoveringText(Arrays.asList("ยงbCurrent Lvยง7: ยงe"+xpCalcResult.getLevel(),"ยงbExpยง7: ยงe"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "ยง7/ยงe"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "ยงbTotal Xpยง7: ยงe"+ TextUtils.format(xp.longValue())),mouseX, mouseY, + scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererTalismans.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererTalismans.java new file mode 100644 index 00000000..e5db0bda --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/datarenders/impl/DataRendererTalismans.java @@ -0,0 +1,123 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.impl; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer; +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class DataRendererTalismans implements IDataRenderer { + @Override + public Dimension renderData(PlayerProfile playerProfile) { + boolean apiDisabled = playerProfile.getTalismans() == null || playerProfile.getInventory() == null; + if (!playerProfile.getAdditionalProperties().containsKey("talismanCnt") && !apiDisabled) { + int[] cnts = new int[Rarity.values().length]; + for (ItemStack talisman : playerProfile.getTalismans()) { + if (talisman == null) continue; + Rarity r = getRarity(talisman); + if (r != null) cnts[r.ordinal()]++; + } + for (ItemStack itemStack : playerProfile.getInventory()) { + if (itemStack == null) continue; + Rarity r = getRarity(itemStack); + if (r != null) cnts[r.ordinal()]++; + } + playerProfile.getAdditionalProperties().put("talismanCnt", cnts); + } + int[] rawData = (int[]) playerProfile.getAdditionalProperties().get("talismanCnt"); + + String str = ""; + if (rawData != null) + for (Rarity r : Rarity.values()) { + str = r.color+rawData[r.idx] +" "+ str; + } + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + if (apiDisabled) + fr.drawString("ยงeTalis ยงcAPI DISABLED", 0,0,-1); + else + fr.drawString("ยงeTalis ยงf"+str, 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + + private Rarity getRarity(ItemStack itemStack) { + NBTTagCompound display = itemStack.getTagCompound().getCompoundTag("display"); + if (display == null) return null; + NBTTagList lore = display.getTagList("Lore", 8); + if (lore == null) return null; + for (int i = 0; i < lore.tagCount(); i++) { + String line = lore.getStringTagAt(i); + for (Rarity value : Rarity.values()) { + if (line.startsWith(value.getColor()) && line.contains("CCESSORY")) return value; + } + } + return null; + } + + @Override + public Dimension renderDummy() { + String str = ""; + for (Rarity r : Rarity.values()) { + str = r.color+(r.idx+5)*2+" "+str; + } + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("ยงeTalis ยงf"+str, 0,0,-1); + return new Dimension(100, fr.FONT_HEIGHT); + } + @Override + public Dimension getDimension() { + return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); + } + + @Override + public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { + int[] rawData = (int[]) playerProfile.getAdditionalProperties().get("talismanCnt"); + if (rawData == null) return; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + List list = new ArrayList<>(); + + for (Rarity r : Rarity.values()) { + list.add(r.getColor()+r.name()+"ยง7: ยงe"+rawData[r.idx]); + } + GuiUtils.drawHoveringText(list,mouseX, mouseY, + scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj); + } + + + @AllArgsConstructor @Getter + public static enum Rarity { + COMMON("ยงf", 0), UNCOMMON("ยงa",1), RARE("ยง9",2), EPIC("ยง5",3), LEGENDARY("ยง6",4), MYTHIC("ยงd",5); + + private String color; + private int idx; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureActions.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureActions.java new file mode 100644 index 00000000..bb755bc1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureActions.java @@ -0,0 +1,143 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.AbstractAction; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRoute; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.features.text.StyledText; +import kr.syeyoung.dungeonsguide.mod.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.mod.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureActions extends TextHUDFeature { + public FeatureActions() { + super("Dungeon.Secrets", "Action Viewer", "View List of actions that needs to be taken", "secret.actionview", false, 200, getFontRenderer().FONT_HEIGHT * 10); + + getStyles().add(new TextStyle("pathfinding", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("mechanic", new AColor(0x55, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("separator", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("state", new AColor(0x55, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("current", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("number", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("dot", new AColor(0x55, 0x55,0x55,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("action", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("afterline", new AColor(0xAA, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + } + + + @Override + public boolean doesScaleWithHeight() { + return false; + } + + @Override + public boolean isHUDViewable() { + if (!SkyblockStatus.isOnDungeon()) return false; + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() == null || !DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getMapProcessor().isInitialized()) return false; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom == null) return false; + return dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor; + } + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("Pathfinding ","pathfinding")); + dummyText.add(new StyledText("Secret ","mechanic")); + dummyText.add(new StyledText("-> ","separator")); + dummyText.add(new StyledText("Found\n","state")); + dummyText.add(new StyledText("> ","current")); + dummyText.add(new StyledText("1","number")); + dummyText.add(new StyledText(". ","dot")); + dummyText.add(new StyledText("Move ","action")); + dummyText.add(new StyledText("OffsetPoint{x=1,y=42,z=1} \n","afterline")); + dummyText.add(new StyledText(" ","current")); + dummyText.add(new StyledText("2","number")); + dummyText.add(new StyledText(". ","dot")); + dummyText.add(new StyledText("Click ","action")); + dummyText.add(new StyledText("OffsetPoint{x=1,y=42,z=1} \n","afterline")); + dummyText.add(new StyledText(" ","current")); + dummyText.add(new StyledText("3","number")); + dummyText.add(new StyledText(". ","dot")); + dummyText.add(new StyledText("Profit ","action")); + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("pathfinding","mechanic","separator","state","current", "number", "dot", "action", "afterline"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + + @Override + public List getText() { + List actualBit = new ArrayList(); + + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + + for (ActionRoute path : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getPath().values()) { + actualBit.add(new StyledText("Pathfinding ","pathfinding")); + actualBit.add(new StyledText(path.getMechanic()+" ","mechanic")); + actualBit.add(new StyledText("-> ","separator")); + actualBit.add(new StyledText(path.getState()+"\n","state")); + + for (int i = Math.max(0,path.getCurrent()-2); i < path.getActions().size(); i++) { + actualBit.add(new StyledText((i == path.getCurrent() ? ">" : " ") +" ","current")); + actualBit.add(new StyledText(i+"","number")); + actualBit.add(new StyledText(". ","dot")); + AbstractAction action = path.getActions().get(i); + String[] str = action.toString().split("\n"); + actualBit.add(new StyledText(str[0] + " ","action")); + actualBit.add(new StyledText("(","afterline")); + for (int i1 = 1; i1 < str.length; i1++) { + String base = str[i1].trim(); + if (base.startsWith("-")) + base = base.substring(1); + base = base.trim(); + actualBit.add(new StyledText(base+" ","afterline")); + } + actualBit.add(new StyledText(")\n","afterline")); + } + } + return actualBit; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureBloodRush.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureBloodRush.java new file mode 100644 index 00000000..e4bfc7b1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureBloodRush.java @@ -0,0 +1,45 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.KeybindPressedListener; +import net.minecraft.util.ChatComponentText; +import org.lwjgl.input.Keyboard; + +public class FeatureBloodRush extends SimpleFeature implements KeybindPressedListener { + public FeatureBloodRush() { + super("Dungeon.Secrets.Blood Rush", "Blood Rush Mode", "Auto pathfind to witherdoors. \nCan be toggled with key set in settings", "secret.bloodrush", false); + addParameter("key", new FeatureParameter("key", "Key", "Press to toggle Blood Rush", Keyboard.KEY_NONE, "keybind")); + } + + @Override + public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { + if (keyBindPressedEvent.getKey() == this.getParameter("key").getValue()) { + setEnabled(!isEnabled()); + try { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfToggled Blood Rush to ยงe"+(FeatureRegistry.SECRET_BLOOD_RUSH.isEnabled() ? "on":"off"))); + } catch (Exception ignored) {} + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureCreateRefreshLine.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureCreateRefreshLine.java new file mode 100644 index 00000000..7c7cd31a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureCreateRefreshLine.java @@ -0,0 +1,69 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import org.lwjgl.input.Keyboard; + +import java.util.LinkedHashMap; + +public class FeatureCreateRefreshLine extends SimpleFeature { + public FeatureCreateRefreshLine() { + super("Dungeon.Secrets.Keybinds", "Refresh pathfind line or Trigger pathfind", "A keybind for creating or refresh pathfind lines for pathfind contexts that doesn't have line, or contexts that has refresh rate set to -1.\nPress settings to edit the key", "secret.refreshPathfind", true); + this.parameters = new LinkedHashMap<>(); + addParameter("key", new FeatureParameter("key", "Key","Press to refresh or create pathfind line", Keyboard.KEY_NONE, "keybind")); + addParameter("pathfind", new FeatureParameter("pathfind", "Enable Pathfinding", "Force Enable pathfind for future actions when used", false, "boolean")); + addParameter("refreshrate", new FeatureParameter("refreshrate", "Line Refreshrate", "Ticks to wait per line refresh, to be overriden. If the line already has pathfind enabled, this value does nothing. Specify it to -1 to don't refresh line at all", 10, "integer")); + } + public int getKeybind() {return this.getParameter("key").getValue();} + public boolean isPathfind() { + return this.getParameter("pathfind").getValue(); + } + public int getRefreshRate() { + return this.getParameter("refreshrate").getValue(); + } + + + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { + @Override + public MPanel get() { + MFeatureEdit featureEdit = new MFeatureEdit(FeatureCreateRefreshLine.this, rootConfigPanel); + for (FeatureParameter parameter: getParameters()) { + if (parameter.getKey().equals("refreshrate")) + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureCreateRefreshLine.this, parameter, rootConfigPanel, a -> !isPathfind())); + else + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureCreateRefreshLine.this, parameter, rootConfigPanel, a -> false)); + } + return featureEdit; + } + }); + return "base." + getKey() ; + } + + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureFreezePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureFreezePathfind.java new file mode 100644 index 00000000..16dc46d2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureFreezePathfind.java @@ -0,0 +1,45 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.KeybindPressedListener; +import net.minecraft.util.ChatComponentText; +import org.lwjgl.input.Keyboard; + +public class FeatureFreezePathfind extends SimpleFeature implements KeybindPressedListener { + public FeatureFreezePathfind() { + super("Dungeon.Secrets.Keybinds", "Global Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move.\nPress settings to edit the key", "secret.freezepathfind", false); + addParameter("key", new FeatureParameter("key", "Key", "Press to toggle freeze pathfind", Keyboard.KEY_NONE, "keybind")); + } + + @Override + public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { + if (keyBindPressedEvent.getKey() == this.getParameter("key").getValue()) { + setEnabled(!isEnabled()); + try { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfToggled Pathfind Freeze to ยงe"+(FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() ? "on":"off"))); + } catch (Exception ignored) {} + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeaturePathfindStrategy.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeaturePathfindStrategy.java new file mode 100644 index 00000000..49dd6d58 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeaturePathfindStrategy.java @@ -0,0 +1,106 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import com.google.common.base.Supplier; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MStringSelectionButton; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.awt.*; +import java.util.Arrays; +import java.util.stream.Collectors; + +public class FeaturePathfindStrategy extends SimpleFeature { + public FeaturePathfindStrategy() { + super("Dungeon.Secrets.Preferences", "Pathfind Algorithm", "Select pathfind algorithm used by paths", "secret.secretpathfind.algorithm", true); + addParameter("strategy", new FeatureParameter("strategy", "Pathfind Strategy", "Pathfind Strategy", "THETA_STAR", "string")); + + } + + @Override + public boolean isDisyllable() { + return false; + } + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { + @Override + public MPanel get() { + + MFeatureEdit featureEdit = new MFeatureEdit(FeaturePathfindStrategy.this, rootConfigPanel); + PathfindStrategy alignment = getPathfindStrat(); + MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.stream(PathfindStrategy.values()).map(Enum::name).collect(Collectors.toList()), alignment.name()) { + @Override + public Dimension getPreferredSize() { + return new Dimension(150, 20); + } + }; + mStringSelectionButton.setOnUpdate(() -> { + FeaturePathfindStrategy.this.getParameter("strategy").setValue(mStringSelectionButton.getSelected()); + FeaturePathfindStrategy.this.getParameter("strategy").setDescription(getPathfindStrat().getDescription()); + featureEdit.removeParameterEdit(null); + }); + featureEdit.addParameterEdit("strategy", new MParameterEdit(FeaturePathfindStrategy.this, FeaturePathfindStrategy.this.getParameter("strategy"), rootConfigPanel, mStringSelectionButton, (a) -> false)); + + for (FeatureParameter parameter: getParameters()) { + if (parameter.getKey().equals("strategy")) continue; + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeaturePathfindStrategy.this, parameter, rootConfigPanel)); + } + return featureEdit; + } + }); + return "base." + getKey() ; + } + + @Getter @RequiredArgsConstructor + public enum PathfindStrategy { + THETA_STAR("The default pathfinding algorithm. It will generate sub-optimal path quickly."), + A_STAR_DIAGONAL("New pathfinding algorithm. It will generate path that looks like the one JPS generates"), + A_STAR_FINE_GRID("New pathfinding algorithm. It will generate path that kind of looks like stair"), + JPS_LEGACY("The improved pathfinding algorithm. Not suggested for usage. It will have problems on diagonal movements, thus giving wrong routes"), + A_STAR_LEGACY("The first pathfinding algorithm. It may have problem on navigating through stairs. This is the one used by Minecraft for mob pathfind."); + + private final String description; + } + + @Override + public void loadConfig(JsonObject jsonObject) { + super.loadConfig(jsonObject); + FeaturePathfindStrategy.PathfindStrategy alignment; + try { + alignment = PathfindStrategy.valueOf(FeaturePathfindStrategy.this.getParameter("strategy").getValue()); + } catch (Exception e) {alignment = PathfindStrategy.THETA_STAR;} + FeaturePathfindStrategy.this.getParameter("strategy").setValue(alignment.name()); + FeaturePathfindStrategy.this.getParameter("strategy").setDescription(alignment.getDescription()); + } + + public PathfindStrategy getPathfindStrat() { + return PathfindStrategy.valueOf(FeaturePathfindStrategy.this.getParameter("strategy").getValue()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeaturePathfindToAll.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeaturePathfindToAll.java new file mode 100644 index 00000000..9435968f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeaturePathfindToAll.java @@ -0,0 +1,45 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeaturePathfindToAll extends SimpleFeature { + public FeaturePathfindToAll(){ + super("Dungeon.Secrets.Pathfind To All", "Start pathfind to all secrets upon entering a room", "Auto browse to all secrets in the room", "secret.secretpathfind.allbrowse", false); + addParameter("bat", new FeatureParameter("bat", "Trigger pathfind to Bat", "This feature will trigger pathfind to all bats in this room when entering a room", true, "boolean")); + addParameter("chest", new FeatureParameter("chest", "Trigger pathfind to Chest", "This feature will trigger pathfind to all chests in this room when entering a room", true, "boolean")); + addParameter("essence", new FeatureParameter("essence", "Trigger pathfind to Essence", "This feature will trigger pathfind to all essences in this room when entering a room", true, "boolean")); + addParameter("itemdrop", new FeatureParameter("itemdrop", "Trigger pathfind to Itemdrop", "This feature will trigger pathfind to all itemdrops in this room when entering a room", true, "boolean")); + } + + public boolean isBat() { + return this.getParameter("bat").getValue(); + } + public boolean isChest() { + return this.getParameter("chest").getValue(); + } + public boolean isEssence() { + return this.getParameter("essence").getValue(); + } + public boolean isItemdrop() { + return this.getParameter("itemdrop").getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureSoulRoomWarning.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureSoulRoomWarning.java new file mode 100644 index 00000000..7394e73d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureSoulRoomWarning.java @@ -0,0 +1,232 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoomInfoRegistry; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.listener.TickListener; +import kr.syeyoung.dungeonsguide.mod.features.text.*; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MPassiveLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MStringSelectionButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MToggleButton; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; +import java.util.List; +import java.util.function.Predicate; + +public class FeatureSoulRoomWarning extends TextHUDFeature implements TickListener { + + public FeatureSoulRoomWarning() { + super("Dungeon.HUDs","Secret Soul Alert", "Alert if there is an fairy soul in the room", "secret.fairysoulwarn", true, getFontRenderer().getStringWidth("There is a fairy soul in this room!"), getFontRenderer().FONT_HEIGHT); + getStyles().add(new TextStyle("warning", new AColor(0xFF, 0x69,0x17,255), new AColor(0, 0,0,0), false)); + + addParameter("roomuids", new FeatureParameter("roomuids", "Disabled room Names", "Disable for these rooms", new ArrayList<>(), "stringlist")); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + @Override + public boolean isHUDViewable() { + return warning > System.currentTimeMillis(); + } + + @Override + public List getUsedTextStyle() { + return Collections.singletonList("warning"); + } + + private UUID lastRoomUID = UUID.randomUUID(); + private long warning = 0; + + private static final List text = new ArrayList(); + static { + text.add(new StyledText("There is a fairy soul in this room!", "warning")); + } + + @Override + public List getText() { + return text; + } + + + @Override + public void onTick() { + if (!skyblockStatus.isOnDungeon()) return; + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() == null || !DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getMapProcessor().isInitialized()) return; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + if (thePlayer == null) return; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom == null) return; + if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + + if (!dungeonRoom.getDungeonRoomInfo().getUuid().equals(lastRoomUID)) { + for (DungeonMechanic value : dungeonRoom.getMechanics().values()) { + if (value instanceof DungeonFairySoul) + warning = System.currentTimeMillis() + 2500; + } + lastRoomUID = dungeonRoom.getDungeonRoomInfo().getUuid(); + } + } + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { + @Override + public MPanel get() { + + MFeatureEdit featureEdit = new MFeatureEdit(FeatureSoulRoomWarning.this, rootConfigPanel); + featureEdit.addParameterEdit("textStyleNEW", new PanelTextParameterConfig(FeatureSoulRoomWarning.this)); + + StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(FeatureSoulRoomWarning.this.getParameter("alignment").getValue()); + MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name()); + mStringSelectionButton.setOnUpdate(() -> { + FeatureSoulRoomWarning.this.getParameter("alignment").setValue(mStringSelectionButton.getSelected()); + }); + featureEdit.addParameterEdit("alignment", new MParameterEdit(FeatureSoulRoomWarning.this, FeatureSoulRoomWarning.this.getParameter("alignment"), rootConfigPanel, mStringSelectionButton, (a) -> false)); + + for (FeatureParameter parameter: getParameters()) { + if (parameter.getKey().equals("textStylesNEW")) continue; + if (parameter.getKey().equals("alignment")) continue; + if (parameter.getKey().equals("roomuids")) continue; + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(FeatureSoulRoomWarning.this, parameter, rootConfigPanel)); + } + featureEdit.addParameterEdit("roomuids", new RoomSelectionPanel(FeatureSoulRoomWarning.this.>getParameter("roomuids"), (a) -> { + for (DungeonMechanic value : a.getMechanics().values()) { + if (value instanceof DungeonFairySoul) return true; + } + return false; + }) ); + return featureEdit; + } + }); + return "base." + getKey() ; + } + + public static class RoomSelectionPanel extends MPanel { + FeatureParameter> uids; + private List passiveLabelAndElements = new ArrayList<>(); + private List toggleButtons = new ArrayList<>(); + private MButton addAll, removeAll; + public RoomSelectionPanel(FeatureParameter> roomuids, Predicate selectableRooms) { + this.uids = roomuids; + for (DungeonRoomInfo dungeonRoomInfo : DungeonRoomInfoRegistry.getRegistered()) { + if (!selectableRooms.test(dungeonRoomInfo)) continue; + MToggleButton mToggleButton = new MToggleButton(); + mToggleButton.setEnabled(!roomuids.getValue().contains(dungeonRoomInfo.getUuid().toString())); + mToggleButton.setOnToggle(() -> { + if (mToggleButton.isEnabled()) + roomuids.getValue().remove(dungeonRoomInfo.getUuid().toString()); + else + roomuids.getValue().add(dungeonRoomInfo.getUuid().toString()); + }); + toggleButtons.add(mToggleButton); + MPassiveLabelAndElement passiveLabelAndElement = new MPassiveLabelAndElement(dungeonRoomInfo.getName(), mToggleButton); + passiveLabelAndElement.setDivideRatio(0.7); + passiveLabelAndElements.add(passiveLabelAndElement); + } + for (MPassiveLabelAndElement passiveLabelAndElement : passiveLabelAndElements) { + add(passiveLabelAndElement); + } + { + addAll = new MButton(); addAll.setText("Enable All"); + addAll.setOnActionPerformed(() -> { + roomuids.getValue().clear(); + for (MToggleButton toggleButton : toggleButtons) { + toggleButton.setEnabled(true); + } + }); + removeAll = new MButton(); removeAll.setText("Disable All"); + removeAll.setOnActionPerformed(() -> { + for (MToggleButton toggleButton : toggleButtons) { + toggleButton.setEnabled(false); + toggleButton.getOnToggle().run(); + } + }); + add(addAll); add(removeAll); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(-1, (int) (20 * Math.ceil(passiveLabelAndElements.size() / 3) + 27)); + } + + @Override + public void onBoundsUpdate() { + int xI = 0; + int y = 22; + int w3 = (getBounds().width-20) / 3; + for (MPassiveLabelAndElement passiveLabelAndElement : passiveLabelAndElements) { + passiveLabelAndElement.setBounds(new Rectangle(5 + xI * (w3+5), y, w3, 20)); + xI ++; + if (xI == 3) { + xI = 0; + y += 20; + } + } + + addAll.setBounds(new Rectangle(getBounds().width-150, 2, 70, 14)); + removeAll.setBounds(new Rectangle(getBounds().width-75, 2, 70, 14)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Gui.drawRect(0,0,getBounds().width, getBounds().height,RenderUtils.blendAlpha(0x141414, 0.12f)); + Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f)); + Gui.drawRect(1,1,getBounds().width-1, 18, RenderUtils.blendAlpha(0x141414, 0.12f)); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.pushMatrix(); + GlStateManager.translate(5,5,0); + GlStateManager.scale(1.0,1.0,0); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Enable for these rooms", 0,0, 0xFFFFFFFF); + GlStateManager.popMatrix(); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureTogglePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureTogglePathfind.java new file mode 100644 index 00000000..e55d7e00 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/FeatureTogglePathfind.java @@ -0,0 +1,45 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.KeybindPressedListener; +import net.minecraft.util.ChatComponentText; +import org.lwjgl.input.Keyboard; + +public class FeatureTogglePathfind extends SimpleFeature implements KeybindPressedListener { + public FeatureTogglePathfind() { + super("Dungeon.Secrets.Keybinds", "Toggle Pathfind Lines", "A key for toggling pathfound line visibility.\nPress settings to edit the key", "secret.togglePathfind"); + addParameter("key", new FeatureParameter("key", "Key", "Press to toggle pathfind lines", Keyboard.KEY_NONE, "keybind")); + } + public boolean togglePathfindStatus = false; + + @Override + public void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent) { + if (keyBindPressedEvent.getKey() == this.getParameter("key").getValue() && isEnabled()) { + togglePathfindStatus = !togglePathfindStatus; + try { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfToggled Pathfind Line visibility to ยงe"+(togglePathfindStatus ? "on":"off"))); + } catch (Exception ignored) {} + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/PathfindLineProperties.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/PathfindLineProperties.java new file mode 100644 index 00000000..f5137394 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/PathfindLineProperties.java @@ -0,0 +1,115 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRouteProperties; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; + +import java.util.LinkedHashMap; + +public class PathfindLineProperties extends SimpleFeature { + private PathfindLineProperties parent; + public PathfindLineProperties(String category, String name, String description, String key, boolean useParent, PathfindLineProperties parent) { + super(category, name, description, key); + this.parent = parent; + this.parameters = new LinkedHashMap<>(); + if (parent != null) + addParameter("useGlobal", new FeatureParameter("useGlobal", "Use Global Settings instead of this", "Completely ignore these settings, then use the parent one:: '"+parent.getName()+"'", useParent, "boolean")); + addParameter("pathfind", new FeatureParameter("pathfind", "Enable Pathfinding", "Enable pathfind for secrets", useParent, "boolean")); + addParameter("lineColor", new FeatureParameter("lineColor", "Line Color", "Color of the pathfind line", new AColor(0xFFFF0000, true), "acolor")); + addParameter("lineWidth", new FeatureParameter("lineWidth", "Line Thickness", "Thickness of the pathfind line",1.0f, "float")); + addParameter("linerefreshrate", new FeatureParameter("linerefreshrate", "Line Refreshrate", "Ticks to wait per line refresh. Specify it to -1 to don't refresh line at all", 10, "integer")); + addParameter("beacon", new FeatureParameter("beacon", "Enable Beacons", "Enable beacons for pathfind line targets", true, "boolean")); + addParameter("beamColor", new FeatureParameter("beamColor", "Beam Color", "Color of the beacon beam", new AColor(0x77FF0000, true), "acolor")); + addParameter("beamTargetColor", new FeatureParameter("beamTargetColor", "Target Color", "Color of the target", new AColor(0x33FF0000, true), "acolor")); + } + + + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { + @Override + public MPanel get() { + MFeatureEdit featureEdit = new MFeatureEdit(PathfindLineProperties.this, rootConfigPanel); + for (FeatureParameter parameter: getParameters()) { + if (parameter.getKey().startsWith("line")) + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> isGlobal() || !isPathfind())); + else if (parameter.getKey().startsWith("beam")) + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> isGlobal() || !isBeacon())); + else if (!parameter.getKey().equals("useGlobal")) + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> isGlobal())); + else + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> false)); + } + return featureEdit; + } + }); + return "base." + getKey() ; + } + + @Override + public boolean isDisyllable() { + return false; + } + + public boolean isGlobal() { + if (parent == null) return false; + return this.getParameter("useGlobal").getValue(); + } + + public boolean isPathfind() { + return isGlobal() ? parent.isPathfind() : this.getParameter("pathfind").getValue(); + } + public AColor getLineColor() { + return isGlobal() ? parent.getLineColor() : this.getParameter("lineColor").getValue(); + } + public float getLineWidth() { + return isGlobal() ? parent.getLineWidth() : this.getParameter("lineWidth").getValue(); + } + public int getRefreshRate() { + return isGlobal() ? parent.getRefreshRate() : this.getParameter("linerefreshrate").getValue(); + } + public boolean isBeacon() { + return isGlobal() ? parent.isBeacon() : this.getParameter("beacon").getValue(); + } + public AColor getBeamColor() { + return isGlobal() ? parent.getBeamColor() : this.getParameter("beamColor").getValue(); + } + public AColor getTargetColor() { + return isGlobal() ? parent.getTargetColor() : this.getParameter("beamTargetColor").getValue(); + } + public ActionRouteProperties getRouteProperties() { + ActionRouteProperties actionRouteProperties = new ActionRouteProperties(); + actionRouteProperties.setPathfind(isPathfind()); + actionRouteProperties.setLineColor(getLineColor()); + actionRouteProperties.setLineWidth(getLineWidth()); + actionRouteProperties.setLineRefreshRate(getRefreshRate()); + actionRouteProperties.setBeacon(isBeacon()); + actionRouteProperties.setBeaconBeamColor(getBeamColor()); + actionRouteProperties.setBeaconColor(getTargetColor()); + return actionRouteProperties; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java new file mode 100644 index 00000000..76f64d08 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java @@ -0,0 +1,164 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.SkyblockStatus; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.mod.config.types.GUIRectangle; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.features.listener.GuiClickListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.GuiPreRenderListener; +import kr.syeyoung.dungeonsguide.mod.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MFloatSelectionButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MPassiveLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.*; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.MathHelper; +import net.minecraftforge.client.event.GuiScreenEvent; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.io.IOException; +import java.util.*; +import java.util.List; + +public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderListener, GuiClickListener, WorldRenderListener { + public FeatureMechanicBrowse() { + super("Dungeon.Secrets.Secret Browser","Secret Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300); + addParameter("scale", new FeatureParameter("scale", "Scale", "Scale", 1.0f, "float")); + mGuiMechanicBrowser = new MGuiMechanicBrowser(this); + mGuiMechanicBrowser.setWorldAndResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); + lastWidth = Minecraft.getMinecraft().displayWidth; lastHeight = Minecraft.getMinecraft().displayHeight; + } + + public double getScale() { + return this.getParameter("scale").getValue(); + } + + private MGuiMechanicBrowser mGuiMechanicBrowser; + + + @Override + public void drawDemo(float partialTicks) { + super.drawDemo(partialTicks); + double scale = FeatureMechanicBrowse.this.getParameter("scale").getValue(); + GlStateManager.scale(scale, scale, 1.0); + + Dimension bigDim = getFeatureRect().getRectangleNoScale().getSize(); + Dimension effectiveDim = new Dimension((int) (bigDim.width / scale),(int)( bigDim.height / scale)); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + Gui.drawRect(0, 0, effectiveDim.width, fr.FONT_HEIGHT + 4, 0xFF444444); + Gui.drawRect(1, 1, effectiveDim.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); + fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); + fr.drawString("Open Chat to Select Secrets", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA); + } + + private int lastWidth, lastHeight; + + @Override + public void drawScreen(float partialTicks) { + if (!isEnabled()) return; + int i = Mouse.getEventX(); + int j = Minecraft.getMinecraft().displayHeight - Mouse.getEventY(); + if (Minecraft.getMinecraft().displayWidth != lastWidth || Minecraft.getMinecraft().displayHeight != lastHeight) mGuiMechanicBrowser.initGui(); + lastWidth = Minecraft.getMinecraft().displayWidth; lastHeight = Minecraft.getMinecraft().displayHeight; + mGuiMechanicBrowser.drawScreen(i,j,partialTicks); + } + + @Override + public void setFeatureRect(GUIRectangle featureRect) { + super.setFeatureRect(featureRect); + mGuiMechanicBrowser.initGui(); + } + + @Override + public void drawHUD(float partialTicks) { } + + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + if (!isEnabled()) return; + try { + mGuiMechanicBrowser.handleMouseInput(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + @Override + public void onGuiPreRender(GuiScreenEvent.DrawScreenEvent.Pre rendered) { + if (!isEnabled()) return; + int i = Mouse.getEventX(); + int j = Minecraft.getMinecraft().displayHeight - Mouse.getEventY(); + mGuiMechanicBrowser.drawScreen(i, j, rendered.renderPartialTicks); + } + + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + if (!skyblockStatus.isOnDungeon()) return; + if (DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext() == null || !DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getMapProcessor().isInitialized()) return; + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom == null) return; + if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + String id = mGuiMechanicBrowser.getPanelMechanicBrowser().getSelectedID(); + if (id != null) { + Optional.ofNullable(dungeonRoom.getMechanics().get(mGuiMechanicBrowser.getPanelMechanicBrowser().getSelectedID())) + .ifPresent(a -> { + a.highlight(new Color(0,255,255,50), id +" ("+( + dungeonRoom.getMechanics().get(id).getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double((dungeonRoom.getMechanics().get(id)).getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", dungeonRoom, partialTicks); + }); + } + } + @Override + public List getTooltipForEditor(GuiGuiLocationConfig guiGuiLocationConfig) { + List mPanels = super.getTooltipForEditor(guiGuiLocationConfig); + + mPanels.add(new MPassiveLabelAndElement("Scale", new MFloatSelectionButton(FeatureMechanicBrowse.this.getParameter("scale").getValue()) {{ + setOnUpdate(() ->{ + FeatureMechanicBrowse.this.getParameter("scale").setValue(this.getData()); + mGuiMechanicBrowser.initGui(); + }); } + })); + + return mPanels; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java new file mode 100644 index 00000000..d7d69e0a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MGuiMechanicBrowser.java @@ -0,0 +1,45 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.mod.gui.MGui; +import lombok.Getter; + +public class MGuiMechanicBrowser extends MGui { + private FeatureMechanicBrowse featureMechanicBrowse; + @Getter + private PanelMechanicBrowser panelMechanicBrowser; + public MGuiMechanicBrowser(FeatureMechanicBrowse mechanicBrowse) { + this.featureMechanicBrowse = mechanicBrowse; + panelMechanicBrowser = new PanelMechanicBrowser(mechanicBrowse); + getMainPanel().add(panelMechanicBrowser); + } + + @Override + public void initGui() { + super.initGui(); + panelMechanicBrowser.setBounds(featureMechanicBrowse.getFeatureRect().getRectangle()); + panelMechanicBrowser.setScale(featureMechanicBrowse.getScale()); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawScreen(mouseX, mouseY, partialTicks); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java new file mode 100644 index 00000000..03937077 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MechanicBrowserElement.java @@ -0,0 +1,61 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.AllArgsConstructor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.util.function.BiConsumer; +import java.util.function.Supplier; + +@AllArgsConstructor +public class MechanicBrowserElement extends MPanel { + private Supplier name; + private boolean isCategory = false; + private BiConsumer onClick; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (isCategory || isFocused) + Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF444444); + else if (lastAbsClip.contains(absMousex, absMousey)) + Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF555555); + Minecraft.getMinecraft().fontRendererObj.drawString((String)name.get(), 4, 1, 0xFFEEEEEE); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(Minecraft.getMinecraft().fontRendererObj.getStringWidth(name.get()) + 8, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY) && onClick != null) + onClick.accept(this, new Point(lastParentPoint.x + bounds.x, lastParentPoint.y + bounds.y)); + } + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY) && onClick != null) + setCursor(EnumCursor.POINTING_HAND); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java new file mode 100644 index 00000000..87b100a5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/MechanicBrowserTooltip.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.mod.gui.elements.MList; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltip; +import lombok.Getter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MechanicBrowserTooltip extends MTooltip { + @Getter + private MList mList; + public MechanicBrowserTooltip() { + mList = new MList(); + mList.setGap(0); + add(mList); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Dimension effectiveDim = getEffectiveDimension(); + Gui.drawRect(0, 0, effectiveDim.width, effectiveDim.height, 0xFF444444); + Gui.drawRect(1, 1, effectiveDim.width - 1, effectiveDim.height - 1, 0xFF262626); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + mList.setBounds(new Rectangle(1,1, getEffectiveDimension().width-2, getEffectiveDimension().height-2)); + mList.realignChildren(); + } + + @Override + public void setScale(double scale) { + super.setScale(scale); + mList.setBounds(new Rectangle(1,1, getEffectiveDimension().width-2, getEffectiveDimension().height-2)); + mList.realignChildren(); + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = mList.getPreferredSize(); + return new Dimension((int) ((dim.width + 2) * getScale()), (int) ((dim.height + 2) * getScale())); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!lastAbsClip.contains(absMouseX, absMouseY)) close(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java new file mode 100644 index 00000000..e9082ab8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java @@ -0,0 +1,343 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser; + +import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.mod.dungeon.actions.tree.ActionRoute; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MList; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MPanelScaledGUI; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MScrollablePanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomprocessor.GeneralRoomProcessor; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class PanelMechanicBrowser extends MPanelScaledGUI { + private FeatureMechanicBrowse feature; + private MScrollablePanel scrollablePanel; + private MList mList; + private MechanicBrowserTooltip mechanicBrowserTooltip; + + public PanelMechanicBrowser(FeatureMechanicBrowse mechanicBrowse) { + this.feature = mechanicBrowse; + this.scrollablePanel = new MScrollablePanel(1); + add(this.scrollablePanel); + scrollablePanel.getScrollBarY().setWidth(0); + mList = new MList() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,0,parentWidth,parentHeight)); + Dimension prefSize = getPreferredSize(); + int hei = prefSize.height; + setBounds(new Rectangle(0,0,parentWidth,hei)); + realignChildren(); + } + }; + mList.setDrawLine(false); mList.setGap(0); + scrollablePanel.add(mList); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + toggleTooltip(openGUI()); + + if(Minecraft.getMinecraft().thePlayer == null) return; + + + Optional dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext()) + .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) + .map(a -> { + + return DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getRoomMapper().get(a); + }); + + + DungeonRoom dungeonRoom = dungeonRoomOpt.orElse(null); + renderTick(dungeonRoom); + if (dungeonRoom == null) return; + if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + + GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + Dimension effectiveDim = getEffectiveDimension(); + + Gui.drawRect(0, 0, effectiveDim.width, fr.FONT_HEIGHT + 4, 0xFF444444); + Gui.drawRect(1, 1, effectiveDim.width - 1, fr.FONT_HEIGHT + 3, 0xFF262626); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Selected: ", 2,2, 0xFFAAAAAA); + if (grp.getPath("MECH-BROWSER") == null) + fr.drawString("Nothing", fr.getStringWidth("Selected: ") + 2,2, 0xFFAA0000); + else { + ActionRoute route = grp.getPath("MECH-BROWSER"); + fr.drawString(route.getMechanic()+" -> "+route.getState(), fr.getStringWidth("Selected: ") + 2,2, 0xFFFFFF00); + } + fr.drawString("Open Chat to Select Secrets", 2, fr.FONT_HEIGHT + 5, 0xFFAAAAAA); + + if (!openGUI()) return; + + Gui.drawRect(0, fr.FONT_HEIGHT + 4, effectiveDim.width, effectiveDim.height, 0xFF444444); + Gui.drawRect(1, fr.FONT_HEIGHT + 5, effectiveDim.width - 1,effectiveDim.height - 1, 0xFF262626); + } + + private UUID lastRoomUID = null; + public void renderTick(DungeonRoom dungeonRoom) { + if (dungeonRoom == null && lastRoomUID != null) { + lastRoomUID = null; + for (MPanel childComponent : mList.getChildComponents()) { + mList.remove(childComponent); + } + if (mechanicBrowserTooltip != null) { + mechanicBrowserTooltip.close(); + mechanicBrowserTooltip = null; + } + selectedID = null; + } else if (dungeonRoom != null && lastRoomUID != dungeonRoom.getDungeonRoomInfo().getUuid()) { + lastRoomUID = dungeonRoom.getDungeonRoomInfo().getUuid(); + // SETUP THINGS. + for (MPanel childComponent : mList.getChildComponents()) { + mList.remove(childComponent); + } + if (mechanicBrowserTooltip != null) { + mechanicBrowserTooltip.close(); + mechanicBrowserTooltip = null; + } + selectedID = null; + mList.add(new MechanicBrowserElement(() -> "ยงbCancel Current", false, (pt, me) -> cancel(pt))); + + boolean found = false; + for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonFairySoul) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Fairy Soul", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonSecret) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Secrets", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonTomb) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Crypts", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonNPC) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "NPC", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonJournal) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Journals", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonRoomDoor){ + if (!found) { + mList.add(new MechanicBrowserElement(() -> "Gates", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + found = false; + for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { + if (value.getValue() instanceof DungeonDoor || value.getValue() instanceof DungeonBreakableWall || value.getValue() instanceof DungeonLever + || value.getValue() instanceof DungeonOnewayDoor || value.getValue() instanceof DungeonOnewayLever || value.getValue() instanceof DungeonPressurePlate) { + if (!found) { + mList.add(new MechanicBrowserElement(() -> "ETC", true, null)); + found = true; + } + mList.add(new MechanicBrowserElement(() -> value.getKey()+" ยง7("+ value.getValue().getCurrentState(dungeonRoom) +", "+ + (value.getValue().getRepresentingPoint(dungeonRoom) != null ? + String.format("%.1f", MathHelper.sqrt_double(value.getValue().getRepresentingPoint(dungeonRoom).getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))) : "") + +"m)", false, (me, pt) -> onElementClick(value.getKey(), value.getValue(), pt, me))); + } + } + + scrollablePanel.evalulateContentArea(); + + } + } + + private int latestTooltipDY; + @Getter + private String selectedID = null; + public void onElementClick(String id, DungeonMechanic dungeonMechanic, Point pt, MechanicBrowserElement mechanicBrowserElement) { + + Optional dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext()) + .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) + .map(a -> { + + return DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getRoomMapper().get(a); + }); + selectedID = id; + + DungeonRoom dungeonRoom = dungeonRoomOpt.orElse(null); + if (dungeonRoom == null) return; + DungeonMechanic dungeonMechanic1 = dungeonRoom.getMechanics().get(id); + if (dungeonMechanic1 != dungeonMechanic) return; + Set states = dungeonMechanic1.getPossibleStates(dungeonRoom); + + + if (mechanicBrowserTooltip != null) { + mechanicBrowserTooltip.close(); + } + + latestTooltipDY = (int) (pt.y * getScale() - bounds.y - 1); + + mechanicBrowserTooltip = new MechanicBrowserTooltip(); + for (String state : states) { + mechanicBrowserTooltip.getMList().add(new MechanicBrowserElement(() -> state, false, (m2, pt2) -> { + if (dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor) + ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind("MECH-BROWSER", id, state, FeatureRegistry.SECRET_LINE_PROPERTIES_SECRET_BROWSER.getRouteProperties()); +// mechanicBrowserTooltip.close(); +// mechanicBrowserTooltip = null; + })); + } + mechanicBrowserTooltip.setScale(getScale()); + Dimension prefSize = mechanicBrowserTooltip.getPreferredSize(); + mechanicBrowserTooltip.setBounds(new Rectangle(bounds.x + + (bounds.x > Minecraft.getMinecraft().displayWidth/2 ? -prefSize.width : bounds.width), latestTooltipDY + bounds.y, prefSize.width, prefSize.height)); + mechanicBrowserTooltip.open(this); + } + + public void cancel(MechanicBrowserElement mechanicBrowserElement) { + + Optional dungeonRoomOpt = Optional.ofNullable(DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext()) + .map(DungeonContext::getMapProcessor).map(a->a.worldPointToRoomPoint(Minecraft.getMinecraft().thePlayer.getPosition())) + .map(a -> { + + return DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext().getRoomMapper().get(a); + }); + mechanicBrowserElement.setFocused(false); + if (!dungeonRoomOpt.isPresent()) return; + DungeonRoom dungeonRoom = dungeonRoomOpt.get(); + if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).cancel("MECH-BROWSER"); + } + + public void toggleTooltip(boolean open) { + if (mechanicBrowserTooltip != null) { + if (open) { + mechanicBrowserTooltip.open(this); + } else { + mechanicBrowserTooltip.close(); + } + } + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + Dimension dimension = getEffectiveDimension(); + int y = Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT + 4; + scrollablePanel.setBounds(new Rectangle(1,y + 1, dimension.width - 2, dimension.height - y - 2)); + scrollablePanel.evalulateContentArea(); + if (mechanicBrowserTooltip != null) { + Dimension prefSize = mechanicBrowserTooltip.getPreferredSize(); + mechanicBrowserTooltip.setScale(getScale()); + mechanicBrowserTooltip.setBounds(new Rectangle(bounds.x + (bounds.x > Minecraft.getMinecraft().displayWidth/2 ? -prefSize.width: bounds.width), latestTooltipDY + bounds.y, prefSize.width, prefSize.height)); + } + } + + public boolean openGUI() { + return Minecraft.getMinecraft().currentScreen != null + && Minecraft.getMinecraft().currentScreen instanceof GuiChat && lastRoomUID != null; + } + + @Override + public List getChildComponents() { + return openGUI() ? super.getChildComponents() : Collections.emptyList(); + } + + @Override + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + selectedID = null; + if (mechanicBrowserTooltip != null) { + mechanicBrowserTooltip.close(); + mechanicBrowserTooltip = null; + } + + return super.mouseClicked0(absMouseX, absMouseY, relMouseX0, relMouseY0, mouseButton); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBlaze.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBlaze.java new file mode 100644 index 00000000..b755b94b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBlaze.java @@ -0,0 +1,51 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureSolverBlaze extends SimpleFeature { + public FeatureSolverBlaze() { + super("Dungeon.Solvers.Floor 2+", "Blaze", "Highlights the blaze that needs to be killed in an blaze room", "solver.blaze"); + addParameter("normBlazeColor", new FeatureParameter("blazecolor", "Normal Blaze Color", "Normal Blaze Color", new AColor(255,255,255,255), "acolor", nval -> normBlazeColor = nval)); + addParameter("nextBlazeColor", new FeatureParameter("blazecolor", "Next Blaze Color", "Next Blaze Color", new AColor(0,255,0,255), "acolor", nval -> nextBlazeColor = nval)); + addParameter("nextUpBlazeColor", new FeatureParameter("blazecolor", "Next Up Blaze Color", "Color of blaze after next blaze", new AColor(255,255,0,255), "acolor", nval -> nextUpBlazeColor = nval)); + addParameter("blazeborder", new FeatureParameter("blazeborder", "Blaze Border Color", "Blaze border color", new AColor(255,255,255,0), "acolor", nval -> blazeborder = nval)); + } + + AColor normBlazeColor; + AColor nextBlazeColor; + AColor nextUpBlazeColor; + AColor blazeborder; + + public AColor getBlazeColor() { + return normBlazeColor; + } + public AColor getNextBlazeColor() { + return nextBlazeColor; + } + public AColor getNextUpBlazeColor() { + return nextUpBlazeColor; + } + public AColor getBorder() { + return blazeborder; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBombdefuse.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBombdefuse.java new file mode 100644 index 00000000..1eb2c930 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBombdefuse.java @@ -0,0 +1,30 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import org.lwjgl.input.Keyboard; + +public class FeatureSolverBombdefuse extends SimpleFeature { + public FeatureSolverBombdefuse() { + super("Dungeon.Solvers.Floor 7+", "Bomb Defuse", "Communicates with others dg using key 'F' for solutions and displays it", "solver.bombdefuse"); + addParameter("key", new FeatureParameter("key", "Key","Press to send solution in chat", Keyboard.KEY_NONE, "keybind")); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBox.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBox.java new file mode 100644 index 00000000..0c00add5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverBox.java @@ -0,0 +1,57 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +import java.util.LinkedHashMap; + +public class FeatureSolverBox extends SimpleFeature { + public FeatureSolverBox() { + super("Dungeon.Solvers.Floor 3+", "Box (Advanced)", "Calculates solution for box puzzle room, and displays it to user", "solver.box"); + this.parameters = new LinkedHashMap<>(); + addParameter("disableText", new FeatureParameter("disableText", "Box Puzzle Solver Disable text", "Disable 'Type recalc to recalculate solution' showing up on top left.\nYou can still type recalc to recalc solution after disabling this feature", false, "boolean")); + addParameter("lineColor", new FeatureParameter("lineColor", "Line Color", "Color of the solution line", new AColor(0xFF00FF00, true), "acolor")); + addParameter("lineWidth", new FeatureParameter("lineWidth", "Line Thickness", "Thickness of the solution line",1.0f, "float")); + + addParameter("targetColor", new FeatureParameter("targetColor", "Target Color", "Color of the target button", new AColor(0x5500FFFF, true), "acolor")); + addParameter("textColor1", new FeatureParameter("textColor1", "Text Color", "Color of the text (next step)", new AColor(0xFF00FF00, true), "acolor")); + addParameter("textColor2", new FeatureParameter("textColor2", "Text Color", "Color of the text (others)", new AColor(0xFF000000, true), "acolor")); + } + public AColor getLineColor() { + return this.getParameter("lineColor").getValue(); + } + public float getLineWidth() { + return this.getParameter("lineWidth").getValue(); + } + public boolean disableText() { + return this.getParameter("disableText").getValue(); + } + public AColor getTargetColor() { + return this.getParameter("targetColor").getValue(); + } + public AColor getTextColor() { + return this.getParameter("textColor1").getValue(); + } + public AColor getTextColor2() { + return this.getParameter("textColor2").getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverIcefill.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverIcefill.java new file mode 100644 index 00000000..b21a9098 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverIcefill.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +import java.util.LinkedHashMap; + +public class FeatureSolverIcefill extends SimpleFeature { + public FeatureSolverIcefill() { + super("Dungeon.Solvers.Floor 3+", "Icepath (Advanced)", "Calculates solution for icepath puzzle and displays it to user", "solver.icepath"); + this.parameters = new LinkedHashMap<>(); + addParameter("lineColor", new FeatureParameter("lineColor", "Line Color", "Color of the solution line", new AColor(0xFF00FF00, true), "acolor")); + addParameter("lineWidth", new FeatureParameter("lineWidth", "Line Thickness", "Thickness of the solution line",1.0f, "float")); + } + public AColor getLineColor() { + return this.getParameter("lineColor").getValue(); + } + public float getLineWidth() { + return this.getParameter("lineWidth").getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverKahoot.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverKahoot.java new file mode 100644 index 00000000..fdd1ed7c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverKahoot.java @@ -0,0 +1,35 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureSolverKahoot extends SimpleFeature { + public FeatureSolverKahoot() { + super("Dungeon.Solvers.Floor 4+", "Quiz", "Highlights the correct solution for trivia puzzle", "solver.trivia"); + + addParameter("targetColor", new FeatureParameter("targetColor", "Target Color", "Color of the solution box", new AColor(0,255,0,50), "acolor")); + } + + public AColor getTargetColor() { + return this.getParameter("targetColor").getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverRiddle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverRiddle.java new file mode 100644 index 00000000..da84f379 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverRiddle.java @@ -0,0 +1,35 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureSolverRiddle extends SimpleFeature { + public FeatureSolverRiddle() { + super("Dungeon.Solvers.Any Floor", "Riddle", "Highlights the correct box after clicking on all 3 weirdos", "solver.riddle"); + + addParameter("targetColor", new FeatureParameter("targetColor", "Target Color", "Color of the solution box", new AColor(0,255,0,50), "acolor")); + } + + public AColor getTargetColor() { + return this.getParameter("targetColor").getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverSilverfish.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverSilverfish.java new file mode 100644 index 00000000..a014b09e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverSilverfish.java @@ -0,0 +1,44 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +import java.util.LinkedHashMap; + +public class FeatureSolverSilverfish extends SimpleFeature { + public FeatureSolverSilverfish() { + super("Dungeon.Solvers.Floor 3+", "Silverfish (Advanced)", "Actively calculates solution for silverfish puzzle and displays it to user", "solver.silverfish"); + this.parameters = new LinkedHashMap<>(); + addParameter("lineColor", new FeatureParameter("lineColor", "Line Color", "Color of the solution line", new AColor(0xFF00FF00, true), "acolor", nval -> lineColor = nval)); + addParameter("lineWidth", new FeatureParameter("lineWidth", "Line Thickness", "Thickness of the solution line",1.0f, "float", nval -> lineWidth = nval)); + } + + AColor lineColor; + Float lineWidth; + + public AColor getLineColor() { + return lineColor; + } + public float getLineWidth() { + return lineWidth; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverTeleport.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverTeleport.java new file mode 100644 index 00000000..f2a6adf2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverTeleport.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureSolverTeleport extends SimpleFeature { + public FeatureSolverTeleport() { + super("Dungeon.Solvers.Any Floor", "Teleport", "Shows teleport pads you've visited in a teleport maze room", "solver.teleport"); + + addParameter("targetColor", new FeatureParameter("targetColor", "Solution Color", "Color of the solution teleport pad", new AColor(0,255,0,100), "acolor")); + addParameter("targetColor2", new FeatureParameter("targetColor2", "Not-Solution Color", "Color of the solution teleport pads you've been to", new AColor(255,0,0,100), "acolor")); + } + + public AColor getTargetColor() { + return this.getParameter("targetColor").getValue(); + } + public AColor getTargetColor2() { + return this.getParameter("targetColor2").getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverTictactoe.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverTictactoe.java new file mode 100644 index 00000000..cafe97b3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/solvers/FeatureSolverTictactoe.java @@ -0,0 +1,39 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.impl.solvers; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; + +public class FeatureSolverTictactoe extends SimpleFeature { + public FeatureSolverTictactoe() { + super("Dungeon.Solvers.Any Floor", "Tictactoe", "Shows the best move that could be taken by player in the tictactoe room", "solver.tictactoe"); + + addParameter("targetColor", new FeatureParameter("targetColor", "Target Color", "Color of the solution box during your turn", new AColor(0,255,255,50), "acolor")); + addParameter("targetColor2", new FeatureParameter("targetColor", "Target Color", "Color of the solution box during enemy turn", new AColor(255,201,0,50), "acolor")); + } + + public AColor getTargetColor() { + return this.getParameter("targetColor").getValue(); + } + public AColor getTargetColor2() { + return this.getParameter("targetColor2").getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/BossroomEnterListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/BossroomEnterListener.java new file mode 100644 index 00000000..5de1e891 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/BossroomEnterListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface BossroomEnterListener { + void onBossroomEnter(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ChatListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ChatListener.java new file mode 100644 index 00000000..fae18924 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ChatListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +public interface ChatListener { + void onChat(ClientChatReceivedEvent clientChatReceivedEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ChatListenerGlobal.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ChatListenerGlobal.java new file mode 100644 index 00000000..60eed29b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ChatListenerGlobal.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +public interface ChatListenerGlobal { + void onChat(ClientChatReceivedEvent clientChatReceivedEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DiscordUserJoinRequestListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DiscordUserJoinRequestListener.java new file mode 100644 index 00000000..44656aa1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DiscordUserJoinRequestListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import kr.syeyoung.dungeonsguide.mod.events.impl.DiscordUserJoinRequestEvent; + +public interface DiscordUserJoinRequestListener { + void onDiscordUserJoinRequest(DiscordUserJoinRequestEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DiscordUserUpdateListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DiscordUserUpdateListener.java new file mode 100644 index 00000000..2404d960 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DiscordUserUpdateListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import kr.syeyoung.dungeonsguide.mod.events.impl.DiscordUserUpdateEvent; + +public interface DiscordUserUpdateListener { + void onDiscordUserUpdate(DiscordUserUpdateEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonContextInitializationListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonContextInitializationListener.java new file mode 100644 index 00000000..a234fa61 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonContextInitializationListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface DungeonContextInitializationListener { + void onDungeonInitialize(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonEndListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonEndListener.java new file mode 100644 index 00000000..c9ca0caa --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonEndListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface DungeonEndListener { + void onDungeonEnd(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonQuitListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonQuitListener.java new file mode 100644 index 00000000..fc0e114f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonQuitListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface DungeonQuitListener { + void onDungeonQuit(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonStartListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonStartListener.java new file mode 100644 index 00000000..d0674daf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/DungeonStartListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface DungeonStartListener { + void onDungeonStart(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/EntityLivingRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/EntityLivingRenderListener.java new file mode 100644 index 00000000..f13c29f0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/EntityLivingRenderListener.java @@ -0,0 +1,26 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.RenderLivingEvent; + +public interface EntityLivingRenderListener { + void onEntityRenderPre(RenderLivingEvent.Pre renderPlayerEvent); + void onEntityRenderPost(RenderLivingEvent.Post renderPlayerEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiBackgroundRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiBackgroundRenderListener.java new file mode 100644 index 00000000..abaf900c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiBackgroundRenderListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.GuiScreenEvent; + +public interface GuiBackgroundRenderListener { + void onGuiBGRender(GuiScreenEvent.BackgroundDrawnEvent rendered); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiClickListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiClickListener.java new file mode 100644 index 00000000..d3816c3e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiClickListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.GuiScreenEvent; + +public interface GuiClickListener { + void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiOpenListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiOpenListener.java new file mode 100644 index 00000000..bb8b8348 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiOpenListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.GuiOpenEvent; + +public interface GuiOpenListener { + void onGuiOpen(GuiOpenEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiPostRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiPostRenderListener.java new file mode 100644 index 00000000..2cd249f5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiPostRenderListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.GuiScreenEvent; + +public interface GuiPostRenderListener { + void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiPreRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiPreRenderListener.java new file mode 100644 index 00000000..848267c3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiPreRenderListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.GuiScreenEvent; + +public interface GuiPreRenderListener { + void onGuiPreRender(GuiScreenEvent.DrawScreenEvent.Pre rendered); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiUpdateListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiUpdateListener.java new file mode 100644 index 00000000..633f1542 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/GuiUpdateListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import kr.syeyoung.dungeonsguide.mod.events.impl.WindowUpdateEvent; + +public interface GuiUpdateListener { + void onGuiUpdate(WindowUpdateEvent windowUpdateEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/InteractListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/InteractListener.java new file mode 100644 index 00000000..0dcbc19d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/InteractListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +public interface InteractListener { + void onInteract(PlayerInteractEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/KeyInputListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/KeyInputListener.java new file mode 100644 index 00000000..bba7862b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/KeyInputListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.GuiScreenEvent; + +public interface KeyInputListener { + void onKeyInput(GuiScreenEvent.KeyboardInputEvent keyboardInputEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/KeybindPressedListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/KeybindPressedListener.java new file mode 100644 index 00000000..d0966183 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/KeybindPressedListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import kr.syeyoung.dungeonsguide.mod.events.impl.KeyBindPressedEvent; + +public interface KeybindPressedListener { + void onKeybindPress(KeyBindPressedEvent keyBindPressedEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/PlayerRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/PlayerRenderListener.java new file mode 100644 index 00000000..40961ced --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/PlayerRenderListener.java @@ -0,0 +1,26 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.RenderPlayerEvent; + +public interface PlayerRenderListener { + void onEntityRenderPre(RenderPlayerEvent.Pre renderPlayerEvent ); + void onEntityRenderPost(RenderPlayerEvent.Post renderPlayerEvent ); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ScreenRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ScreenRenderListener.java new file mode 100644 index 00000000..4a69b8eb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/ScreenRenderListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface ScreenRenderListener { + void drawScreen(float partialTicks); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SkyblockJoinListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SkyblockJoinListener.java new file mode 100644 index 00000000..d2d996e9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SkyblockJoinListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface SkyblockJoinListener { + void onSkyblockJoin(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SkyblockLeaveListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SkyblockLeaveListener.java new file mode 100644 index 00000000..e1d95775 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SkyblockLeaveListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface SkyblockLeaveListener { + void onSkyblockQuit(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SoundListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SoundListener.java new file mode 100644 index 00000000..9cd4b2fe --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/SoundListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.sound.PlaySoundEvent; + +public interface SoundListener { + void onSound(PlaySoundEvent playSoundEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/StompConnectedListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/StompConnectedListener.java new file mode 100644 index 00000000..3772f780 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/StompConnectedListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import kr.syeyoung.dungeonsguide.mod.events.impl.StompConnectedEvent; + +public interface StompConnectedListener { + void onStompConnected(StompConnectedEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TextureStichListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TextureStichListener.java new file mode 100644 index 00000000..5c54eb9e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TextureStichListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.client.event.TextureStitchEvent; + +public interface TextureStichListener { + void onTextureStitch(TextureStitchEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TickListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TickListener.java new file mode 100644 index 00000000..436ea23d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TickListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface TickListener { + void onTick(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TitleListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TitleListener.java new file mode 100644 index 00000000..ec402a96 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TitleListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraft.network.play.server.S45PacketTitle; + +public interface TitleListener { + void onTitle(S45PacketTitle renderPlayerEvent); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TooltipListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TooltipListener.java new file mode 100644 index 00000000..f2f73c62 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/TooltipListener.java @@ -0,0 +1,25 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +public interface TooltipListener { + void onTooltip(ItemTooltipEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/WorldRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/WorldRenderListener.java new file mode 100644 index 00000000..40b8e338 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/listener/WorldRenderListener.java @@ -0,0 +1,23 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.listener; + +public interface WorldRenderListener { + void drawWorld(float partialTicks); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/PanelTextParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/PanelTextParameterConfig.java new file mode 100644 index 00000000..f12fb379 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/PanelTextParameterConfig.java @@ -0,0 +1,283 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.text; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MEditableAColor; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MPanelScaledGUI; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MScrollablePanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MToggleButton; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class PanelTextParameterConfig extends MPanel { + + private final StyledTextProvider feature; + + private final MEditableAColor currentColor; + private final MEditableAColor backgroundColor; + private final MToggleButton shadow; + + private MScrollablePanel mScrollablePanel; + private MPanelScaledGUI rendering; + + @Override + public void onBoundsUpdate() { + } + @Override + public Dimension getPreferredSize() { + return new Dimension(400, getPanelBound().height + 20); + } + + public PanelTextParameterConfig(final StyledTextProvider feature) { + this.feature = feature; + setBackgroundColor(new Color(38, 38, 38, 255)); + + currentColor = new MEditableAColor(); + currentColor.setColor(new AColor(0xff555555, true)); + currentColor.setEnableEdit(false); + currentColor.setSize(new Dimension(15, 10)); + currentColor.setOnUpdate(new Runnable() { + @Override + public void run() { + for (String se:selected) + feature.getStylesMap().get(se).setColor(currentColor.getColor()); + } + }); + add(currentColor); + backgroundColor = new MEditableAColor(); + backgroundColor.setColor(new AColor(0xff555555, true)); + backgroundColor.setEnableEdit(false); + backgroundColor.setSize(new Dimension(15, 10)); + backgroundColor.setOnUpdate(new Runnable() { + @Override + public void run() { + for (String se:selected) + feature.getStylesMap().get(se).setBackground(backgroundColor.getColor()); + } + }); + add(backgroundColor); + shadow = new MToggleButton(); + shadow.setSize(new Dimension(20, 10)); + shadow.setOnToggle(new Runnable() { + @Override + public void run() { + for (String se:selected) + feature.getStylesMap().get(se).setShadow(shadow.isEnabled()); + } + }); + add(shadow); + + mScrollablePanel = new MScrollablePanel(3); + mScrollablePanel.setHideScrollBarWhenNotNecessary(true); + add(mScrollablePanel); + + mScrollablePanel.add(rendering = new MPanelScaledGUI() { + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); + + List texts = feature.getDummyText(); + Map styles = feature.getStylesMap(); + List calc = StyledTextRenderer.drawTextWithStylesAssociated(texts, 0,0, getEffectiveDimension().width, styles, StyledTextRenderer.Alignment.LEFT); + boolean bool =scissor.contains(absMousex, absMousey); + for (StyledTextRenderer.StyleTextAssociated calc3: calc) { + if (selected.contains(calc3.getStyledText().getGroup())) { + Gui.drawRect(calc3.getRectangle().x, calc3.getRectangle().y, calc3.getRectangle().x + calc3.getRectangle().width, calc3.getRectangle().y + calc3.getRectangle().height, 0x4244A800); + } else if (bool && calc3.getRectangle().contains(relMousex0, relMousey0)) { + for (StyledTextRenderer.StyleTextAssociated calc2 : calc) { + if (calc2.getStyledText().getGroup().equals(calc3.getStyledText().getGroup())) + Gui.drawRect(calc2.getRectangle().x, calc2.getRectangle().y, calc2.getRectangle().x + calc2.getRectangle().width, calc2.getRectangle().y + calc2.getRectangle().height, 0x55777777); + } + } + } + } + + + private int lastX; + private int lastY; + private boolean dragStart = false; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + List texts = feature.getDummyText(); + Map styles = feature.getStylesMap(); + boolean existed = selected.isEmpty(); + boolean found = false; + List calc = StyledTextRenderer.calculate(texts, 0,0, styles); + for (StyledTextRenderer.StyleTextAssociated calc3: calc) { + if (calc3.getRectangle().contains(relMouseX, relMouseY)) { + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { + if (!selected.contains(calc3.getStyledText().getGroup())) + selected.add(calc3.getStyledText().getGroup()); + else + selected.remove(calc3.getStyledText().getGroup()); + } else { + selected.clear(); + selected.add(calc3.getStyledText().getGroup()); + } + found = true; + } + } + + if (!found && !(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) && parent.getLastAbsClip().contains(absMouseX * getScale(), absMouseY* getScale())) { + selected.clear(); + dragStart = true; + lastX = absMouseX; + lastY = absMouseY; + } + currentColor.setEnableEdit(selected.size() != 0); + PanelTextParameterConfig.this.backgroundColor.setEnableEdit(selected.size() != 0); + if (existed != selected.isEmpty()) { + if (selected.size() != 0) { + currentColor.setColor(styles.get(selected.iterator().next()).getColor()); + PanelTextParameterConfig.this.backgroundColor.setColor(styles.get(selected.iterator().next()).getBackground()); + shadow.setEnabled(styles.get(selected.iterator().next()).isShadow()); + } else { + currentColor.setColor(new AColor(0xff555555, true)); + PanelTextParameterConfig.this.backgroundColor.setColor(new AColor(0xff555555, true)); + shadow.setEnabled(false); + } + } + + if (selected.size() == 1) { + currentColor.setColor(styles.get(selected.iterator().next()).getColor()); + PanelTextParameterConfig.this.backgroundColor.setColor(styles.get(selected.iterator().next()).getBackground()); + shadow.setEnabled(styles.get(selected.iterator().next()).isShadow()); + } + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + dragStart = false; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + if (dragStart) { + int dx= absMouseX - lastX; + int dy= absMouseY - lastY; + int actualOFFX = (int) (dx / getScale()); + int actualOFFY = (int) (dy / getScale()); + lastX =(int) (actualOFFX * getScale())+lastX; + lastY =(int) (actualOFFY * getScale())+lastY; + mScrollablePanel.getScrollBarX().addToCurrent(-actualOFFX); + mScrollablePanel.getScrollBarY().addToCurrent(-actualOFFY); + } + } + + @Override + public Dimension getPreferredSize() { + List calc = StyledTextRenderer.calculate(feature.getDummyText(), 0,0, feature.getStylesMap()); + int w = 0, h = 0; + for (StyledTextRenderer.StyleTextAssociated styleTextAssociated : calc) { + int endX = styleTextAssociated.getRectangle().x + styleTextAssociated.getRectangle().width; + int endY = styleTextAssociated.getRectangle().y + styleTextAssociated.getRectangle().height; + if (endX > w) w = endX; + if (endY > h) h = endY; + } + return new Dimension((int) (w * getScale()),(int) (h * getScale())); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(new Point(0,0), getPreferredSize())); + } + + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if ( parent.getLastAbsClip().contains(absMouseX * getScale(), absMouseY* getScale())) { + double scale = rendering.getScale(); + if (scrollAmount > 0) { + scale += 0.1; + } else if (scrollAmount < 0) { + scale -= 0.1; + } + if (scale < 0.1) scale = 0.1f; + if (scale > 5) scale = 5.0f; + rendering.setScale(scale); + mScrollablePanel.setBounds(new Rectangle(new Point(5,5),getPanelBound())); + } + } + }); + + + } + + private final Set selected = new HashSet(); + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + + GlStateManager.pushMatrix(); + + Dimension dim = getPanelBound(); + int width = dim.width, height = dim.height; + Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f)); + Gui.drawRect(4,4,width+6, height+6, 0xFF222222); + Gui.drawRect(5,5,width+5, height+5, RenderUtils.blendAlpha(0x141414, 0.15f)); + + + GlStateManager.translate(5, height + 7, 0); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString("Press Shift to multi-select", 0, 0, 0xFFBFBFBF); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.translate(width + 15, 5, 0); + GlStateManager.pushMatrix(); + fr.drawString("Selected Groups: "+selected, 0, 0, 0xFFBFBFBF); + GlStateManager.popMatrix(); + fr.drawString("Text Color: ", 0, 10, 0xFFFFFFFF); + fr.drawString("Background Color: ", 0, 20, 0xFFFFFFFF); + fr.drawString("Shadow: ", 0, 39, 0xFFFFFFFF); + + GlStateManager.popMatrix(); + } + + private Dimension getPanelBound(){ +// return new Dimension((getBounds().width-25)/2, 100); + return new Dimension(150,100); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + + Dimension dim = getPanelBound(); + currentColor.setBounds(new Rectangle(75+dim.width , 14, 15, 10)); + backgroundColor.setBounds(new Rectangle(110+dim.width , 24, 15, 10)); + shadow.setBounds(new Rectangle(75+dim.width , 43, 30, 10)); + mScrollablePanel.setBounds(new Rectangle(5,5,dim.width,dim.height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledText.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledText.java new file mode 100644 index 00000000..d9f936fa --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledText.java @@ -0,0 +1,29 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.text; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class StyledText { + private String text; + private String group; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextProvider.java new file mode 100644 index 00000000..04a4cc81 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextProvider.java @@ -0,0 +1,30 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.text; + +import java.util.List; +import java.util.Map; + +public interface StyledTextProvider { + List getDummyText(); + List getText(); + + List getStyles(); + Map getStylesMap(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextRenderer.java new file mode 100644 index 00000000..17bddb72 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/StyledTextRenderer.java @@ -0,0 +1,244 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.text; + +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.fml.relauncher.ReflectionHelper; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class StyledTextRenderer { + + public static enum Alignment { + LEFT, CENTER, RIGHT + } + + private static final Method renderChar = ReflectionHelper.findMethod(FontRenderer.class, null, new String[] {"renderChar", "func_181559_a"}, char.class, boolean.class); + private static final Method doDraw = ReflectionHelper.findMethod(FontRenderer.class, null, new String[] {"doDraw"}, float.class); + private static final Field posX = ReflectionHelper.findField(FontRenderer.class, "posX", "field_78295_j"); + private static final Field posY = ReflectionHelper.findField(FontRenderer.class, "posY", "field_78296_k"); + + + public static List drawTextWithStylesAssociated(List texts, int x, int y,int width, Map styleMap, Alignment alignment) { + String[] totalLines = (texts.stream().map( a-> a.getText()).collect(Collectors.joining())+" ").split("\n"); + + + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + + int currentLine = 0; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine])); + int currY = y; + int maxHeightForLine = 0; + List associateds = new ArrayList(); + for (StyledText st : texts) { + TextStyle ts = styleMap.get(st.getGroup()); + String[] lines = st.getText().split("\n"); + for (int i = 0; i < lines.length; i++) { + String str = lines[i]; + Dimension d = null; + try { + d = drawFragmentText(fr, str, ts, currX, currY, false); + } catch (InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); + } + associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height))); + currX += d.width; + if (maxHeightForLine < d.height) + maxHeightForLine = d.height; + + if (i+1 != lines.length) { + currY += maxHeightForLine ; + currentLine++; + currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine])); + maxHeightForLine = 0; + } + } + if (st.getText().endsWith("\n")) { + currY += maxHeightForLine; + currentLine++; + currX = alignment == Alignment.LEFT ? x : alignment == Alignment.CENTER ? (x+width-fr.getStringWidth(totalLines[currentLine]))/2 : (x+width-fr.getStringWidth(totalLines[currentLine])); + maxHeightForLine = 0; + } + } + return associateds; + } + + public static List calculate(List texts, int x, int y, Map styleMap) { + int currX = x; + int currY = y; + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + int maxHeightForLine = 0; + List associateds = new ArrayList(); + for (StyledText st : texts) { + TextStyle ts = styleMap.get(st.getGroup()); + String[] lines = st.getText().split("\n"); + for (int i = 0; i < lines.length; i++) { + String str = lines[i]; + Dimension d = null; + try { + d = drawFragmentText(fr, str, ts, currX, currY, true); + } catch (InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); + } + associateds.add(new StyleTextAssociated(st, new Rectangle(currX, currY, d.width, d.height))); + currX += d.width; + if (maxHeightForLine < d.height) + maxHeightForLine = d.height; + + if (i+1 != lines.length) { + currY += maxHeightForLine; + currX = x; + maxHeightForLine = 0; + } + } + if (st.getText().endsWith("\n")) { + currY += maxHeightForLine; + currX = x; + maxHeightForLine = 0; + } + } + return associateds; + } + + @Data + @AllArgsConstructor + public static class StyleTextAssociated { + private StyledText styledText; + private Rectangle rectangle; + } + + private static Dimension drawFragmentText(FontRenderer fr, String content, TextStyle style, int x, int y, boolean stopDraw) throws InvocationTargetException, IllegalAccessException { + if (stopDraw) + return new Dimension(fr.getStringWidth(content), fr.FONT_HEIGHT); + + int bgColor = RenderUtils.getColorAt(x,y, style.getBackground()); + if ((bgColor & 0xFF000000) != 0) + Gui.drawRect(x,y, x+fr.getStringWidth(content), y + fr.FONT_HEIGHT, bgColor); + + + posX.set(fr, x+1); + posY.set(fr, y+1); + + if (style.isShadow()) { + char[] charArr = content.toCharArray(); + float width = 0; + for (int i = 0; i < charArr.length; i++) { + int color = RenderUtils.getColorAt(x + width, y, style.getColor()); + color = (color & 16579836) >> 2 | color & -16777216; + + width +=renderChar(fr, charArr[i], color,true, false, false, false); + } + } + posX.set(fr, x); + posY.set(fr, y); + { + char[] charArr = content.toCharArray(); + float width = 0; + for (int i = 0; i < charArr.length; i++) { + int color = RenderUtils.getColorAt(x + width, y, style.getColor()); + + width +=renderChar(fr, charArr[i], color, false, false, false, false); + } + return new Dimension((int) width, fr.FONT_HEIGHT); + } + } + + private static float renderChar(FontRenderer fr, char character, int color, boolean shadow, boolean randomStyle, boolean boldStyle, boolean italicStyle) throws InvocationTargetException, IllegalAccessException { + RenderUtils.GL_SETCOLOR(color); + int j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(character); + + if (randomStyle && j != -1) + { + int k = fr.getCharWidth(character); + char c1; + + while (true) + { + j = fr.fontRandom.nextInt("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".length()); + c1 = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".charAt(j); + + if (k == fr.getCharWidth(c1)) + { + break; + } + } + + character = c1; + } + + float f1 = j == -1 || fr.getUnicodeFlag() ? 0.5f : 1f; + boolean flag = (character == 0 || j == -1 || fr.getUnicodeFlag()) && shadow; + + if (flag) + { + posX.set(fr,(float) posX.get(fr) - f1); + posY.set(fr,(float) posY.get(fr) - f1); + } + + float f = (float) renderChar.invoke(fr, character, italicStyle); + + if (flag) + { + posX.set(fr,(float) posX.get(fr) + f1); + posY.set(fr,(float) posY.get(fr) + f1); + } + + if (boldStyle) + { + posX.set(fr,(float) posX.get(fr) + f1); + + if (flag) + { + posX.set(fr,(float) posX.get(fr) - f1); + posY.set(fr,(float) posY.get(fr) - f1); + } + + renderChar.invoke(fr, character, italicStyle); + posX.set(fr,(float) posX.get(fr) - f1); + + if (flag) + { + posX.set(fr,(float) posX.get(fr) + f1); + posY.set(fr,(float) posY.get(fr) + f1); + } + + ++f; + } + doDraw.invoke(fr, f); + + return f; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java new file mode 100644 index 00000000..f70ab496 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java @@ -0,0 +1,191 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.text; + +import com.google.common.base.Supplier; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.mod.features.GuiFeature; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MFloatSelectionButton; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MPassiveLabelAndElement; +import kr.syeyoung.dungeonsguide.mod.gui.elements.MStringSelectionButton; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; + +import java.util.*; +import java.util.List; + +public abstract class TextHUDFeature extends GuiFeature implements StyledTextProvider { + protected TextHUDFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { + super(category, name, description, key, keepRatio, width, height); + addParameter("textStylesNEW", new FeatureParameter>("textStylesNEW", "", "", new ArrayList(), "list_textStyle")); + addParameter("alignment", new FeatureParameter("alignment", "Alignment", "Alignment", "LEFT", "string")); + addParameter("scale", new FeatureParameter("scale", "Scale", "Scale", 1.0f, "float")); + } + + @Override + public void drawHUD(float partialTicks) { + if (isHUDViewable()) { + List asd = getText(); + + double scale = 1; + if (doesScaleWithHeight()) { + FontRenderer fr = getFontRenderer(); + scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); + } else { + scale = this.getParameter("scale").getValue(); + } + GlStateManager.scale(scale, scale, 0); + StyledTextRenderer.drawTextWithStylesAssociated(asd, 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(), + StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.getParameter("alignment").getValue())); + } + } + + public boolean doesScaleWithHeight() { + return true; + } + + @Override + public void drawDemo(float partialTicks) { + List asd = getDummyText(); + double scale = 1; + if (doesScaleWithHeight()) { + FontRenderer fr = getFontRenderer(); + scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); + } else { + scale = this.getParameter("scale").getValue(); + } + GlStateManager.scale(scale, scale, 0); + + StyledTextRenderer.drawTextWithStylesAssociated(asd, 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(), + StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.getParameter("alignment").getValue())); + } + + public int countLines(List texts) { + StringBuilder things = new StringBuilder(); + for (StyledText text : texts) { + things.append(text.getText()); + } + String things2 = things.toString().trim(); + int lines = 1; + for (char c : things2.toCharArray()) { + if (c == '\n') lines++; + } + return lines; + } + + public abstract boolean isHUDViewable(); + + public abstract List getUsedTextStyle(); + public List getDummyText() { + return getText(); + } + public abstract List getText(); + + public List getStyles() { + return this.>getParameter("textStylesNEW").getValue(); + } + private Map stylesMap; + public Map getStylesMap() { + if (stylesMap == null) { + List styles = getStyles(); + Map res = new HashMap(); + for (TextStyle ts : styles) { + res.put(ts.getGroupName(), ts); + } + for (String str : getUsedTextStyle()) { + if (!res.containsKey(str)) + res.put(str, new TextStyle(str, new AColor(0xffffffff, true), new AColor(0x00777777, true), false)); + } + stylesMap = res; + } + return stylesMap; + } + + + @Override + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier() { + @Override + public MPanel get() { + + MFeatureEdit featureEdit = new MFeatureEdit(TextHUDFeature.this, rootConfigPanel); + featureEdit.addParameterEdit("textStyleNEW", new PanelTextParameterConfig(TextHUDFeature.this)); + + StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.getParameter("alignment").getValue()); + MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name()); + mStringSelectionButton.setOnUpdate(() -> { + TextHUDFeature.this.getParameter("alignment").setValue(mStringSelectionButton.getSelected()); + }); + featureEdit.addParameterEdit("alignment", new MParameterEdit(TextHUDFeature.this, TextHUDFeature.this.getParameter("alignment"), rootConfigPanel, mStringSelectionButton, (a) -> false)); + + for (FeatureParameter parameter: getParameters()) { + if (parameter.getKey().equals("textStylesNEW")) continue; + if (parameter.getKey().equals("alignment")) continue; + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(TextHUDFeature.this, parameter, rootConfigPanel)); + } + return featureEdit; + } + }); + return "base." + getKey() ; + } + + @Override + public List getTooltipForEditor(GuiGuiLocationConfig guiGuiLocationConfig) { + List mPanels = super.getTooltipForEditor(guiGuiLocationConfig); + StyledTextRenderer.Alignment alignment = StyledTextRenderer.Alignment.valueOf(this.getParameter("alignment").getValue()); + MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(Arrays.asList("LEFT", "CENTER", "RIGHT"), alignment.name()); + mStringSelectionButton.setOnUpdate(() -> { + TextHUDFeature.this.getParameter("alignment").setValue(mStringSelectionButton.getSelected()); + }); + + mPanels.add(new MPassiveLabelAndElement("Alignment", mStringSelectionButton)); + if (!doesScaleWithHeight()) { + mPanels.add(new MPassiveLabelAndElement("Scale", new MFloatSelectionButton(TextHUDFeature.this.getParameter("scale").getValue()) {{ + setOnUpdate(() ->{ + TextHUDFeature.this.getParameter("scale").setValue(this.getData()); + }); } + })); + } + + return mPanels; + } + + @Override + public void onParameterReset() { + stylesMap = null; + } + + @Override + public void loadConfig(JsonObject jsonObject) { + super.loadConfig(jsonObject); + StyledTextRenderer.Alignment alignment; + try { + alignment = StyledTextRenderer.Alignment.valueOf(TextHUDFeature.this.getParameter("alignment").getValue()); + } catch (Exception e) {alignment = StyledTextRenderer.Alignment.LEFT;} + TextHUDFeature.this.getParameter("alignment").setValue(alignment.name()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextStyle.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextStyle.java new file mode 100644 index 00000000..16cb4b66 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextStyle.java @@ -0,0 +1,34 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.features.text; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TextStyle { + private String groupName; + private AColor color; + private AColor background; + private boolean shadow = false; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/MGui.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/MGui.java new file mode 100644 index 00000000..1db826a4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/MGui.java @@ -0,0 +1,247 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui; + +import kr.syeyoung.dungeonsguide.mod.gui.elements.MRootPanel; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.GLCursors; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.LWJGLException; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.io.IOException; + +public class MGui extends GuiScreen { + + @Getter + private final MRootPanel mainPanel = new MRootPanel(); + private boolean isOpen = false; + + public MGui() { + try { + Mouse.setNativeCursor(GLCursors.getCursor(EnumCursor.DEFAULT)); + } catch (Throwable e) { + e.printStackTrace(); + } + } + + @Override + public void initGui() { + super.initGui(); + Keyboard.enableRepeatEvents(true); + isOpen = true; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + mainPanel.setBounds(new Rectangle(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + int i = Mouse.getEventX(); + int j = this.mc.displayHeight - Mouse.getEventY(); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GlStateManager.pushMatrix(); + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GlStateManager.color(1, 1, 1, 1); + GlStateManager.scale(1.0 / scaledResolution.getScaleFactor(), 1.0 / scaledResolution.getScaleFactor(), 1.0d); + mainPanel.render0(1, new Point(0, 0), new Rectangle(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight), i, j, i, j, partialTicks); + GlStateManager.popMatrix(); + GlStateManager.enableBlend(); + GlStateManager.enableDepth(); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } + + @Override + public void keyTyped(char typedChar, int keyCode) throws IOException { + try { + mainPanel.keyPressed0(typedChar, keyCode); + super.keyTyped(typedChar, keyCode); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + public void keyHeld(int keyCode, char typedChar) throws IOException { + try { + mainPanel.keyHeld0(typedChar, keyCode); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + public void keyReleased(int keyCode, char typedChar) throws IOException { + try { + mainPanel.keyReleased0(typedChar, keyCode); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + try { + super.mouseClicked(mouseX, mouseY, mouseButton); + mainPanel.mouseClicked0(mouseX, mouseY + , mouseX, mouseY, mouseButton); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + Keyboard.enableRepeatEvents(false); + isOpen = false; + + try { + Mouse.setNativeCursor(null); + mainPanel.setCursor(EnumCursor.DEFAULT); + } catch (LWJGLException e) { + e.printStackTrace(); + } + } + + @Override + public void mouseReleased(int mouseX, int mouseY, int state) { + try { + mainPanel.mouseReleased0(mouseX, mouseY + , mouseX, mouseY, state); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + @Override + public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + try { + mainPanel.mouseClickMove0(mouseX, mouseY + , mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + public void mouseMove(int mouseX, int mouseY) { + try { + mainPanel.mouseMoved0(mouseX, mouseY + , mouseX, mouseY); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + + private int touchValue; + private int eventButton; + private long lastMouseEvent; + + + private int lastX, lastY; + + + @Override + public void handleMouseInput() throws IOException { + if (!isOpen) return; + try { + int i = Mouse.getEventX(); + int j = this.mc.displayHeight - Mouse.getEventY(); + int k = Mouse.getEventButton(); + + if (Mouse.getEventButtonState()) { + if (this.mc.gameSettings.touchscreen && this.touchValue++ > 0) { + return; + } + + this.eventButton = k; + this.lastMouseEvent = Minecraft.getSystemTime(); + this.mouseClicked(i, j, this.eventButton); + } else if (k != -1) { + if (this.mc.gameSettings.touchscreen && --this.touchValue > 0) { + return; + } + + this.eventButton = -1; + this.mouseReleased(i, j, k); + } else if (this.eventButton != -1 && this.lastMouseEvent > 0L) { + long l = Minecraft.getSystemTime() - this.lastMouseEvent; + this.mouseClickMove(i, j, this.eventButton, l); + } + if (lastX != i || lastY != j) { + try { + EnumCursor prevCursor = mainPanel.getCurrentCursor(); + mainPanel.setCursor(EnumCursor.DEFAULT); + this.mouseMove(i, j); + EnumCursor newCursor = mainPanel.getCurrentCursor(); + if (prevCursor != newCursor) Mouse.setNativeCursor(GLCursors.getCursor(newCursor)); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + + int wheel = Mouse.getEventDWheel(); + if (wheel != 0) { + mainPanel.mouseScrolled0(i, j, i, j, wheel); + } + lastX = i; + lastY = j; + } catch (Throwable e) { + e.printStackTrace(); + } + } + + public void handleKeyboardInput() throws IOException { + if (!isOpen) return; + + if (Keyboard.getEventKeyState()) { + if (Keyboard.isRepeatEvent()) + this.keyHeld(Keyboard.getEventKey(), Keyboard.getEventCharacter()); + else + this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); + } else { + this.keyReleased(Keyboard.getEventKey(), Keyboard.getEventCharacter()); + } + + this.mc.dispatchKeypresses(); + } + + @Override + public void handleInput() throws IOException { +// Keyboard.enableRepeatEvents(true); // i hope it's temproary solution + super.handleInput(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/MPanel.java new file mode 100644 index 00000000..6a329110 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/MPanel.java @@ -0,0 +1,296 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui; + +import kr.syeyoung.dungeonsguide.mod.gui.elements.MTooltip; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +@Getter +public class MPanel { + protected Rectangle bounds = new Rectangle(0,0,0,0); // relative to parent + + protected List childComponents = new CopyOnWriteArrayList(); + + protected Color backgroundColor = new Color(0,0,0,0); + + protected Rectangle lastAbsClip = new Rectangle(0,0,0,0); + + @Getter(AccessLevel.PUBLIC) + @Setter + protected boolean isFocused; + + @Getter + @Setter + protected MPanel parent; + + private boolean debug; + + public void setBackgroundColor(Color c) { + if (c == null) return; + this.backgroundColor = c; + } + + public void setPosition(Point pt) { + this.setBounds(new Rectangle(pt.x, pt.y, getBounds().width, getBounds().height)); + } + + public void setSize(Dimension dim) { + this.setBounds(new Rectangle(getBounds().x, getBounds().y, dim.width, dim.height)); + } + + public Dimension getSize() { + return getBounds().getSize(); + } + + public Dimension getPreferredSize() { return getSize(); } + + public void setBounds(Rectangle bounds) { + if (bounds == null) return; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; + + for (MPanel childComponent : childComponents) { + childComponent.resize0(getBounds().width, getBounds().height); + } + onBoundsUpdate(); + } + + public void onBoundsUpdate() { + + } + + public void add(MPanel child) { + if (child.parent != null) throw new IllegalArgumentException("What have you done"); + this.childComponents.add(child); + child.setParent(this); + } + + public void openTooltip(MTooltip mPanel) { + parent.openTooltip(mPanel); + } + public int getTooltipsOpen() { + return parent.getTooltipsOpen(); + } + + public void remove(MPanel panel) { + if (panel != null) + panel.setParent(null); + this.childComponents.remove(panel); + } + + protected Point lastParentPoint; + + @Getter + @Setter + private boolean ignoreBoundOnClip; + + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a + + lastParentPoint = parentPoint; + int relMousex = relMousex0 - getBounds().x; + int relMousey = relMousey0 - getBounds().y; + + GlStateManager.translate(getBounds().x, getBounds().y, 5); + GlStateManager.color(1,1,1,1); + + + Rectangle absBound = getBounds().getBounds(); + absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); + Rectangle clip; + if (ignoreBoundOnClip) clip = parentClip; + else clip = determineClip(parentClip, absBound); + lastAbsClip = clip; + if (clip.getSize().height * clip.getSize().width == 0) return; + + this.scale = scale; + clip(clip.x, clip.y, clip.width, clip.height); + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + GuiScreen.drawRect(0,0, getBounds().width, getBounds().height, backgroundColor.getRGB()); + GlStateManager.enableBlend(); + + GlStateManager.pushMatrix(); + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + + render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); + GlStateManager.popMatrix(); + if (debug && lastAbsClip.contains(absMousex, absMousey)) { + GL11.glDisable(GL11.GL_SCISSOR_TEST); + Gui.drawRect(0, 0, getBounds().width, getBounds().height, 0x2200FF00); + Gui.drawRect(0, 0, getPreferredSize().width, getPreferredSize().height, 0x220000FF); + } + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + Point newPt = new Point(parentPoint.x + getBounds().x, parentPoint.y + getBounds().y); + + for (MPanel mPanel : getChildComponents()){ + GlStateManager.pushMatrix(); + mPanel.render0(scale, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks); + GlStateManager.popMatrix(); + } + } + protected double scale; + public void clip(int x, int y, int width, int height) { + if (width < 0 || height < 0) return; + + GL11.glScissor((int) (x * scale), Minecraft.getMinecraft().displayHeight - (int) ((y + height) * scale), (int)(width* scale + scale) - 1, (int) (height * scale + scale) - 1); + } + + protected Rectangle determineClip(Rectangle rect1, Rectangle rect2) { + int minX = Math.max(rect1.x, rect2.x); + int minY = Math.max(rect1.y, rect2.y); + int maxX = Math.min(rect1.x + rect1.width, rect2.x + rect2.width); + int maxY = Math.min(rect1.y + rect1.height, rect2.y +rect2.height); + if (minX > maxX) return new Rectangle(0,0,0,0); + if (minY > maxY) return new Rectangle(0,0,0,0); + return new Rectangle(minX, minY, maxX - minX, maxY - minY); + } + + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {} + + public void resize0(int parentWidth, int parentHeight) { + resize(parentWidth, parentHeight); + } + + public void resize(int parentWidth, int parentHeight) {} + + + public void keyPressed0(char typedChar, int keyCode) { + for (MPanel childComponent : getChildComponents()) { + childComponent.keyPressed0(typedChar, keyCode); + } + + if (isFocused) + keyPressed(typedChar, keyCode); + } + public void keyPressed(char typedChar, int keyCode) {} + public void keyHeld0(char typedChar, int keyCode) { + for (MPanel childComponent : getChildComponents()) { + childComponent.keyHeld0(typedChar, keyCode); + } + + if (isFocused) + keyHeld(typedChar, keyCode); + } + public void keyHeld(char typedChar, int keyCode) {} + public void keyReleased0(char typedChar, int keyCode) { + for (MPanel childComponent : getChildComponents()) { + childComponent.keyReleased0(typedChar, keyCode); + } + + if (isFocused) + keyReleased(typedChar, keyCode); + } + public void keyReleased(char typedChar, int keyCode) {} + + + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + boolean noClip = true; + boolean focusedOverall = false; + for (MPanel childComponent : getChildComponents()) { + if (childComponent.mouseClicked0(absMouseX, absMouseY, relMousex, relMousey, mouseButton)) { + noClip = false; + focusedOverall = true; + } + } + + if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { + isFocused = true; + focusedOverall = true; + } else { + isFocused = false; + } + + mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); + return focusedOverall; + } + + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {} + + public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseReleased0(absMouseX, absMouseY, relMousex, relMousey, state); + } + mouseReleased(absMouseX, absMouseY, relMousex, relMousey, state); + } + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {} + + public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseClickMove0(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); + } + mouseClickMove(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); + } + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {} + + public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseScrolled0(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); + } + mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); + } + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {} + + public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + mouseMoved(absMouseX, absMouseY, relMousex, relMousey); + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseMoved0(absMouseX, absMouseY, relMousex, relMousey); + } + } + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) {} + + public void setCursor(EnumCursor enumCursor) { + parent.setCursor(enumCursor); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MButton.java new file mode 100755 index 00000000..4d8ee52f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MButton.java @@ -0,0 +1,117 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +@Getter +@Setter +public class MButton extends MPanel { + private String text; + + private Color foreground = Color.white; + private int background = RenderUtils.blendAlpha(0xFF141414, 0.08f); + private int hover = RenderUtils.blendAlpha(0xFF141414, 0.14f); + private int clicked = RenderUtils.blendAlpha(0xFF141414, 0.16f); + private int border = 0x0; + private int disabled =0xFF141414; + private int roundness = 0; + + private boolean enabled = true; + + private Runnable onActionPerformed; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + int bg = background; + if (!enabled) { + bg = disabled; + } else if (getTooltipsOpen() > 0) { + } else if (isclicked) { + bg = clicked; + } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { + bg = hover; + } + if (roundness == 0) { + if (((border >> 24) & 0xFF) == 0) + Gui.drawRect(0, 0, getBounds().width, getBounds().height, bg); + else { + Gui.drawRect(0, 0, getBounds().width, getBounds().height, border); + Gui.drawRect(1, 1, getBounds().width - 1, getBounds().height - 1, bg); + } + } else { + if (((border >> 24) & 0xFF) == 0) + RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, bg); + else { + RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, border); + RenderUtils.drawRoundedRectangle(1, 1, getBounds().width-2, getBounds().height-2, roundness, Math.PI/8, bg); + } + GlStateManager.enableTexture2D(); + } + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(getText()); + int x = (getBounds().width - width) / 2; + int y = (getBounds().height - renderer.FONT_HEIGHT) / 2 + 1; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + renderer.drawString(getText(), x,y, foreground.getRGB()); + } + + boolean isclicked = false; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { + isclicked = true; + if (onActionPerformed != null) + onActionPerformed.run(); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); + } + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + isclicked = false; + } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY) && enabled) + setCursor(EnumCursor.POINTING_HAND); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MCollapsable.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MCollapsable.java new file mode 100644 index 00000000..f665ee15 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MCollapsable.java @@ -0,0 +1,137 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +/** + * Note it is passive. + */ +public class MCollapsable extends MPanel { + @Getter + @Setter + private boolean collapsed = true; + + private MPanel representing; + @Getter + private MList lowerElements; + + @Getter @Setter + private int leftPad = 0, leftPadElements = 13; + + private Runnable onPreferedSizeChange; + + public MCollapsable(MPanel representing, Runnable onPreferedSizeChange) { + this.representing = representing; + super.add(representing); + lowerElements = new MList(); + lowerElements.setGap(0); + super.add(lowerElements); + + this.onPreferedSizeChange = onPreferedSizeChange; + } + + @Override + public Dimension getPreferredSize() { + Dimension rep = representing.getPreferredSize(); + if (collapsed) { + return new Dimension(rep.width+leftPad+10, rep.height); + } else { + Dimension lowerElem = lowerElements.getPreferredSize(); + return new Dimension(Math.max(rep.width+leftPad+10, leftPadElements + lowerElem.width), rep.height+lowerElem.height+lowerElements.getGap()); + } + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + Dimension representingSize =this.representing.getPreferredSize(); + Dimension lowerSize = lowerElements.getPreferredSize(); + + representing.setBounds(new Rectangle(new Point(leftPad+10, 0), new Dimension(bounds.width - (leftPad+10), representingSize.height))); + lowerElements.setBounds(new Rectangle(new Point(leftPadElements, representingSize.height+lowerElements.getGap()), new Dimension(bounds.width - (leftPadElements), lowerSize.height))); + lowerElements.realignChildren(); + } + + @Override + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { + super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); + + clip(lastAbsClip.x, lastAbsClip.y, lastAbsClip.width, lastAbsClip.height); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + + GlStateManager.pushMatrix(); + + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + if (collapsed) { + GlStateManager.translate(leftPad + 10 - fr.getStringWidth(">"),(bounds.height - fr.FONT_HEIGHT)/2,0); + } else { + GlStateManager.translate(leftPad + fr.FONT_HEIGHT,(representing.getPreferredSize().height - fr.getStringWidth(">"))/2,0); + GlStateManager.rotate(90, 0,0,1); + } + + fr.drawString(">", 0,0, -1); + + + GlStateManager.popMatrix(); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } + + @Override + public void add(MPanel child) { + lowerElements.add(child); + if (onPreferedSizeChange != null) onPreferedSizeChange.run(); + } + + @Override + public void remove(MPanel panel) { + lowerElements.remove(panel); + if (onPreferedSizeChange != null) onPreferedSizeChange.run(); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (relMouseX >= leftPad && relMouseY >= 0 && relMouseX <= leftPad + 10 && relMouseY <= representing.getPreferredSize().height) { + collapsed = !collapsed; + if (onPreferedSizeChange != null) onPreferedSizeChange.run(); + } + } + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX, int relMouseY) { + if (relMouseX >= leftPad && relMouseY >= 0 && relMouseX <= leftPad + 10 && relMouseY <= representing.getPreferredSize().height) + setCursor(EnumCursor.POINTING_HAND); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MColor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MColor.java new file mode 100644 index 00000000..d7cccdc6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MColor.java @@ -0,0 +1,48 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +@AllArgsConstructor +@NoArgsConstructor +public class MColor extends MPanel { + @Getter + @Setter + private Color color = Color.white; + @Getter + @Setter + private Dimension size = new Dimension(20,15); + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Rectangle rectangle = getBounds(); + + int x = (rectangle.width - getSize().width) / 2; + int y = (rectangle.height - getSize().height) / 2; + + Gui.drawRect(x,y,x+getSize().width,y+getSize().height, getColor().getRGB()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MEditableAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MEditableAColor.java new file mode 100644 index 00000000..b33a2b48 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MEditableAColor.java @@ -0,0 +1,106 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +@AllArgsConstructor +@NoArgsConstructor +public class MEditableAColor extends MPanel { + @Getter + @Setter + private AColor color = new AColor(0xffffffff, true); + @Getter + @Setter + private Dimension size = new Dimension(20,15); + + @Getter + private boolean enableEdit = false; + + @Getter + @Setter + private Runnable onUpdate; + + public void setEnableEdit(boolean enableEdit) { + this.enableEdit = enableEdit; + if (portable != null && !enableEdit) { + remove(portable); + portable = null; + } + } + + private MPortableColorEdit portable = null; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Rectangle rectangle = getBounds(); + + int x = (rectangle.width - getSize().width) / 2; + int y = (rectangle.height - getSize().height) / 2; + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + Gui.drawRect(x,y,x+getSize().width,y+getSize().height, RenderUtils.getColorAt(absMousex - relMousex0, absMousey - relMousey0, color)); + + Gui.drawRect(x,y,x+getSize().width,y+1, 0xff333333); + Gui.drawRect(x,y,x+1,y+getSize().height, 0xff333333); + Gui.drawRect(x+getSize().width-1,y,x+getSize().width,y+getSize().height, 0xff333333); + Gui.drawRect(x,y+getSize().height-1,x+getSize().width,y+getSize().height, 0xff333333); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!enableEdit) return; + if (lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { + portable = new MPortableColorEdit() { + @Override + public void update2() { + super.update2(); + MEditableAColor.this.color = portable.getColor(); + if (onUpdate != null) + onUpdate.run(); + } + }; + portable.setColor(color); + Rectangle startWith = new Rectangle((int)(absMouseX * getScale()), (int) (absMouseY* getScale()), (int) (100 * getScale()), (int) (90 * getScale())); + if (startWith.x < 10) startWith.x = 10; + if (startWith.y < 10) startWith.y = 10; + if (startWith.x + startWith.width > Minecraft.getMinecraft().displayWidth - 10) startWith.x = Minecraft.getMinecraft().displayWidth - 10 - startWith.width; + if (startWith.y + startWith.height > Minecraft.getMinecraft().displayHeight - 10) startWith.y = Minecraft.getMinecraft().displayHeight - 10 - startWith.height; + portable.setBounds(startWith); + + + portable.setScale(2.0f); + portable.open(this); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MFloatSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MFloatSelectionButton.java new file mode 100755 index 00000000..1bda009c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MFloatSelectionButton.java @@ -0,0 +1,97 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; + +@Getter +@Setter +public class MFloatSelectionButton extends MPanel { + + private float data; + + private MButton dec; + private MButton inc; + private MTextField selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MFloatSelectionButton(float data2) { + this.data = data2; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MTextField() { + @Override + public String getText() { + return data +""; + } + @Override + public void edit(String str) { + try { + data = Float.parseFloat(str); + onUpdate.run(); + } catch (Exception e) {} + } + }; updateSelected(); add(selected); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data--; + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data ++; + updateSelected(); + onUpdate.run(); + } + }); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(-1,15); + } + + public float getSelected() { + return data; + } + + public void updateSelected() { + selected.setText(data+""); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); + inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); + selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MIntegerSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MIntegerSelectionButton.java new file mode 100755 index 00000000..6d17aebf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MIntegerSelectionButton.java @@ -0,0 +1,95 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import org.lwjgl.input.Keyboard; + +import java.awt.*; + +@Getter +@Setter +public class MIntegerSelectionButton extends MPanel { + + private int data; + + private MButton dec; + private MButton inc; + private MTextField selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MIntegerSelectionButton(int data2) { + this.data = data2; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MTextField() { + @Override + public void edit(String str) { + try { + data = Integer.parseInt(str); + onUpdate.run(); + } catch (Exception e) {} + } + }; updateSelected(); add(selected); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data -= (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ? 5 : 1); + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data += (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ? 5 : 1); + updateSelected(); + onUpdate.run(); + } + }); + } + + + @Override + public Dimension getPreferredSize() { + return new Dimension(-1,15); + } + + public int getSelected() { + return data; + } + + private void updateSelected() { + selected.setText(data+""); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); + inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); + selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MKeyEditButton.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MKeyEditButton.java new file mode 100755 index 00000000..70330f03 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MKeyEditButton.java @@ -0,0 +1,147 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +@Getter +@Setter +public class MKeyEditButton extends MPanel { + private int key; + private Runnable onKeyEdit; + + private Color foreground = Color.white; + private int background = RenderUtils.blendAlpha(0xFF141414, 0.08f); + private int hover = RenderUtils.blendAlpha(0xFF141414, 0.14f); + private int clicked = RenderUtils.blendAlpha(0xFF141414, 0.16f); + private int border = 0x0; + private int disabled =0xFF141414; + private int roundness = 0; + + private boolean enabled = true; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + int bg = background; + if (!enabled) { + bg = disabled; + } else if (getTooltipsOpen() > 0) { + } else if (selected) { + bg = clicked; + } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { + bg = hover; + } + if (roundness == 0) { + if (((border >> 24) & 0xFF) == 0) + Gui.drawRect(0, 0, getBounds().width, getBounds().height, bg); + else { + Gui.drawRect(0, 0, getBounds().width, getBounds().height, border); + Gui.drawRect(1, 1, getBounds().width - 1, getBounds().height - 1, bg); + } + } else { + if (((border >> 24) & 0xFF) == 0) + RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, bg); + else { + RenderUtils.drawRoundedRectangle(0, 0, getBounds().width, getBounds().height, roundness, Math.PI/8, border); + RenderUtils.drawRoundedRectangle(1, 1, getBounds().width-2, getBounds().height-2, roundness, Math.PI/8, bg); + } + GlStateManager.enableTexture2D(); + } + + String str = GameSettings.getKeyDisplayString(key); + if (selected) str = "> "+str+" <"; + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(str); + int x = (getBounds().width - width) / 2; + int y = (getBounds().height - renderer.FONT_HEIGHT) / 2 + 1; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + renderer.drawString(str, x,y, foreground.getRGB()); + } + + private boolean selected; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { + if (selected) { + key = -100 + mouseButton; + selected = false; + if (onKeyEdit != null) + onKeyEdit.run(); + } else { + selected = true; + } + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); + } else { + selected = false; + } + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + + } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY) && enabled) + setCursor(EnumCursor.POINTING_HAND); + } + + @Override + public void keyPressed(char typedChar, int keyCode) { + if (!selected) return; + if (keyCode == 1) { + key = 0; + } else if (keyCode != 0) { + key = keyCode; + } else if (typedChar > 0) { + key = typedChar + 256; + } + selected = false; + if (onKeyEdit != null) + onKeyEdit.run(); + throw new RuntimeException("hack to stop event propagation"); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(80, 15); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MLabel.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MLabel.java new file mode 100755 index 00000000..a7fc06c1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MLabel.java @@ -0,0 +1,72 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +public class MLabel extends MPanel { + @Getter + @Setter + private String text; + + @Getter + @Setter + private Color foreground = Color.white; + + public enum Alignment { + LEFT, CENTER, RIGHT + } + @Getter + @Setter + private Alignment alignment= Alignment.LEFT; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(getText()); + int x,y; + if (alignment == Alignment.CENTER) { + x = (getBounds().width - width) / 2; + y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + } else if (alignment == Alignment.LEFT) { + x = 0; + y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + } else if (alignment == Alignment.RIGHT) { + x = getBounds().width - width; + y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + } else{ + return; + } + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + renderer.drawString(getText(), x,y, 0xffffffff); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MLabelAndElement.java new file mode 100755 index 00000000..20f2aa93 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MLabelAndElement.java @@ -0,0 +1,75 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MLabelAndElement extends MPanel { + private final MLabel label; + private final MPanel element; + + @Getter @Setter + private Color hover; + @Getter @Setter + private Runnable onClick; + + public MLabelAndElement(String label, MPanel element) { + this.add(this.label = new MLabel()); + this.label.setText(label); + this.add(element); + this.element = element; + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(200, 30); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (onClick!= null && lastAbsClip.contains(absMouseX, absMouseY)) { + onClick.run(); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + label.setBounds(new Rectangle(0,0,parentHeight / 3, getBounds().height)); + element.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); + element.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MList.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MList.java new file mode 100644 index 00000000..bfdcae26 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MList.java @@ -0,0 +1,93 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MList extends MPanel { + @Getter + private int gap = 5; + + @Getter @Setter + private boolean drawLine = true; + + public void setGap(int gap) { + this.gap = gap; + realignChildren(); + } + + @Getter @Setter + private int gapLineColor = 0xFFFFFFFF; + + public void realignChildren() { + int y = 0; + for (MPanel childComponent : getChildComponents()) { + Dimension preferedSize = childComponent.getPreferredSize(); + int height = Math.max(10, preferedSize.height); + childComponent.setBounds(new Rectangle(0, y, bounds.width, height)); + y += height; + if (gap > 0) + y += gap; + } + setSize(new Dimension(getSize().width, Math.max(0, y-gap))); + } + + @Override + public Dimension getPreferredSize() { + int maxW = 0; + int h = 0; + for (MPanel childComponent : getChildComponents()) { + Dimension preferedSize = childComponent.getPreferredSize(); + int height = Math.max(10, preferedSize.height); + if (preferedSize.width > maxW) maxW = preferedSize.width; + h += height; + if (gap > 0) h += gap; + } + return new Dimension(maxW, Math.max(0, h-gap)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (gap <= 0) return; + if (!drawLine) return; + for (int i = 1; i < getChildComponents().size(); i++) { + MPanel panel = getChildComponents().get(i); + Rectangle bound = panel.getBounds(); + int top = bound.y - (int)Math.ceil(gap/2.0); + Gui.drawRect(0, top, getBounds().width, top + 1, gapLineColor); + } + } + + @Override + public void add(MPanel child) { + super.add(child); + realignChildren(); + } + + @Override + public void remove(MPanel panel) { + super.remove(panel); + realignChildren(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModal.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModal.java new file mode 100644 index 00000000..1a2abc6e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModal.java @@ -0,0 +1,92 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; + +import java.awt.*; + +public class MModal extends MTooltip { + @Getter + private MPanel modalContent = new MPanel(); + + @Getter @Setter + private String title = "Default Title"; + + public MModal() { + super.add(modalContent); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + super.resize(parentWidth, parentHeight); + setBounds(new Rectangle(0,0, parentWidth, parentHeight)); + } + + @Getter @Setter + private Dimension modalSize = new Dimension(300,200); + + + @Override + public void onBoundsUpdate() { + super.onBoundsUpdate(); + Dimension effDim = getEffectiveDimension(); + + modalContent.setBounds(new Rectangle((effDim.width - modalSize.width)/2, (effDim.height - modalSize.height)/2 + 16, modalSize.width, modalSize.height-16)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + RenderUtils.drawGradientRect(0, 0, bounds.width, bounds.height, -1072689136, -804253680); + Dimension effDim = getEffectiveDimension(); + int x = (effDim.width-modalSize.width)/2; + int y = (effDim.height - modalSize.height)/2; + GlStateManager.translate(x,y, 0); + RenderUtils.drawRoundedRectangle(0,0,modalSize.width, modalSize.height, 3, Math.PI/8, RenderUtils.blendAlpha(0x141414, 0.20f)); + Gui.drawRect(0,15, modalSize.width, 16, 0xFF02EE67); + Gui.drawRect(0,16,modalSize.width, 26, RenderUtils.blendAlpha(0x141414, 0.1f)); + RenderUtils.drawRoundedRectangle(0,16,modalSize.width, modalSize.height-16, 3, Math.PI/8, RenderUtils.blendAlpha(0x141414, 0.1f)); + + GlStateManager.enableTexture2D(); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString(title, 5,(16-fr.FONT_HEIGHT)/2, -1); + } + + @Override + public void add(MPanel child) { + modalContent.add(child); + } + + protected void addSuper(MPanel child) { + super.add(child); + } + + @Override + public void remove(MPanel panel) { + modalContent.remove(panel); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModalConfirmation.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModalConfirmation.java new file mode 100644 index 00000000..746d1afa --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModalConfirmation.java @@ -0,0 +1,87 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class MModalConfirmation extends MModal { + private String content; + private Runnable callBackYes; + private Runnable callBackNo; + @Getter + private MButton yes, no; + public MModalConfirmation(String title, String content, Runnable callBackYes, Runnable callBackNo) { + super(); + setTitle(title); + this.content = content; + this.callBackYes = callBackYes; + this.callBackNo = callBackNo; + this.yes = new MButton(); + this.no = new MButton(); + yes.setText("Yes"); no.setText("No"); + no.setBackground(RenderUtils.blendAlpha(0x141414, 0.15f)); + no.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); + yes.setOnActionPerformed(() -> { + close(); + if (callBackYes != null) callBackYes.run(); + }); + no.setOnActionPerformed(() -> { + close(); + if (callBackNo != null) callBackNo.run(); + }); + yes.setBackground(RenderUtils.blendAlpha(0x141414, 0.15f)); + yes.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); + + add(new ConfirmationContent()); + } + + public class ConfirmationContent extends MPanel { + public ConfirmationContent() { + add(yes); add(no); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + GlStateManager.translate(5,5,0); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GL11.glDisable(GL11.GL_SCISSOR_TEST); + fr.drawSplitString(content, 0,0, ConfirmationContent.this.bounds.width-10, -1); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + yes.setBounds(new Rectangle(10,bounds.height-25,(bounds.width-30)/2, 15)); + no.setBounds(new Rectangle(yes.getBounds().x + yes.getBounds().width + 10,bounds.height-25,(bounds.width-30)/2, 15)); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModalMessage.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModalMessage.java new file mode 100644 index 00000000..1973e239 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MModalMessage.java @@ -0,0 +1,77 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class MModalMessage extends MModal { + private String content; + private Runnable callBackOk; + @Getter + private MButton yes; + public MModalMessage(String title, String content, Runnable callBackOk) { + super(); + setTitle(title); + this.content = content; + this.callBackOk = callBackOk; + this.yes = new MButton(); + yes.setText("Ok"); + yes.setOnActionPerformed(() -> { + close(); + if (callBackOk != null) callBackOk.run(); + }); + yes.setBackground(RenderUtils.blendAlpha(0x141414, 0.15f)); + yes.setHover(RenderUtils.blendAlpha(0x141414, 0.17f)); + + add(new MessageContent()); + } + + public class MessageContent extends MPanel { + public MessageContent() { + add(yes); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + GlStateManager.translate(5,5,0); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + GL11.glDisable(GL11.GL_SCISSOR_TEST); + fr.drawSplitString(content, 0,0, MModalMessage.MessageContent.this.bounds.width-10, -1); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + yes.setBounds(new Rectangle(10,bounds.height-25,(bounds.width-20), 15)); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MNavigatingPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MNavigatingPane.java new file mode 100755 index 00000000..76de53d5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MNavigatingPane.java @@ -0,0 +1,213 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import com.google.common.base.Function; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class MNavigatingPane extends MPanel { + + private final Map pages = new HashMap(); + private final List bookMarks = new ArrayList(); + + @Getter + @Setter + private Function pageGenerator; + + @Getter + private String currentPage = ""; + + public void setCurrentPage(String currentPage) { + this.history.push(this.currentPage); + this.currentPage = currentPage; + } + + @Getter + private Color background2; + + private final Stack history = new Stack(); + + private final MButton back = new MButton(); + + public MNavigatingPane() { + back.setText("<"); + back.setOnActionPerformed(new Runnable() { + @Override + public void run() { + if (history.size() > 0) + currentPage = history.pop(); + } + }); + back.setBackgroundColor(Color.darkGray); + back.setBounds(new Rectangle(3,18,12,12)); + add(back); + } + + public void setBackground2(Color background2) { + this.background2 = background2; + for (MPanel value : pages.values()) { + value.setBackgroundColor(background2); + } + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + + Gui.drawRect(0, 15, getBounds().width, getBounds().height, 0xFF444444); + Gui.drawRect(1, 16, getBounds().width-1, getBounds().height-1, background2 != null ? background2.getRGB() : 0); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(currentPage.replace(".", " > "), 20, 20, 0xFFFFFFFF); + + } + + public void addBookmark(String name, String addr) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + MTabButton button = new MTabButton(this, name, addr); + int totalX = 0; + for (MTabButton button1:bookMarks) + totalX += button1.getBounds().width; + button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(name) + 6), 15)); + bookMarks.add(button); + if (currentPage.isEmpty()) + currentPage = addr; + } + public void addBookmarkRunnable(String name, final Runnable toRun) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + MTabButton button = new MTabButton(this, name, null) { + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY)) { + toRun.run(); + } + } + }; + int totalX = 0; + for (MTabButton button1:bookMarks) + totalX += button1.getBounds().width; + button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(name) + 6), 15)); + bookMarks.add(button); + } + + @Override + public List getChildComponents() { + ArrayList dynamic = new ArrayList(bookMarks); + if (!pages.containsKey(currentPage)) { + MPanel panel = pageGenerator.apply(currentPage); + MPanel panel2 = new MPanel() ; + if (panel != null) + panel2.add(panel); + panel2.setBackgroundColor(background2); + pages.put(currentPage, panel2); + panel2.setBounds(new Rectangle(1,30,getBounds().width-2, getBounds().height-31)); + panel2.setParent(this); + } + dynamic.add(pages.get(currentPage)); + dynamic.add(back); + return dynamic; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + for (MPanel ma:pages.values()) + ma.setBounds(new Rectangle(1,30,getBounds().width-2, getBounds().height-31)); + } + + @Override + public void setBounds(Rectangle bounds) { + if (bounds == null) return; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; + } + + @Getter + @Setter + public static class MTabButton extends MPanel { + private String text; + private String address; + + private Color foreground = Color.white; + private Color hover = new Color(154, 154, 154, 255); + private Color clicked = new Color(88, 88, 88,255); + private Color selected = new Color(111, 111, 111,255); + private Color disabled = new Color(0,0,0); + + private boolean enabled = true; + + private MNavigatingPane tabbedPane; + + public MTabButton(MNavigatingPane tabbedPane, String key, String address) { + this.tabbedPane = tabbedPane; + this.text = key; + this.address = address; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + Color bg = null; + if (!enabled) { + bg = disabled; + } else if (tabbedPane.getCurrentPage().equals(address)) { + bg = selected; + } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { + bg = hover; + } + Gui.drawRect(0, tabbedPane.getCurrentPage().equals(address) ? 0 : 2, getBounds().width, getBounds().height, 0xFF444444); + if (bg != null) + Gui.drawRect(1,tabbedPane.getCurrentPage().equals(address) ? 1 : 3,getBounds().width - 1, getBounds().height, bg.getRGB()); + + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(text); + int x = (getBounds().width - width) / 2; + int y = (getBounds().height - 3 - renderer.FONT_HEIGHT) / 2 + 3; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + renderer.drawString(text, x,y, foreground.getRGB()); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY)) { + tabbedPane.setCurrentPage(address); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPanelScaledGUI.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPanelScaledGUI.java new file mode 100644 index 00000000..0941116a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPanelScaledGUI.java @@ -0,0 +1,213 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class MPanelScaledGUI extends MPanel { + @Getter + protected double scale = 1.0; + @Getter + protected double relativeScale; + + public void setScale(double scale) { + this.scale = scale; + for (MPanel childComponent : childComponents) { + childComponent.resize0((int) (getBounds().width/scale), (int) (getBounds().height/scale)); + } + onBoundsUpdate(); + } + + @Override + public void setBounds(Rectangle bounds) { + if (bounds == null) return; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; + + for (MPanel childComponent : childComponents) { + childComponent.resize0((int) (getBounds().width/scale), (int) (getBounds().height/scale)); + } + onBoundsUpdate(); + } + + public Dimension getEffectiveDimension() { + return new Dimension((int)(getBounds().width / scale), (int)(getBounds().height / scale)); + } + + @Override + public void render0(double parentScale, Point parentPoint, Rectangle parentClip, int absMousex0, int absMousey0, int relMousex0, int relMousey0, float partialTicks) { + lastParentPoint = parentPoint; + + GlStateManager.translate(getBounds().x, getBounds().y, 5); + GlStateManager.color(1,1,1,1); + + Rectangle absBound = getBounds().getBounds(); + absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); + + Rectangle clip; + if (isIgnoreBoundOnClip()) clip = parentClip; + else clip = determineClip(parentClip, absBound); + lastAbsClip = clip; + + if (clip.getSize().height * clip.getSize().width == 0) return; + + int absMousex = (int) (absMousex0 / scale), absMousey = (int) (absMousey0 / scale); + int relMousex = (int) ((relMousex0 - getBounds().x) / scale); + int relMousey = (int) ((relMousey0 - getBounds().y) /scale); + + // FROM HERE, IT IS SCALED + + GlStateManager.scale(this.scale, this.scale, 1); + clip = new Rectangle((int) (clip.x / scale), (int) (clip.y / scale), (int) (clip.width / scale), (int) (clip.height / scale)); + lastAbsClip = clip; + + + this.relativeScale = parentScale * this.scale; + clip(clip.x, clip.y, clip.width, clip.height); + + + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + + GuiScreen.drawRect(0,0, (int) (getBounds().width / scale), (int) (getBounds().height / scale), backgroundColor.getRGB()); + GlStateManager.enableBlend(); + + + GlStateManager.pushMatrix(); + + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + + render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); + + GlStateManager.popMatrix(); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + + + Point newPt = new Point((int) ((parentPoint.x + getBounds().x) / scale), (int) ((parentPoint.y + getBounds().y) / scale)); + + for (MPanel mPanel : getChildComponents()){ + GlStateManager.pushMatrix(); + + mPanel.render0(relativeScale, newPt,clip,absMousex, absMousey, relMousex, relMousey, partialTicks); + + GlStateManager.popMatrix(); + } + } + + @Override + public void clip(int x, int y, int width, int height) { + if (width < 0 || height < 0) return; + + GL11.glScissor((int) (x * relativeScale), Minecraft.getMinecraft().displayHeight - (int) ((y + height+1) * relativeScale), (int)((width+1)* relativeScale), (int) ((height+1) * relativeScale)); + } + + @Override + public void resize0(int parentWidth, int parentHeight) { + super.resize0(parentWidth, parentHeight); + } + + + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + boolean noClip = true; + boolean focusedOverall = false; + for (MPanel childComponent : getChildComponents()) { + if (childComponent.mouseClicked0(absMouseX, absMouseY,relMousex, relMousey, mouseButton)) { + noClip = false; + focusedOverall = true; + } + } + + if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { + isFocused = true; + focusedOverall = true; + } else { + isFocused = false; + } + mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); + + return focusedOverall; + } + public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseReleased0(absMouseX, absMouseY, relMousex, relMousey, state); + } + mouseReleased(absMouseX, absMouseY, relMousex, relMousey, state); + } + public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseClickMove0(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); + } + mouseClickMove(absMouseX, absMouseY, relMousex, relMousey, clickedMouseButton, timeSinceLastClick); + } + public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseScrolled0(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); + } + mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); + } + + @Override + public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + mouseMoved(absMouseX, absMouseY, relMousex, relMousey); + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseMoved0(absMouseX, absMouseY, relMousex, relMousey); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MParameter.java new file mode 100755 index 00000000..72f64de1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MParameter.java @@ -0,0 +1,90 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonParameterEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.panes.DynamicEditor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MParameter extends MPanel { + private final MLabel label; + private final MLabel data; + + @Getter @Setter + private Color hover = Color.gray; + + @Getter @Setter + private Parameter parameter; + private final DynamicEditor processorParameterEditPane; + + public MParameter(final Parameter parameter, DynamicEditor processorParameterEditPane) { + this.processorParameterEditPane = processorParameterEditPane; + this.add(this.label = new MLabel() { + @Override + public String getText() { + return parameter.getName(); + } + }); + this.add(this.data = new MLabel() { + @Override + public String getText() { + return parameter.getNewData() != null ?parameter.getNewData().toString() :"-empty-"; + } + }); + this.label.setAlignment(MLabel.Alignment.LEFT); + this.data.setAlignment(MLabel.Alignment.RIGHT); + + this.parameter = parameter; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (this.getBounds().x > -20 && lastAbsClip.contains(absMouseX, absMouseY)) { + // open new gui; + EditingContext.getEditingContext().openGui(new GuiDungeonParameterEdit(this, processorParameterEditPane)); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + label.setBounds(new Rectangle(0,0,parentHeight / 3, getBounds().height)); + data.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width / 3, getBounds().height)); + data.setBounds(new Rectangle(getBounds().width / 3,0,getBounds().width / 3 * 2, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPassiveLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPassiveLabelAndElement.java new file mode 100755 index 00000000..9a4cd791 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPassiveLabelAndElement.java @@ -0,0 +1,71 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MPassiveLabelAndElement extends MPanel { + private final MLabel label; + private final MPanel element; + + @Getter @Setter + private Color hover; + @Getter @Setter + private Runnable onClick; + + @Getter @Setter + private double divideRatio = 1/3.0; + + public MPassiveLabelAndElement(String label, MPanel element) { + this.add(this.label = new MLabel()); + this.label.setText(label); + this.add(element); + this.element = element; + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(100, 20); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (onClick!= null && lastAbsClip.contains(absMouseX, absMouseY)) { + onClick.run(); + } + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0, (int) (getBounds().width * divideRatio), getBounds().height)); + element.setBounds(new Rectangle((int) (getBounds().width * divideRatio),0, (int) (getBounds().width * (1-divideRatio)), getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPopupMenu.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPopupMenu.java new file mode 100644 index 00000000..bc2a656b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPopupMenu.java @@ -0,0 +1,97 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.util.List; + +public class MPopupMenu extends MTooltip { + private int x, y; + public MPopupMenu(int x, int y, List popupMenuElementList) { + this.x = x; this.y = y; + int maxWidth = 150; + for (MPanel mPanel : popupMenuElementList) { + Dimension dimension = mPanel.getPreferredSize(); + if (dimension.width > maxWidth) maxWidth = dimension.width; + } + int h1 = 7; + for (MPanel mPanel : popupMenuElementList) { + Dimension dimension = mPanel.getPreferredSize(); + mPanel.setBounds(new Rectangle(7,h1, maxWidth-13, dimension.height)); + h1 += dimension.height + 7; + add(mPanel); + } + + if (y + h1 > Minecraft.getMinecraft().displayHeight) + y = Minecraft.getMinecraft().displayHeight - h1; + if (x + maxWidth+ 2 > Minecraft.getMinecraft().displayWidth) + x = Minecraft.getMinecraft().displayWidth - maxWidth-2; + setBounds(new Rectangle(x,y,maxWidth+2, h1)); + } + + @Override + public void setScale(double scale) { + super.setScale(scale); + + int maxWidth = 150; + for (MPanel mPanel : getChildComponents()) { + Dimension dimension = mPanel.getPreferredSize(); + if (dimension.width > maxWidth) maxWidth = dimension.width; + } + int h1 = 7; + for (MPanel mPanel : getChildComponents()) { + Dimension dimension = mPanel.getPreferredSize(); + mPanel.setBounds(new Rectangle(7,h1, maxWidth-13, dimension.height)); + h1 += dimension.height + 7; + } + maxWidth += 2; + maxWidth *= scale; h1 *= scale; + + if (y + h1 > Minecraft.getMinecraft().displayHeight) + y = Minecraft.getMinecraft().displayHeight - h1; + if (x + maxWidth > Minecraft.getMinecraft().displayWidth) + x = Minecraft.getMinecraft().displayWidth - maxWidth; + setBounds(new Rectangle(x,y,maxWidth, h1)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); + int radius = 7; + double deltaDegree = Math.PI/6; + Dimension effectiveDim = getEffectiveDimension(); + RenderUtils.drawRoundedRectangle(0,0,effectiveDim.width,effectiveDim.height,radius,deltaDegree, RenderUtils.blendAlpha(0x121212, 0.0f)); + for (int i = 1; i < getChildComponents().size(); i++) { + MPanel childComponent = getChildComponents().get(i); + Gui.drawRect(7,childComponent.getBounds().y - 4, effectiveDim.width-7, childComponent.getBounds().y - 3, RenderUtils.blendAlpha(0x121212, 0.10f)); + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!lastAbsClip.contains(absMouseX, absMouseY)) { + close(); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPortableColorEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPortableColorEdit.java new file mode 100644 index 00000000..d86a07ee --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MPortableColorEdit.java @@ -0,0 +1,292 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.MathHelper; +import org.apache.commons.lang3.StringUtils; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class MPortableColorEdit extends MTooltip { + + private final float[] hsv = new float[3]; + private float alpha = 0; + private float chromaSpeed = 0; + + @Getter + private AColor color; + + private final MTextField textField; + + public MPortableColorEdit() { + textField = new MTextField() { + @Override + public void edit(String str) { + if (str.length() >= 7 && str.startsWith("#")) { + String color = str.substring(1); + try { + long colorInt = Long.parseLong(color, 16); + + Color.RGBtoHSB((int) (colorInt >> 16) & 0xFF, (int) (colorInt >> 8) & 0xFF, (int) colorInt & 0xFF, hsv); + if (color.length() >= 8) + alpha = ((int) ((colorInt >> 24) & 0xFF)) / 255.0f; + update2(); + } catch (Exception e) {} + } + } + }; + add(textField); + } + + @Override + public void onBoundsUpdate() { + super.onBoundsUpdate(); + + textField.setBounds(new Rectangle(5, getEffectiveDimension().height - 25, getEffectiveDimension().width - 10, 20)); + } + + public void setColor(AColor color) { + this.color = color; + + alpha = color.getAlpha() / 255.0f; + chromaSpeed = color.isChroma() ? color.getChromaSpeed() : 0; + Color.RGBtoHSB(color.getRed(), color.getBlue(), color.getGreen(), hsv); + + int rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); + rgb = (rgb & 0xFFFFFF) | ((int)(alpha * 255) << 24); + textField.setText("#" + StringUtils.leftPad(Integer.toHexString(rgb).toUpperCase(), 8, '0')); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Dimension size = getEffectiveDimension(); + + Gui.drawRect(0,0,size.width,size.height, 0xff333333); + Gui.drawRect(1,1,size.width-1,size.height-1, 0xffa1a1a1); + + int width = size.height- 35; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + int shademodel = GL11.glGetInteger(GL11.GL_SHADE_MODEL); + GlStateManager.shadeModel(GL11.GL_SMOOTH); + GlStateManager.enableBlend(); + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + // worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); + + int rgb = Color.HSBtoRGB(hsv[0], hsv[1], 1); + float r = (rgb >> 16 & 255) / 255.0f; + float g = (rgb >> 8 & 255) / 255.0f; + float b = (rgb & 255) / 255.0f; + GL11.glBegin(GL11.GL_TRIANGLES); + GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(15+width ,5, 0); + GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(10+width , 5, 0); + GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(15+width , 5+width, 0); + + GlStateManager.color(0,0,0,alpha); GL11.glVertex3i(10+width , 5, 0); + GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(10+width , 5 + width, 0); + GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(15+width , 5+width, 0); + GL11.glEnd(); + rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); + r = (rgb >> 16 & 255) / 255.0f; + g = (rgb >> 8 & 255) / 255.0f; + b = (rgb & 255) / 255.0f; + GL11.glBegin(GL11.GL_TRIANGLES); + GlStateManager.color(r,g,b,0);GL11.glVertex3i(25+width ,5, 0); + GlStateManager.color(r,g,b,0);GL11.glVertex3i(20+width , 5, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 5+width, 0); + + GlStateManager.color(r,g,b,0); GL11.glVertex3i(20+width , 5, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(20+width , 5+ width, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 5+width, 0); + GL11.glEnd(); + + + GL11.glBegin(GL11.GL_TRIANGLES); + rgb = RenderUtils.getChromaColorAt(0,0, chromaSpeed, hsv[1], hsv[2], alpha); + r = (rgb >> 16 & 255) / 255.0f; + g = (rgb >> 8 & 255) / 255.0f; + b = (rgb & 255) / 255.0f; + GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width ,5, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(30+width , 5, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width , 5+width, 0); + + GlStateManager.color(r,g,b,1); GL11.glVertex3i(30+width , 5, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(30+width , 5+ width, 0); + GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width , 5+width, 0); + GL11.glEnd(); + + + + float radius = width/2f; + float cx = 5 + radius; + float cy = 5 + radius; + + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GlStateManager.color(1,1,1,alpha); + GL11.glVertex3f(cx,cy,0); + for (int i = 0; i <= 360; i++) { + float rad = 3.141592653f * i / 180; + int rgb2 = Color.HSBtoRGB(i / 360f, 1, hsv[2]); + float r2 = (rgb2 >> 16 & 255) / 255.0f; + float g2 = (rgb2 >> 8 & 255) / 255.0f; + float b2 = (rgb2 & 255) / 255.0f; + GlStateManager.color(r2,g2,b2, alpha); + GL11.glVertex3f(MathHelper.sin(rad) * radius + cx, MathHelper.cos(rad) * radius + cy, 0); + } + GL11.glEnd(); + GlStateManager.shadeModel(shademodel); + + GlStateManager.color(1,1,1,1); + worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); + float rad2 = 2 * 3.141592653f * hsv[0] ; + float x = 5 + radius + (MathHelper.sin(rad2)) * hsv[1] * radius; + float y = 5 + radius + (MathHelper.cos(rad2))* hsv[1] * radius; + for (int i = 0; i < 100; i++) { + float rad = 2 * 3.141592653f * (i / 100f); + worldrenderer.pos(MathHelper.sin(rad) * 2 + x, MathHelper.cos(rad) * 2 + y, 0).endVertex(); + } + tessellator.draw(); + + worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + worldrenderer.pos(8+width, 5 + (hsv[2]) * width, 0.5).endVertex(); + worldrenderer.pos(17+width, 5 + (hsv[2]) * width, 0.5).endVertex(); + tessellator.draw(); + + worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + worldrenderer.pos(18+width, 5 + (alpha) * width, 0.5).endVertex(); + worldrenderer.pos(27+width, 5 + (alpha) * width, 0.5).endVertex(); + tessellator.draw(); + + worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + worldrenderer.pos(28+width, 5 + (chromaSpeed) * width, 0.5).endVertex(); + worldrenderer.pos(37+width, 5 + (chromaSpeed) * width, 0.5).endVertex(); + tessellator.draw(); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.color(1,1,1,1); + GlStateManager.color(1,1,1,1); + } + + private int selected = 0; + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + int width = getEffectiveDimension().height- 35; + float radius = width / 2f; + float circleX = 5 + radius; + float circleY = 5 + radius; + + selected = 0; + if (!lastAbsClip.contains(absMouseX, absMouseY)) { + close(); + return; + } + + { + // check circle + float dx = relMouseX - circleX; + float dy = circleY - relMouseY; + if (dx * dx + dy * dy <= radius * radius) { + double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180+90) % 360; + hsv[0] = (float) theta / 360f; + hsv[1] = MathHelper.sqrt_float(dx * dx + dy * dy) / radius; + selected = 1; + } + } + { + if (10+width <= relMouseX && relMouseX <= 15 + width && + 5 <= relMouseY && relMouseY <= 5 + width) { + hsv[2] = (relMouseY - 5) / (float)width; + selected = 2; + } + } + { + if (20+width <= relMouseX && relMouseX <= 25 + width && + 5 <= relMouseY && relMouseY <= 5 + width) { + alpha = (relMouseY - 5) / (float)width; + selected = 3; + } + } + { + if (30+width <= relMouseX && relMouseX <= 35 + width && + 5 <= relMouseY && relMouseY <= 5 + width) { + chromaSpeed = (relMouseY - 5) / (float)width; + selected = 4; + } + } + update(); + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + int width = getEffectiveDimension().height- 35; + float radius = width / 2f; + float circleX = 5 + radius; + float circleY = 5 + radius; + { + // check circle + float dx = relMouseX - circleX; // sin theta + float dy = circleY - relMouseY; // cos theta + if (selected == 1) { + double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180+90) % 360; + hsv[0] = (float) theta / 360f; + hsv[1] = MathHelper.clamp_float(MathHelper.sqrt_float(dx * dx + dy * dy) / radius, 0, 1); + } + } + { + if (selected == 2) { + hsv[2] = MathHelper.clamp_float((relMouseY - 5) / (float)width, 0, 1); + } + if (selected == 3) { + alpha = MathHelper.clamp_float((relMouseY - 5) / (float)width, 0, 1); + } + if (selected == 4) { + chromaSpeed = MathHelper.clamp_float((relMouseY - 5) / (float)width, 0, 1); + } + } + update(); + } + + + public void update() { + int rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); + rgb = (rgb & 0xFFFFFF) | ((int)(alpha * 255) << 24); + textField.setText("#" + StringUtils.leftPad(Integer.toHexString(rgb).toUpperCase(), 8, '0')); + update2(); + } + + public void update2() { + color = new AColor(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0xffffff | (MathHelper.clamp_int((int)(alpha * 255), 0, 255) << 24), true); + color.setChromaSpeed(chromaSpeed); + color.setChroma(chromaSpeed != 0); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MRootPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MRootPanel.java new file mode 100644 index 00000000..949dd0d3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MRootPanel.java @@ -0,0 +1,60 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +@Getter +public class MRootPanel extends MPanel { + @Getter + private List tooltips = new CopyOnWriteArrayList<>(); + + + @Override + public void openTooltip(MTooltip mPanel) { + mPanel.setRoot(this); + tooltips.add(mPanel); + mPanel.resize(getBounds().width, getBounds().height); + add(mPanel); + } + + @Override + public int getTooltipsOpen() { + return tooltips.size(); + } + + public void removeTooltip(MTooltip mTooltip) { + mTooltip.setRoot(null); + tooltips.remove(mTooltip); + remove(mTooltip); + } + + @Getter @Setter + private EnumCursor currentCursor = EnumCursor.DEFAULT; + @Override + public void setCursor(EnumCursor enumCursor) { + currentCursor = enumCursor; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MScrollBar.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MScrollBar.java new file mode 100644 index 00000000..e8ea25bd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MScrollBar.java @@ -0,0 +1,209 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; +import net.minecraft.util.MathHelper; + +import java.awt.*; + +public class MScrollBar extends MPanel { + private final Axis axis; + + @Getter + private int thumbSize, max, min; + @Setter + @Getter + private int current; + + @Getter + @Setter + private int width = 10; + + public void setMax(int max) { + if (max < min) max = min; + this.max = max; + + current = MathHelper.clamp_int(current, min, max); + if (onUpdate != null) onUpdate.run(); + } + + public void setMin(int min) { + if (max < min) max = min; + this.min = min; + + current = MathHelper.clamp_int(current, min, max); + if (onUpdate != null) onUpdate.run(); + } + + public void setThumbSize(int thumbSize) { + this.thumbSize = thumbSize; + + current = MathHelper.clamp_int(current, min, max); + if (onUpdate != null) onUpdate.run(); + } + + public void addToCurrent(int dv) { + int current2 = current + dv; + + current = MathHelper.clamp_int(current2, min, max); + + if (onUpdate != null) onUpdate.run(); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(axis == Axis.X ? -1 : width, axis == Axis.Y ? -1 : width); + } + + @Getter + @Setter + private int background = RenderUtils.blendAlpha(0xFF141414, 0.04f), + thumb = RenderUtils.blendAlpha(0xFF141414, 0.14f), + thumbHover = RenderUtils.blendAlpha(0xFF141414, 0.15f), + thumbClick = RenderUtils.blendAlpha(0xFF141414, 0.20f); + + private Runnable onUpdate; + + public MScrollBar(int min, int max, int thumbSize, int current, Axis axis, Runnable onUpdate) { + if (max < min) max = min; + this.min = min; this.min = max; this.thumbSize = thumbSize; this.current = current; this.axis = axis; + this.current = MathHelper.clamp_int(current, min, max); + this.onUpdate = onUpdate; + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + lastThumbRect.width = 0; lastThumbRect.height = 0; + } + + private Rectangle lastThumbRect = new Rectangle(); + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + // RENDER SUPER NICE SCROLL BAR + int minimalThumbLen = 20; + + Gui.drawRect(0,0,getBounds().width, getBounds().height, background); + int length = axis == Axis.X ? bounds.width :bounds.height; + int totalUnscaledLength = max-min + thumbSize; + double subPoint = ((double)max-min) * length / totalUnscaledLength; + if (length - subPoint < minimalThumbLen) { + subPoint = length - minimalThumbLen; + } + double thumbSize = length - subPoint; + + double startPt; + if (max - min == 0) { + startPt =0; + } else { + startPt = subPoint * (current - min)/((double)max - min); + } + + int color = thumbHover; + if (getBounds().contains(relMousex0, relMousey0)) color = thumbHover; + if (grabbed) color = thumbClick; + + if (axis == Axis.X) { + int startX = (int) startPt; + int endX = (int) (startPt + thumbSize); + + Gui.drawRect(startX,0,endX,getBounds().height, color); + lastThumbRect.x = startX; lastThumbRect.y = 0; lastThumbRect.width = endX - startX; lastThumbRect.height = getBounds().height; + } else if (axis == Axis.Y) { + int startY = (int) startPt; + int endY = (int) (startPt + thumbSize); + + Gui.drawRect(0,startY,getBounds().width,endY, color); + lastThumbRect.x = 0; lastThumbRect.y = startY; lastThumbRect.width = getBounds().width; lastThumbRect.height = endY - startY; + } + } + + private int lastX; + private int lastY; + private int actualValue; + private boolean grabbed; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (!lastAbsClip.contains(absMouseX, absMouseY)) return; + if (getTooltipsOpen() > 0) return; + grabbed = true; + actualValue = current; + lastX = absMouseX; + lastY = absMouseY; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + if (!grabbed) return; + + int minimalThumbLen = 20; + + Gui.drawRect(0,0,getBounds().width, getBounds().height, background); + int length = axis == Axis.X ? bounds.width :bounds.height; + int totalUnscaledLength = max-min + thumbSize; + double subPoint = ((double)max-min) * length / totalUnscaledLength; + if (length - subPoint < minimalThumbLen) { + subPoint = length - minimalThumbLen; + } + double thumbSize = length - subPoint; + + + + int dx = absMouseX - lastX, dy = absMouseY - lastY; + + lastX = absMouseX; + lastY = absMouseY; + + int prevVal = current; + if (axis == Axis.Y) { + actualValue += dy * (max - min) / subPoint; + } else if (axis == Axis.X) { + actualValue += dx * (max - min) / subPoint; + } + + current = MathHelper.clamp_int(actualValue, min, max); + + if (onUpdate != null && prevVal != current) onUpdate.run(); + } + + @Override + public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { + grabbed= false; + } + + public static enum Axis { + X, Y + } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (grabbed) + setCursor(EnumCursor.CLOSED_HAND); + else if (lastThumbRect.contains(relMouseX0, relMouseY0)) { + setCursor(EnumCursor.OPEN_HAND); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MScrollablePanel.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MScrollablePanel.java new file mode 100644 index 00000000..c791d7a2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MScrollablePanel.java @@ -0,0 +1,185 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import lombok.Getter; +import net.minecraft.client.gui.Gui; +import net.minecraft.util.MathHelper; + +import java.awt.*; + +public class MScrollablePanel extends MPanel { + @Getter + private boolean hideScrollBarWhenNotNecessary = false; + + public void setHideScrollBarWhenNotNecessary(boolean hideScrollBarWhenNotNecessary) { + this.hideScrollBarWhenNotNecessary = hideScrollBarWhenNotNecessary; + setBounds(getBounds()); + } + + private final int axis; // 1: Y 2: X 3: both. + + + private MPanel viewPort; + @Getter + private MPanel contentArea; + @Getter + private MScrollBar scrollBarX, scrollBarY; + + private Rectangle contentAreaDim; + + public MScrollablePanel(int axis) { + this.axis = axis; + viewPort = new MPanel(); + scrollBarX = new MScrollBar(0, 1, 1, 0, MScrollBar.Axis.X, this::onScrollBarUpdate); + scrollBarY = new MScrollBar(0, 1, 1, 0, MScrollBar.Axis.Y, this::onScrollBarUpdate); + + if ((axis & 1) > 0) + super.add(scrollBarY); + if ((axis & 2) > 0) + super.add(scrollBarX); + super.add(viewPort); + + + contentArea = new MPanel() { + @Override + public void add(MPanel child) { + super.add(child); + evalulateContentArea(); + } + + @Override + public void remove(MPanel panel) { + super.remove(panel); + evalulateContentArea(); + } + + @Override + public void setBounds(Rectangle bounds) { + if (bounds == null) return; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; + + onBoundsUpdate(); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + for (MPanel childComponent : childComponents) { + childComponent.resize0(parentWidth, parentHeight); + } + evalulateContentArea(); + } + }; + viewPort.add(contentArea); + contentArea.setIgnoreBoundOnClip(true); + evalulateContentArea(); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); + + boolean hideX = (axis & 2) == 0, hideY = (axis & 1) == 0; + if (bounds.width >= contentAreaDim.width && hideScrollBarWhenNotNecessary) hideX = true; + if (bounds.height >= contentAreaDim.height && hideScrollBarWhenNotNecessary) hideY = true; + if (axis == 3 && !(hideX && hideY)) { + Gui.drawRect(scrollBarX.getBounds().width, scrollBarY.getBounds().height, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.03f)); + } + } + + public void evalulateContentArea() { + if (contentArea.getChildComponents().size() == 0) { + contentAreaDim= new Rectangle(0,0,0,0); + return; + } + int minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE; + for (MPanel childComponent : contentArea.getChildComponents()) { + Rectangle bounds = childComponent.getBounds(); + if (bounds.x < minX) minX = bounds.x; + if (bounds.x + bounds.width > maxX) maxX = bounds.x + bounds.width; + if (bounds.y < minY) minY = bounds.y; + if (bounds.y + bounds.height > maxY) maxY = bounds.y + bounds.height; + } + contentAreaDim = new Rectangle(minX, minY, maxX - minX, maxY - minY); + scrollBarX.setMin(contentAreaDim.x); + scrollBarX.setMax(contentAreaDim.x + contentAreaDim.width-scrollBarX.getThumbSize()); + scrollBarY.setMin(contentAreaDim.y); + scrollBarY.setMax(contentAreaDim.y + contentAreaDim.height-scrollBarY.getThumbSize()); + } + + @Override + public void setBounds(Rectangle bounds) { + super.setBounds(bounds); + boolean hideX = (axis & 2) == 0, hideY = (axis & 1) == 0; + viewPort.setBounds(new Rectangle(0,0,bounds.width, bounds.height)); + evalulateContentArea(); + if (bounds.width >= contentAreaDim.width && hideScrollBarWhenNotNecessary) hideX = true; + if (bounds.height >= contentAreaDim.height && hideScrollBarWhenNotNecessary) hideY = true; + + if (!(hideX || hideY)) { + Dimension preferedX = scrollBarX.getPreferredSize(); + Dimension preferedY = scrollBarY.getPreferredSize(); + scrollBarY.setBounds(new Rectangle(bounds.width - preferedY.width, 0, preferedY.width, bounds.height - preferedX.height)); + scrollBarX.setBounds(new Rectangle(0, bounds.height - preferedX.height, bounds.width - preferedY.width, preferedX.height)); + } else if ((hideY && !hideX)) { + Dimension preferedX = scrollBarX.getPreferredSize(); + scrollBarY.setBounds(new Rectangle(0,0,0,0)); + scrollBarX.setBounds(new Rectangle(0, bounds.height - preferedX.height, bounds.width, preferedX.height)); + } else if ((hideX && !hideY)) { + Dimension preferedY = scrollBarY.getPreferredSize(); + scrollBarX.setBounds(new Rectangle(0,0,0,0)); + scrollBarY.setBounds(new Rectangle(bounds.width - preferedY.width, 0, preferedY.width, bounds.height)); + } else if (hideX && hideY){ + scrollBarY.setBounds(new Rectangle(0,0,0,0)); + scrollBarX.setBounds(new Rectangle(0,0,0,0)); + } + + viewPort.setBounds(new Rectangle(0,0,bounds.width-scrollBarY.getBounds().width, bounds.height - scrollBarX.getBounds().height)); + + scrollBarX.setThumbSize(viewPort.getBounds().width); + scrollBarY.setThumbSize(viewPort.getBounds().height); + scrollBarX.setMax(contentAreaDim.x + contentAreaDim.width-scrollBarX.getThumbSize()); + scrollBarY.setMax(contentAreaDim.y + contentAreaDim.height-scrollBarY.getThumbSize()); + evalulateContentArea(); + } + + + private void onScrollBarUpdate() { + contentArea.setPosition(new Point(-scrollBarX.getCurrent(), -scrollBarY.getCurrent())); + } + + + @Override + public void add(MPanel child) { contentArea.add(child); } + + @Override + public void remove(MPanel panel) { contentArea.remove(panel); } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (lastAbsClip.contains(absMouseX, absMouseY) && (axis == 1 || axis == 3)) { + scrollBarY.addToCurrent(MathHelper.clamp_int(scrollAmount, -1, 1) * -30); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MSpacer.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MSpacer.java new file mode 100644 index 00000000..f891946e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MSpacer.java @@ -0,0 +1,36 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; + +import java.awt.*; + +public class MSpacer extends MPanel { + + int width, height; + public MSpacer(int x, int y, int width, int height) { + setBounds(new Rectangle(x,y,width,height)); + this.width = width; this.height = height; + } + @Override + public Dimension getPreferredSize() { + return new Dimension(width, height); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MStringSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MStringSelectionButton.java new file mode 100755 index 00000000..92472180 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MStringSelectionButton.java @@ -0,0 +1,94 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; +import java.util.List; + +@Getter +@Setter +public class MStringSelectionButton extends MPanel { + + private List possible; + private int selectedIndex; + + private MButton dec; + private MButton inc; + private MLabel selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MStringSelectionButton(final List possible, String defaultValue) { + this.possible = possible; + selectedIndex = possible.indexOf(defaultValue); + if (selectedIndex == -1) selectedIndex = 0; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MLabel(); updateSelected(); add(selected); + selected.setBackgroundColor(Color.black); + selected.setAlignment(MLabel.Alignment.CENTER); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + selectedIndex --; + if (selectedIndex < 0) selectedIndex = possible.size() - 1; + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + selectedIndex++; + if (selectedIndex >= possible.size()) selectedIndex = 0; + updateSelected(); + onUpdate.run(); + } + }); + } + + public String selectionToDisplay(String selection) { + return selection; + } + + public String getSelected() { + if (possible.size() == 0) return null; + return possible.get(selectedIndex); + } + + private void updateSelected() { + if (possible.size() == 0) selected.setText("-Empty-"); + else selected.setText(selectionToDisplay(possible.get(selectedIndex))); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); + inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); + selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTabbedPane.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTabbedPane.java new file mode 100755 index 00000000..ae06fb37 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTabbedPane.java @@ -0,0 +1,160 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MTabbedPane extends MPanel { + + private final Map tabs = new HashMap(); + private final Map buttons = new HashMap(); + + @Getter + @Setter + private String selectedKey = ""; + + @Getter + private Color background2; + + public void setBackground2(Color background2) { + this.background2 = background2; + for (MPanel value : tabs.values()) { + value.setBackgroundColor(background2); + } + for (MTabButton value : buttons.values()) { + value.setBackgroundColor(background2.brighter()); + } + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Gui.drawRect(0, 15, getBounds().width, getBounds().height, 0xFF444444); + } + + public void addTab(String tab, MPanel panel) { + MPanel panel2 = new MPanel() ; + panel2.add(panel); + panel2.setBackgroundColor(background2); + tabs.put(tab, panel2); + panel2.setParent(this); + panel2.setBounds(new Rectangle(1,16,getBounds().width-2, getBounds().height-17)); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + MTabButton button = new MTabButton(this, tab); + int totalX = 0; + for (MTabButton button1:buttons.values()) + totalX += button1.getBounds().width; + button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(tab) + 6), 15)); + buttons.put(tab, button); + if (tabs.size() == 1) + selectedKey = tab; + } + + @Override + public List getChildComponents() { + ArrayList dynamic = new ArrayList(buttons.values()); + dynamic.add(tabs.get(selectedKey)); + return dynamic; + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + for (MPanel ma:tabs.values()) + ma.setBounds(new Rectangle(1,16,getBounds().width-2, getBounds().height-17)); + } + + @Override + public void setBounds(Rectangle bounds) { + if (bounds == null) return; + this.bounds.x = bounds.x; + this.bounds.y = bounds.y; + this.bounds.width = bounds.width; + this.bounds.height = bounds.height; + } + + @Getter + @Setter + public static class MTabButton extends MPanel { + private String text; + + private Color foreground = Color.white; + private Color hover = new Color(154, 154, 154, 255); + private Color clicked = new Color(88, 88, 88,255); + private Color selected = new Color(111, 111, 111,255); + private Color disabled = new Color(0,0,0); + + private boolean enabled = true; + + private MTabbedPane tabbedPane; + + public MTabButton(MTabbedPane tabbedPane, String key) { + this.tabbedPane = tabbedPane; + this.text = key; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + Color bg = null; + if (!enabled) { + bg = disabled; + } else if (tabbedPane.getSelectedKey().equals(text)) { + bg = selected; + } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { + bg = hover; + } + Gui.drawRect(0, tabbedPane.getSelectedKey().equals(text) ? 0 : 2, getBounds().width, getBounds().height, 0xFF444444); + if (bg != null) + Gui.drawRect(1,tabbedPane.getSelectedKey().equals(text) ? 1 : 3,getBounds().width - 1, getBounds().height, bg.getRGB()); + + FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; + int width = renderer.getStringWidth(text); + int x = (getBounds().width - width) / 2; + int y = (getBounds().height - 3 - renderer.FONT_HEIGHT) / 2 + 3; + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + renderer.drawString(text, x,y, foreground.getRGB()); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (lastAbsClip.contains(absMouseX, absMouseY)) { + tabbedPane.setSelectedKey(text); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTextField.java new file mode 100755 index 00000000..20378c20 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTextField.java @@ -0,0 +1,418 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.MathHelper; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.awt.datatransfer.*; +import java.awt.event.KeyEvent; +import java.io.IOException; + +@Getter +public class MTextField extends MPanel { + private final Color foreground = Color.white; + private final Color placeHolderColor = Color.lightGray; + + private String text = ""; + @Setter + private String placeHolder = ""; + private int cursorBlickTicker = 0; + + private int selectionStart = 0; + private int selectionEnd = 0; + + private int cursor = 0; + + private int xOffset = 0; + + public void edit(String str) { + + } + + + @Override + public Dimension getPreferredSize() { + return new Dimension(-1,15); + } + + public void setText(String text) { + this.text = text; + } + private void setText0(String text) { + this.text = text; + edit(text); + } + + private void setCursor0(int cursor) { + if (cursor > text.length()) cursor = text.length(); + if (cursor < 0) cursor = 0; + this.cursor = cursor; + + + int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text.substring(0, cursor)); + int cursorX = width + 3- xOffset; + cursorX = MathHelper.clamp_int(cursorX,10, getBounds().width - 10); + xOffset = width+ 3 - cursorX; + xOffset = MathHelper.clamp_int(xOffset, 0,Math.max(0, Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) - getBounds().width+10)); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + clip(clip.x - 1, clip.y - 1, clip.width +2, clip.height + 2); + Gui.drawRect(0,0,getBounds().width, getBounds().height, isFocused ? Color.white.getRGB() : Color.gray.getRGB()); + Gui.drawRect(1,1,getBounds().width - 1, getBounds().height - 1, Color.black.getRGB()); + + Minecraft mc = Minecraft.getMinecraft(); + clip(clip.x + 1, clip.y + 1, clip.width - 2, clip.height - 2); + FontRenderer fr = mc.fontRendererObj; + int y = (getBounds().height - fr.FONT_HEIGHT) / 2; + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(text, 3 - xOffset, y, foreground.getRGB()); + if (text.isEmpty()) + fr.drawString(placeHolder, 3, y, placeHolderColor.getRGB()); + // draw selection + if (isFocused) { + if (selectionStart != -1) { + int startX = fr.getStringWidth(text.substring(0, selectionStart)) - xOffset; + int endX = fr.getStringWidth(text.substring(0, selectionEnd)) - xOffset; + Gui.drawRect(3 + startX, y, 3 + endX, y + fr.FONT_HEIGHT, 0xFF00FF00); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fr.drawString(text.substring(selectionStart, selectionEnd), 3 + startX, y, foreground.getRGB()); + } + + // draw cursor + if (cursor != -1) { + if (cursor > text.length()) setCursor0(text.length()); + int x = fr.getStringWidth(text.substring(0, cursor)) - xOffset; + cursorBlickTicker++; + if (cursorBlickTicker < 10) + Gui.drawRect(3 + x, y, 4 + x, y + fr.FONT_HEIGHT, 0xFFFFFFFF); + if (cursorBlickTicker == 20) cursorBlickTicker = 0; + } + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + Rectangle actualField = new Rectangle(1, 3,getBounds().width - 2, getBounds().height - 6); + if (!actualField.contains(relMouseX, relMouseY)) return; + if (!lastAbsClip.contains(absMouseX, absMouseY)) return; + if (getTooltipsOpen() > 0) return; + + + + int relStartT = relMouseX-3; + int offseted = relStartT + xOffset; + + selectionStart = -1; + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + for (int i = 0; i < text.length(); i++) { + int totalWidth = fr.getStringWidth(text.substring(0, i)); + if (offseted < totalWidth) { + setCursor0(i); + return; + } + } + setCursor0(text.length()); + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + if (!isFocused) return; + selectionStart = cursor; + selectionEnd = cursor; + + int relStartT = relMouseX-3; + int offseted = relStartT + xOffset; + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + for (int i = 0; i < text.length(); i++) { + int totalWidth = fr.getStringWidth(text.substring(0, i)); + if (offseted < totalWidth) { + if (i < cursor) { + selectionStart = i; + selectionEnd = cursor; + } else { + selectionStart = cursor; + selectionEnd = i; + } + return; + } + } + selectionEnd = text.length(); + if (selectionStart == selectionEnd) { + selectionStart = -1; + } + } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (!isFocused) return; + if (scrollAmount > 0) { + xOffset += 5; + } else if (scrollAmount < 0){ + xOffset -= 5; + } + if (xOffset < 0) { + xOffset = 0; + } + int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); + int overflow = getBounds().width - 3 - width; + if (overflow >= 0) { + xOffset = 0; + } else if (width - xOffset + 10 < getBounds().width) { + xOffset = width - getBounds().width+10; + } + } + + @Override + public void keyHeld(char typedChar, int keyCode) { + if (!isFocused) return; + this.keyPressed(typedChar, keyCode); + } + + @Override + public void keyPressed(char typedChar, int keycode) { + if (!isFocused) return; + + if (selectionStart == -1) { + if (keycode == 199) { // home + setCursor0(0); + xOffset = 0; + return; + } + + if (keycode == 207) { // end + setCursor0(text.length()); + + int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); + xOffset = Integer.max(0, width - getBounds().width+10); + return; + } + + if (keycode == 203) { // left + setCursor0(this.cursor-1);; + if (cursor < 0) setCursor0(0); + return; + } + + if (keycode == 205) { // right + setCursor0(this.cursor+1); + if (cursor > text.length()) setCursor0(text.length()); + return; + } + + // backspace + if (keycode == 14 && cursor > 0) { + setText0(this.text.substring(0, cursor-1) + this.text.substring(cursor)); + setCursor0(this.cursor-1); + return; + } + + //del + if (keycode == 211 && cursor < text.length()) { + setText0(this.text.substring(0, cursor) + this.text.substring(cursor+1)); + return; + } + + // paste + boolean shouldPaste = false; + if (keycode == 47) { + if (Minecraft.isRunningOnMac) { // mac + if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { + shouldPaste = true; + } + } else { // literally everything else + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { + shouldPaste = true; + } + } + } + if (shouldPaste) { + Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); + if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { + try { + Object theText = transferable.getTransferData(DataFlavor.stringFlavor); + setText0( + this.text.substring(0, this.cursor) + + theText + + this.text.substring(this.cursor)); + + cursor += theText.toString().length(); + } catch (UnsupportedFlavorException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return; + } + + // text + if (isPrintableChar(typedChar)) { + setText0( + this.text.substring(0, this.cursor) + + typedChar + + this.text.substring(this.cursor)); + this.setCursor0(this.cursor+1);; + return; + } + } else { + if (keycode == 199) { // home + setCursor0(0); + selectionStart = -1; + xOffset =0; + return; + } + + if (keycode == 207) { // end + selectionStart = -1; + setCursor0(text.length()); + int width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(text); + xOffset = Integer.max(0, width - getBounds().width+10); + return; + } + + if (keycode == 203) { // left + setCursor0(selectionStart); + selectionStart = -1; + return; + } + + if (keycode == 205) { // right + setCursor0(selectionEnd); + selectionStart = -1; + return; + } + + // backspace + if (keycode == 14 && cursor > 0) { + setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); + setCursor0(selectionStart); + selectionStart = -1; + return; + } + + //del + if (keycode == 211 && cursor < text.length()) { + setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); + setCursor0(selectionStart); + selectionStart = -1; + return; + } + + // paste + boolean shouldPaste = false; + if (keycode == 47) { + if (Minecraft.isRunningOnMac) { // mac + if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { + shouldPaste = true; + } + } else { // literally everything else + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { + shouldPaste = true; + } + } + } + if (shouldPaste) { + Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); + if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { + try { + Object theText = transferable.getTransferData(DataFlavor.stringFlavor); + setText0( + this.text.substring(0, this.selectionStart) + + theText + + this.text.substring(this.selectionEnd)); + setCursor0(this.selectionStart + theText.toString().length()); + } catch (UnsupportedFlavorException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + selectionStart = -1; + } + return; + } + boolean shouldCopy = false; + if (keycode == 46) { + if (Minecraft.isRunningOnMac) { // mac + if (Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220)) { + shouldCopy = true; + } + } else { // literally everything else + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) { + shouldCopy = true; + } + } + } + if (shouldCopy) { + StringSelection selection = new StringSelection(text.substring(selectionStart, selectionEnd)); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, selection); + return; + } + + // text + if (isPrintableChar(typedChar)) { + setText0( + this.text.substring(0, this.selectionStart) + + typedChar + + this.text.substring(this.selectionEnd)); + this.setCursor0(this.selectionStart + 1); + selectionStart = -1; + return; + } + } + } + public boolean isPrintableChar( char c ) { + Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); + return (!Character.isISOControl(c)) && + c != KeyEvent.CHAR_UNDEFINED && + block != null && + block != Character.UnicodeBlock.SPECIALS; + } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY)) + setCursor(EnumCursor.BEAM_CURSOR); + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MToggleButton.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MToggleButton.java new file mode 100755 index 00000000..ee336d77 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MToggleButton.java @@ -0,0 +1,96 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; + +@Getter +@Setter +public class MToggleButton extends MPanel { + private boolean enabled = true; + private Runnable onToggle; + + private int border = 0xFF333333, background = 0xFF171717; + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + Dimension bounds = getSize(); + + int gap = 1; + + Gui.drawRect(0, 0, bounds.width, bounds.height, border); + Gui.drawRect(gap, gap, bounds.width-gap, bounds.height-gap, background); + + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + double scale = 1; + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (enabled) { + int x = (int) ((scale * bounds.height - fr.FONT_HEIGHT)/2 + gap); + GlStateManager.pushMatrix(); + GlStateManager.scale(1.0/scale,1.0/scale,0); + fr.drawString("ON", x, x, 0xFF9B9B9B); + GlStateManager.popMatrix(); + Gui.drawRect(bounds.width - bounds.height+gap,gap, bounds.width - gap, bounds.height - gap, 0xFF00B200); + } else { + GlStateManager.pushMatrix(); + GlStateManager.scale(1.0/scale,1.0/scale,0); + int x = (int) ((scale * bounds.height - fr.FONT_HEIGHT)/2 + gap); + fr.drawString("OFF", (int) (scale * bounds.width - x - fr.getStringWidth("OFF")), x, 0xFF9B9B9B); + GlStateManager.popMatrix(); + Gui.drawRect(gap,gap, bounds.height - gap, bounds.height - gap, 0xFFCD4000); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(40,15); + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (onToggle != null && lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) { + enabled = !enabled; + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); + onToggle.run(); + } + } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY)) + setCursor(EnumCursor.POINTING_HAND); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTooltip.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTooltip.java new file mode 100644 index 00000000..b11afb04 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTooltip.java @@ -0,0 +1,107 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class MTooltip extends MPanelScaledGUI { + @Getter @Setter + private MRootPanel root; + + public void open(MPanel component) { + if (root == null) + component.openTooltip(this); + } + public void close() { + if (root != null) + root.removeTooltip(this); + } + + + public boolean isOpen() { + return root != null; + } + + @Override + public int getTooltipsOpen() { + return super.getTooltipsOpen() - 1; + } + + @Override + public void render0(double parentScale, Point parentPoint, Rectangle parentClip, int absMousex0, int absMousey0, int relMousex0, int relMousey0, float partialTicks) { + lastParentPoint = parentPoint; + + GlStateManager.translate(getBounds().x, getBounds().y, 300); + GlStateManager.color(1,1,1,1); + + Rectangle absBound = getBounds().getBounds(); + absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); + + Rectangle clip = absBound; + lastAbsClip = clip; + + if (clip.getSize().height * clip.getSize().width == 0) return; + + int absMousex = (int) (absMousex0 / scale), absMousey = (int) (absMousey0 / scale); + int relMousex = (int) ((relMousex0 - getBounds().x) / scale); + int relMousey = (int) ((relMousey0 - getBounds().y) /scale); + + // FROM HERE, IT IS SCALED + + GlStateManager.scale(this.scale, this.scale, 1); + clip = new Rectangle((int) (clip.x / scale), (int) (clip.y / scale), (int) (clip.width / scale), (int) (clip.height / scale)); + lastAbsClip = clip; + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + this.relativeScale = parentScale * this.scale; + clip(clip.x, clip.y, clip.width, clip.height); + + + GuiScreen.drawRect(0,0, (int) (getBounds().width / scale), (int) (getBounds().height / scale), backgroundColor.getRGB()); + GlStateManager.enableBlend(); + + + GlStateManager.pushMatrix(); + + render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); + + GlStateManager.popMatrix(); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + + + Point newPt = new Point((int) ((parentPoint.x + getBounds().x) / scale), (int) ((parentPoint.y + getBounds().y) / scale)); + + for (MPanel mPanel : getChildComponents()){ + GlStateManager.pushMatrix(); + + mPanel.render0(relativeScale, newPt,clip,absMousex, absMousey, relMousex, relMousey, partialTicks); + + GlStateManager.popMatrix(); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTooltipText.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTooltipText.java new file mode 100644 index 00000000..8ea9068f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MTooltipText.java @@ -0,0 +1,44 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.client.config.GuiUtils; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +@AllArgsConstructor +public class MTooltipText extends MTooltip { + @Getter @Setter + private List tooltipText = new ArrayList<>(); + @Override + public Rectangle getBounds() { + return new Rectangle(0,0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + GuiUtils.drawHoveringText(tooltipText, relMousex0, relMousey0, (int) (Minecraft.getMinecraft().displayWidth/getRelativeScale()), (int) (Minecraft.getMinecraft().displayHeight/getRelativeScale()), -1, Minecraft.getMinecraft().fontRendererObj); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MValue.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MValue.java new file mode 100755 index 00000000..1a251dc0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/gui/elements/MValue.java @@ -0,0 +1,79 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.gui.elements; + +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.mod.gui.MPanel; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.gui.GuiDungeonValueEdit; +import kr.syeyoung.dungeonsguide.mod.dungeon.roomedit.valueedit.ValueEditOffsetPointSet; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; +import java.util.List; +public class MValue extends MPanel { + @Getter + private final T data; + private ValueEditOffsetPointSet valueEditOffsetPointSet; + private final MLabel dataLab; + + @Getter @Setter + private Color hover = Color.gray; + + private final List addons; + + public MValue(final T parameter, List addons) { + this.addons = addons; + this.add(this.dataLab = new MLabel() { + @Override + public String getText() { + return data != null ?data.toString() :"-empty-"; + } + }); + this.dataLab.setAlignment(MLabel.Alignment.RIGHT); + + this.data = parameter; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); + } + } + + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (this.getBounds().x > -20 && lastAbsClip.contains(absMouseX, absMouseY)) { + EditingContext.getEditingContext().openGui(new GuiDungeonValueEdit(data, addons)); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + dataLab.setBounds(new Rectangle(0,0,parentWidth, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + dataLab.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/party/PartyContext.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/party/PartyContext.java new file mode 100644 index 00000000..6cab82b3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/party/PartyContext.java @@ -0,0 +1,102 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.party; + +import lombok.Data; +import net.minecraft.client.Minecraft; + +import java.util.HashSet; +import java.util.Set; +import java.util.TreeSet; + + +@Data +public class PartyContext { + private String partyID; + + private String partyOwner; + private Set partyModerator; private boolean isModeratorComplete; + private Set partyMember; private boolean isMemberComplete; + + private Set dgUsers; + + private Set partyRawMembers = new HashSet<>(); private boolean isRawMemberComplete; + + private Boolean allInvite; + + private boolean partyExistHypixel = true; + + public void setPartyOwner(String partyOwner) { + this.partyOwner = partyOwner; + if (partyMember != null) partyMember.remove(partyOwner); + if (partyModerator != null) partyModerator.remove(partyOwner); + addRawMember(partyOwner); + } + public void addPartyModerator(String partyModerator) { + if (partyModerator.equalsIgnoreCase(partyOwner)) partyOwner = null; + if (partyMember != null) partyMember.remove(partyModerator); + + if (this.partyModerator == null) this.partyModerator = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + this.partyModerator.add(partyModerator); + addRawMember(partyModerator); + } + public void addPartyMember(String partyMember) { + if (partyMember.equalsIgnoreCase(partyOwner)) partyOwner = null; + if (partyModerator != null) partyModerator.remove(partyMember); + + if (this.partyMember == null) this.partyMember = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + this.partyMember.add(partyMember); + addRawMember(partyMember); + } + + public void addDgUser(String partyMember) { + if (this.dgUsers == null) this.dgUsers = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + this.dgUsers.add(partyMember); + } + + public void addRawMember(String partyMember) { + partyRawMembers.add(partyMember); + } + + public void removeFromParty(String username) { + if (username.equalsIgnoreCase(partyOwner)) { + partyOwner = null; + } + if (partyModerator != null) partyModerator.remove(username); + if (partyMember != null) partyMember.remove(username); + partyRawMembers.remove(username); + } + + + public boolean isDgUser(String username) { + return dgUsers != null && dgUsers.contains(username); + } + public boolean hasModerator(String username) { + return partyModerator != null && partyModerator.contains(username); + } + public boolean hasMember(String username) { + return partyMember != null && partyMember.contains(username); + } + public boolean hasLeader(String username) { + return username.equalsIgnoreCase(partyOwner); + } + public boolean isSelfSolo() { + return hasLeader(Minecraft.getMinecraft().getSession().getUsername()) && getPartyRawMembers().size() == 1; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/party/PartyManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/party/PartyManager.java new file mode 100644 index 00000000..6e5d9aa9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/party/PartyManager.java @@ -0,0 +1,626 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.party; + +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessResult; +import kr.syeyoung.dungeonsguide.mod.chat.ChatProcessor; +import kr.syeyoung.dungeonsguide.mod.chat.ChatSubscriber; +import kr.syeyoung.dungeonsguide.mod.chat.ChatTransmitter; +import kr.syeyoung.dungeonsguide.mod.events.impl.HypixelJoinedEvent; +import kr.syeyoung.dungeonsguide.mod.events.impl.StompConnectedEvent; +import kr.syeyoung.dungeonsguide.mod.features.impl.advanced.FeatureTestPepole; +import kr.syeyoung.dungeonsguide.mod.stomp.*; +import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.security.SecureRandom; +import java.util.*; +import java.util.function.Consumer; + +public class PartyManager { + public static final PartyManager INSTANCE = new PartyManager(); + @Getter + private PartyContext partyContext; + + public PartyContext getPartyContext(boolean createIfNeeded) { + PartyContext pc = partyContext == null && createIfNeeded ? partyContext = new PartyContext() : partyContext; + if (createIfNeeded) + pc.addRawMember(Minecraft.getMinecraft().getSession().getUsername()); + return pc; + } + + @Getter + @Setter + private int maxParty = 5; + @Getter + private String askToJoinSecret = null; + + private static final SecureRandom random = new SecureRandom(); + private static final String validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"; + + + private Set> partyBuiltCallback = new HashSet<>(); + + public PartyManager() { + ChatProcessor cp = ChatProcessor.INSTANCE; + // Not in Party + cp.subscribe(new ChatSubscriber() { + @Override + public ChatProcessResult process(String str, Map a) { + if (str.equals("ยงcYou are not currently in a party.ยงr") + || str.equals("ยงeYou left the party.ยงr") + || str.equals("ยงcYou must be in a party to join the party channel!ยงr") + || str.equals("ยงcThe party was disbanded because all invites expired and the party was emptyยงr") + || str.equals("ยงcYou are not in a party and were moved to the ALL channel.ยงr") + || str.startsWith("ยงcThe party was disbanded") + || str.endsWith("ยงehas disbanded the party!ยงr") + || str.startsWith("ยงcYou are not in a party") + || str.startsWith("ยงeYou have been kicked from the party by ")) { + PartyManager.this.leaveParty(); + + for (Consumer partyContextConsumer : partyBuiltCallback) { + try { + partyContextConsumer.accept(null); + } catch (Exception e) { + e.printStackTrace(); + } + } + partyBuiltCallback.clear(); + a.put("type", "notinparty"); + } + return ChatProcessResult.NONE; + } + }); + // All invite + cp.subscribe(new ChatSubscriber() { + @Override + public ChatProcessResult process(String str, Map a) { + if (str.endsWith("ยงaenabled All Inviteยงr")) { + PartyManager.this.getPartyContext(true).setAllInvite(true); + a.put("type", "allinvite_on"); + } else if (str.endsWith("ยงcdisabled All Inviteยงr") + || str.equals("ยงcYou are not allowed to invite players.ยงr")) { + PartyManager.this.getPartyContext(true).setAllInvite(false); + a.put("type", "allinvite_off"); + PartyManager.this.potentialInvitenessChange(); + } + return ChatProcessResult.NONE; + } + }); + // Member building + cp.subscribe(new ChatSubscriber() { + boolean memberExpected; + PartyContext partyContext = new PartyContext(); + @Override + public ChatProcessResult process(String txt, Map context) { + if (txt.startsWith("ยง6Party Members ")) { + memberExpected = true; + partyContext = new PartyContext(); + partyContext.setPartyModerator(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); + partyContext.setPartyMember(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); + context.put("type", "member_start"); + } else if (txt.startsWith("ยงeParty ") && txt.contains(":")){ + String role = txt.split(":")[0]; + String playerNames = TextUtils.stripColor(txt.split(":")[1]); + for (String s : playerNames.split(" ")) { + if (s.isEmpty()) continue; + if (s.equals("โ—")) continue; + if (s.startsWith("[")) continue; + partyContext.addRawMember(s); + if (role.contains("Moder")) partyContext.addPartyModerator(s); + if (role.contains("Member")) partyContext.addPartyMember(s); + if (role.contains("Leader")) partyContext.setPartyOwner(s); + } + if (role.contains("Moder")) { + partyContext.setModeratorComplete(true); + context.put("type", "member_moder"); + } + if (role.contains("Member")) { + partyContext.setMemberComplete(true); + context.put("type", "member_member"); + } + if (role.contains("Leader")) { + context.put("type", "member_leader"); + } + } else if (txt.startsWith("ยง9ยงm---------------------------")) { + if (memberExpected) { + PartyContext old = getPartyContext(true); + old.setPartyOwner(partyContext.getPartyOwner()); + old.setPartyModerator(partyContext.getPartyModerator()); + old.setPartyMember(partyContext.getPartyMember()); + old.setPartyRawMembers(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); + old.getPartyRawMembers().addAll(old.getPartyMember()); + old.getPartyRawMembers().addAll(old.getPartyModerator()); + old.getPartyRawMembers().add(old.getPartyOwner()); + old.setModeratorComplete(true); old.setMemberComplete(true); + old.setRawMemberComplete(true); + old.setPartyExistHypixel(true); + + memberExpected = false; + context.put("type", "member_end"); + + for (Consumer partyContextConsumer : partyBuiltCallback) { + try { + partyContextConsumer.accept(partyContext); + } catch (Exception e) { + e.printStackTrace(); + } + } + partyBuiltCallback.clear(); + + if (old.getPartyID() == null) { + joinedParty(); + } + potentialInvitenessChange(); + } + } + return ChatProcessResult.NONE; + } + }); + // Player party join / leave + cp.subscribe(new ChatSubscriber() { + @Override + public ChatProcessResult process(String str, Map a) { + if (str.endsWith("ยงejoined the party.ยงr")) { + String username = null; + for (String s : TextUtils.stripColor(str).split(" ")) { + if (s.startsWith("[")) continue; + username = s; + break; + } + if (username != null) { + PartyManager.this.getPartyContext(true).addPartyMember(username); + } + a.put("type", "party_join"); + } else if (str.endsWith("ยงehas been removed from the party.ยงr") + || str.endsWith("ยงehas left the party.ยงr")) { + String username = null; + for (String s : TextUtils.stripColor(str).split(" ")) { + if (s.startsWith("[")) continue; + username = s; + break; + } + if (username != null && partyContext != null) { + PartyManager.this.getPartyContext().removeFromParty(username); + } + a.put("type", "party_leave"); + } else if (str.endsWith(" They have ยงrยงc60 ยงrยงeseconds to accept.ยงr")) { + String[] messageSplit = TextUtils.stripColor(str).split(" "); + String inviter = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + inviter = s; + break; + } + if (inviter != null && partyContext != null) { + if (PartyManager.this.getPartyContext().hasMember(inviter)) { + PartyManager.this.getPartyContext().setAllInvite(true); + } + } + PartyManager.this.getPartyContext(true).setPartyExistHypixel(true); + a.put("type", "party_invite_exist"); + } else if (str.equals("ยงcCouldn't find a player with that name!ยงr") || str.equals("ยงcYou cannot invite that player since they're not online.")) { + a.put("type", "party_invite_noexist"); + String username = Minecraft.getMinecraft().getSession().getUsername(); + if (partyContext != null && PartyManager.this.getPartyContext().hasMember(username)) { + PartyManager.this.getPartyContext().setAllInvite(true); + } + } + return ChatProcessResult.NONE; + } + }); + // Promotion + cp.subscribe(new ChatSubscriber() { + @Override + public ChatProcessResult process(String str, Map a) { + if (str.startsWith("ยงeThe party was transferred to ")) { + // ยงeThe party was transferred to ยงrยงb[MVPยงrยงf+ยงrยงb] apotato321 ยงrยงeby ยงrยงa[VIPยงrยง6+ยงrยงa] syeyoungยงr + String[] messageSplit = TextUtils.stripColor(str.substring(31)).split(" "); + String newLeader = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + newLeader = s; + break; + } + String oldLeader; + boolean left = false; + if (str.endsWith("ยงrยงeleftยงr")) { + oldLeader = messageSplit[messageSplit.length - 2]; + left = true; + } else { + oldLeader = messageSplit[messageSplit.length - 1]; + } + + if (oldLeader != null && newLeader != null) { + PartyManager.this.getPartyContext(true).setPartyOwner(newLeader); + if (left) + PartyManager.this.getPartyContext(true).removeFromParty(oldLeader); + else + PartyManager.this.getPartyContext(true).addPartyModerator(oldLeader); + } + a.put("type", "party_transfer"); + PartyManager.this.potentialInvitenessChange(); + } else if (str.endsWith("ยงeto Party Leaderยงr")) { + // ยงa[VIPยงrยง6+ยงrยงa] syeyoungยงrยงe has promoted ยงrยงb[MVPยงrยงf+ยงrยงb] apotato321 ยงrยงeto Party Leaderยงr + String[] messageSplit = TextUtils.stripColor(str).split(" "); + String oldLeader = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + oldLeader = s; + break; + } + messageSplit = TextUtils.stripColor(str.substring(str.indexOf("has promoted") + 13)).split(" "); + String newLeader = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + newLeader = s; + break; + } + + if (oldLeader != null && newLeader != null) { + PartyManager.this.getPartyContext(true).setPartyOwner(newLeader); + PartyManager.this.getPartyContext(true).addPartyModerator(oldLeader); + } + a.put("type", "party_transfer"); + PartyManager.this.potentialInvitenessChange(); + } else if (str.endsWith("ยงrยงeto Party Moderatorยงr")) { + // ยงb[MVPยงrยงf+ยงrยงb] apotato321ยงrยงe has promoted ยงrยงa[VIPยงrยง6+ยงrยงa] syeyoung ยงrยงeto Party Moderatorยงr + String[] messageSplit = TextUtils.stripColor(str).split(" "); + String oldLeader = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + oldLeader = s; + break; + } + messageSplit = TextUtils.stripColor(str.substring(str.indexOf("has promoted") + 13)).split(" "); + String newModerator = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + newModerator = s; + break; + } + + if (oldLeader != null && newModerator != null) { + PartyManager.this.getPartyContext(true).setPartyOwner(oldLeader); + PartyManager.this.getPartyContext(true).addPartyModerator(newModerator); + } + a.put("type", "party_promotion"); + PartyManager.this.potentialInvitenessChange(); + } else if (str.endsWith("ยงrยงeto Party Memberยงr")) { + String[] messageSplit = TextUtils.stripColor(str).split(" "); + String oldLeader = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + oldLeader = s; + break; + } + messageSplit = TextUtils.stripColor(str.substring(str.indexOf("has demoted") + 12)).split(" "); + String newMember = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + newMember = s; + break; + } + + if (oldLeader != null && newMember != null) { + PartyManager.this.getPartyContext(true).setPartyOwner(oldLeader); + PartyManager.this.getPartyContext(true).addPartyMember(newMember); + } + a.put("type", "party_demotion"); + PartyManager.this.potentialInvitenessChange(); + } + return ChatProcessResult.NONE; + } + }); + // Player Join + cp.subscribe(new ChatSubscriber() { + boolean joined; + @Override + public ChatProcessResult process(String str, Map context) { + if (str.startsWith("ยงeYou have joined ")) { + String[] messageSplit = TextUtils.stripColor(str.substring(18)).split(" "); + String leader = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + leader = s; + break; + } + leader = leader.substring(0, leader.length()-2); // remove 's + partyContext = new PartyContext(); + getPartyContext().setPartyOwner(leader); + getPartyContext().addPartyMember(Minecraft.getMinecraft().getSession().getUsername()); + context.put("type", "party_selfjoin_leader"); + joined= true; + } else if (str.startsWith("ยงeYou'll be partying with: ")) { + String[] players = TextUtils.stripColor(str.substring(27)).split(" "); + for (String player : players) { + if (player.startsWith("[")) continue; + getPartyContext().addRawMember(player); + } + context.put("type", "party_selfjoin_players"); + } else if (str.startsWith("ยง9ยงm---------------------------") && joined) { + joined = false; + getPartyContext().setRawMemberComplete(true); + joinedParty(); + potentialInvitenessChange(); + } + return ChatProcessResult.NONE; + }}); + // Player Join Dungon + cp.subscribe(new ChatSubscriber() { + @Override + public ChatProcessResult process(String str, Map a) { + if (str.contains("ยงrยงejoined the dungeon group! (ยงrยงb")) { + String username = TextUtils.stripColor(str).split(" ")[3]; + if (username.equalsIgnoreCase(Minecraft.getMinecraft().getSession().getUsername())) { + partyContext = new PartyContext(); + PartyManager.this.requestPartyList((str2) -> { + PartyManager.this.potentialInvitenessChange(); + }); + } else { + PartyManager.this.getPartyContext(true).setMemberComplete(false); + PartyManager.this.requestPartyList((str2) -> { + }); + } + } + return ChatProcessResult.NONE; + } + }); + } + + public void toggleAllowAskToJoin() { + if (canInvite()) { + if (askToJoinSecret != null) askToJoinSecret = null; + else { + updateAskToJoin(); + } + } + } + + public void updateAskToJoin() { + StringBuilder secretBuilder = new StringBuilder(); + for (int i = 0; i < 20; i++) { + secretBuilder.append(validChars.charAt(random.nextInt(validChars.length()))); + } + askToJoinSecret = secretBuilder.toString(); + + StompManager.getInstance().send(new StompPayload().payload(new JSONObject().put("secret", askToJoinSecret).toString()).destination("/app/party.setjoinsecret")); + } + + public static ChatSubscriber dashShredder() { + return (str, a) -> (int)a.get("removed") == 0 && str.startsWith("ยง9ยงm---------------------------") ? ChatProcessResult.REMOVE_LISTENER_AND_CHAT : ChatProcessResult.NONE; + } + + public static ChatSubscriber typeShredder(boolean end, String... types) { + return (str, a) -> (int)a.get("removed") == 0 &&Arrays.stream(types).anyMatch(s -> s.equals(a.getOrDefault("type", null))) ? (end ? ChatProcessResult.REMOVE_LISTENER_AND_CHAT : ChatProcessResult.REMOVE_CHAT) : ChatProcessResult.NONE; + } + + public static ChatSubscriber combinedShredder(ChatSubscriber... chatSubscribers) { + return (str, a) -> { + boolean removeChat = false; + boolean removeListener = false; + for (ChatSubscriber chatSubscriber : chatSubscribers) { + ChatProcessResult chatProcessResult = chatSubscriber.process(str, a); + if (chatProcessResult.isRemoveChat()) removeChat = true; + if (chatProcessResult.isRemoveListener()) removeListener = true; + } + return (removeChat && removeListener) ? ChatProcessResult.REMOVE_LISTENER_AND_CHAT : (removeChat ? ChatProcessResult.REMOVE_CHAT : (removeListener ? ChatProcessResult.REMOVE_LISTENER : ChatProcessResult.NONE)); + }; + } + + @SubscribeEvent + public void onHypixelJoin(HypixelJoinedEvent skyblockJoinedEvent) { + partyContext = null; + requestPartyList((a) -> { + if (a == null) return; + if (isLeader() || isModerator()) return; + if (a.getAllInvite() != null) return; + requestAllInvite(); + }); + } + + private void leaveParty() { + if (partyContext != null) { + getPartyContext().setPartyExistHypixel(false); + if (getPartyContext().isSelfSolo()) return; + if (getPartyContext().getPartyID() != null) { + JSONObject object = new JSONObject(); + object.put("partyid", getPartyContext().getPartyID()); + StompManager.getInstance().send(new StompPayload().payload(object.toString()).destination( "/app/party.leave")); + } + } + + partyContext = new PartyContext(); + playerInvAntiSpam.clear(); + + getPartyContext().setPartyExistHypixel(false); + getPartyContext().setPartyOwner(Minecraft.getMinecraft().getSession().getUsername()); + getPartyContext().setPartyModerator(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); getPartyContext().setMemberComplete(true); + getPartyContext().setPartyMember(new TreeSet<>(String.CASE_INSENSITIVE_ORDER)); getPartyContext().setModeratorComplete(true); + getPartyContext().setAllInvite(false); + joinedParty(); + } + private void joinedParty() { + JSONArray jsonArray = new JSONArray(); + for (String member : getPartyContext().getPartyRawMembers()) { + jsonArray.put(member); + } + JSONObject object = new JSONObject(); + object.put("members", jsonArray); + StompManager.getInstance().send(new StompPayload().payload(object.toString()).destination("/app/party.join")); + + getPartyContext().setPartyID("!@#!@#!@#..........FETCHING..........$!@$!@$!@$"+UUID.randomUUID().toString()); + } + + public boolean isLeader() { + return partyContext != null && getPartyContext().hasLeader(Minecraft.getMinecraft().getSession().getUsername()); // "getUsername" + } + public boolean isModerator() { + return partyContext != null && getPartyContext().hasModerator(Minecraft.getMinecraft().getSession().getUsername()); + } + public boolean canInvite() { + return isLeader() || isModerator() || (partyContext != null && getPartyContext().getAllInvite() != null && getPartyContext().getAllInvite()); + } + + private boolean requested = false; + public void requestPartyList(Consumer onPartyCallback) { + if (requested) { + partyBuiltCallback.add(onPartyCallback); + return; + } + requested = true; + + ChatProcessor.INSTANCE.addToChatQueue("/pl", () -> { + ChatProcessor.INSTANCE.subscribe(dashShredder()); + ChatProcessor.INSTANCE.subscribe(combinedShredder(typeShredder(true, "member_end"), dashShredder(), typeShredder(false,"notinparty", "member_start", "member_moder", "member_leader", "member_member"))); + }, true); + partyBuiltCallback.add(onPartyCallback); + partyBuiltCallback.add(pc -> requested=false); + } + + public void requestAllInvite() { + if (isLeader() || isModerator()) return; + if (partyContext != null && getPartyContext().getAllInvite() != null) return; + + ChatProcessor.INSTANCE.addToChatQueue("/p invite -", () -> { + ChatProcessor.INSTANCE.subscribe(dashShredder()); + ChatProcessor.INSTANCE.subscribe(typeShredder(true, "notinparty", "allinvite_off", "party_invite_noexist")); + ChatProcessor.INSTANCE.subscribe(dashShredder()); + }, true); + } + + private Map playerInvAntiSpam = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + + @SubscribeEvent + public void stompConnect(StompConnectedEvent event) { + + event.getStompInterface().subscribe("/user/queue/party.resp", (stompClient ,payload) -> { + JSONObject object = new JSONObject(payload); + + String str = object.getString("status"); + if ("success".equals(str) && partyContext != null) { + getPartyContext().setPartyID(object.getString("partyId")); + if (askToJoinSecret != null) { + updateAskToJoin(); + } + } else if (partyContext != null){ + getPartyContext().setPartyID(null); + } + }); + + event.getStompInterface().subscribe("/user/queue/party.check", (stompClient ,payload) -> { + JSONObject object = new JSONObject(payload); + String playerName = object.getString("player"); + String token = object.getString("token"); + if (partyContext == null) { + requestPartyList((pc) -> { + boolean contains = pc.getPartyRawMembers().contains(playerName); + if (!contains) { + StompManager.getInstance().send(new StompPayload().payload(new JSONObject().put("status", "failure").put("token", token).toString()).destination("/app/party.check.resp")); + } else { + StompManager.getInstance().send(new StompPayload().payload(new JSONObject().put("status", "success").put("token", token).toString()).destination("/app/party.check.resp")); + } + }); + } else { + if (getPartyContext().getPartyRawMembers().contains(playerName)) { + StompManager.getInstance().send(new StompPayload().payload(new JSONObject().put("status", "success").put("token", token).toString()).destination("/app/party.check.resp")); + } else if (getPartyContext().isMemberComplete() && getPartyContext().isModeratorComplete() && getPartyContext().getPartyOwner() != null) { + StompManager.getInstance().send(new StompPayload().payload(new JSONObject().put("status", "failure").put("token", token).toString()).destination("/app/party.check.resp")); + } else { + requestPartyList((pc) -> { + boolean contains = pc.getPartyRawMembers().contains(playerName); + if (!contains) { + StompManager.getInstance().send(new StompPayload().payload(new JSONObject().put("status", "failure").put("token", token).toString()).destination("/app/party.check.resp")); + } else { + StompManager.getInstance().send(new StompPayload().payload(new JSONObject().put("status", "success").put("token", token).toString()).destination("/app/party.check.resp")); + } + }); + } + } + }); + event.getStompInterface().subscribe("/user/queue/party.broadcast", (stompClient ,payload) -> { + String broadCastPlayload = new JSONObject(payload).getString("payload"); + System.out.println("Received broadcast"); + if(broadCastPlayload.startsWith("C:")) { + FeatureTestPepole.handlePartyBroadCast(broadCastPlayload); + }else { + try { + ChatTransmitter.addToQueue(new ChatComponentText("ยงeDungeons Guide ยง7:: Message Broadcasted from player:: \n" + new JSONObject(payload).getString("payload"))); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + event.getStompInterface().subscribe("/user/queue/party.join", (stompClient ,payload) -> { + JSONObject object = new JSONObject(payload); + String playerName = object.getString("player"); + String secret = object.getString("secret"); + if (secret.equals(askToJoinSecret) && partyContext != null && getPartyContext().getPartyRawMembers().size() < maxParty && playerInvAntiSpam.getOrDefault(playerName, 0L) < System.currentTimeMillis() - 5000) { + playerInvAntiSpam.put(playerName, System.currentTimeMillis()); + ChatProcessor.INSTANCE.addToChatQueue("/p invite "+playerName,() -> {}, true); + } + }); + event.getStompInterface().subscribe("/user/queue/party.askedtojoin.resp", (stompClient ,payload) -> { + JSONObject object = new JSONObject(payload); + String invFrom = object.getString("username"); + String token2 = object.getString("token"); + if (!token2.equals(lastToken)) return; + lastToken = null; + ChatProcessor.INSTANCE.addToChatQueue("/p accept "+invFrom, () -> {}, true); + long end = System.currentTimeMillis() + 3000; + ChatProcessor.INSTANCE.subscribe((str, a) -> { + if (!str.contains("ยงrยงehas invited you to join their party!")) return System.currentTimeMillis() > end ? ChatProcessResult.REMOVE_LISTENER : ChatProcessResult.NONE; + String[] messageSplit = TextUtils.stripColor(str).split(" "); + String inviter = null; + for (String s : messageSplit) { + if (s.startsWith("[")) continue; + if (s.startsWith("-")) continue;; + inviter = s; + break; + } + if (invFrom.equalsIgnoreCase(inviter)) { + ChatProcessor.INSTANCE.addToChatQueue("/p accept "+invFrom, () -> {}, true); + } + return ChatProcessResult.NONE; + }); + }); + + + } + + private String lastToken; + public void joinWithToken(String secret) { + lastToken = secret; + if (partyContext != null && getPartyContext().isPartyExistHypixel()) + ChatProcessor.INSTANCE.addToChatQueue("/p leave", () -> {}, true); + StompManager.getInstance().send(new StompPayload().method(StompHeader.SEND) + .destination("/app/party.askedtojoin") + .payload(new JSONObject().put("token", secret).toString())); + } + + private void potentialInvitenessChange() { + if (askToJoinSecret != null && !canInvite()) askToJoinSecret = null; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/resources/DGTexturePack.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/resources/DGTexturePack.java new file mode 100644 index 00000000..6c8c9a30 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/resources/DGTexturePack.java @@ -0,0 +1,71 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.resources; + +import kr.syeyoung.dungeonsguide.auth.ResourceManager; +import lombok.AllArgsConstructor; +import net.minecraft.client.resources.IResourcePack; +import net.minecraft.client.resources.data.IMetadataSection; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.util.ResourceLocation; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.Set; + +@AllArgsConstructor +public class DGTexturePack implements IResourcePack { + + + @Override + public InputStream getInputStream(ResourceLocation location) throws IOException { + InputStream inputStream = this.getClass().getResourceAsStream("/assets/dg/"+location.getResourcePath()); + if (inputStream != null) return inputStream; + return new ByteArrayInputStream(ResourceManager.getInstance().getResources().get("assets/dg/"+location.getResourcePath())); + } + + @Override + public boolean resourceExists(ResourceLocation location) { + return ResourceManager.getInstance().getResources().containsKey("assets/dg/"+location.getResourcePath()) + || this.getClass().getResourceAsStream("/assets/dg/"+location.getResourcePath()) != null; + } + + @Override + public Set getResourceDomains() { + return Collections.singleton("dungeonsguide"); + } + + @Override + public T getPackMetadata(IMetadataSerializer p_135058_1_, String p_135058_2_) throws IOException { + return null; + } + + @Override + public BufferedImage getPackImage() throws IOException { + return new BufferedImage(512,512, BufferedImage.TYPE_INT_RGB); + } + + @Override + public String getPackName() { + return "Dungeons Guide Default Pack"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/FailedWebSocketConnection.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/FailedWebSocketConnection.java new file mode 100644 index 00000000..15f79dde --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/FailedWebSocketConnection.java @@ -0,0 +1,7 @@ +package kr.syeyoung.dungeonsguide.mod.stomp; + +public class FailedWebSocketConnection extends RuntimeException{ + public FailedWebSocketConnection(String message) { + super(message); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java new file mode 100644 index 00000000..84705a1d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java @@ -0,0 +1,192 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.stomp; + +import lombok.Getter; +import net.minecraftforge.common.MinecraftForge; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.java_websocket.client.WebSocketClient; +import org.java_websocket.handshake.ServerHandshake; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +public class StompClient extends WebSocketClient { + + Logger logger = LogManager.getLogger("StompClient"); + public StompClient(URI serverUri, final String token) throws InterruptedException { + super(serverUri); + + + addHeader("Authorization", token); + + logger.info("connecting websocket"); + if (!connectBlocking()) { + throw new FailedWebSocketConnection("Cant connect to ws"); + } + + logger.info("connected, stomp handshake"); + while(this.stompClientStatus == StompClientStatus.CONNECTING); + logger.info("fully connected"); + } + + + @Getter + private volatile StompClientStatus stompClientStatus = StompClientStatus.CONNECTING; + + @Getter + private StompPayload errorPayload; + + private ScheduledFuture heartbeat = null; + + private static final ScheduledExecutorService ex = Executors.newScheduledThreadPool(1); + @Override + public void onOpen(ServerHandshake handshakedata) { + send(new StompPayload().method(StompHeader.CONNECT) + .header("accept-version","1.2") + .header("heart-beat", "30000,30000") + .header("host",uri.getHost()).getBuilt() + ); + } + + @Override + public void onMessage(String message) { + try { + StompPayload payload = StompPayload.parse(message); + + switch (payload.method()){ + case SEND: + case SUBSCRIBE: + case UNSUBSCRIBE: + case BEGIN: + case COMMIT: + case ABORT: + case ACK: + case NACK: + case DISCONNECT: + case STOMP: + break; + case CONNECTED: + stompClientStatus = StompClientStatus.CONNECTED; + + String serverHeartbeat = payload.headers().get("heart-beat"); + if (serverHeartbeat != null) { + int heartbeatMS = 30; + this.heartbeat = ex.scheduleAtFixedRate(() -> send("\n"), heartbeatMS-1, heartbeatMS-1, TimeUnit.SECONDS); + } + + break; + case MESSAGE: + String subscriptionName = payload.headers().get("subscription"); + int subscriptionId = Integer.parseInt(subscriptionName); + StompSubscription listener = stompSubscriptionMap.get(subscriptionId); + + listener.process(this, payload.payload()); + + break; + case RECEIPT: + String receiptId = payload.headers().get("receipt-id"); + StompPayload payload1 = receiptMap.remove(Integer.parseInt(receiptId)); + if (payload1.method() == StompHeader.DISCONNECT) { + stompClientStatus = StompClientStatus.DISCONNECTED; + close(); + } + break; + case ERROR: + errorPayload = payload; + stompClientStatus = StompClientStatus.ERROR; + this.close(); + break; + + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void onClose(int code, String reason, boolean remote) { + if (heartbeat != null) heartbeat.cancel(true); + + MinecraftForge.EVENT_BUS.post(new StompDiedEvent(code, reason, remote)); + + } + + @Override + public void onError(Exception ex) { + if(ex != null){ + ex.printStackTrace(); + } + } + + + private final Map stompSubscriptionMap = new HashMap<>(); + private final Map receiptMap = new HashMap<>(); + + private int idIncrement = 0; + + private void makeSureStompIsConnected() { + if (stompClientStatus != StompClientStatus.CONNECTED) throw new IllegalStateException("not connected"); + } + + public void sendfake(StompPayload payload) { + makeSureStompIsConnected(); + payload.method(StompHeader.SEND); + if (payload.headers().get("receipt") != null) + receiptMap.put(Integer.parseInt(payload.headers().get("receipt")), payload); + send(payload.getBuilt()); + } + + public void subscribe(String destination, StompSubscription listener) { + makeSureStompIsConnected(); + int id = ++idIncrement; + + send(new StompPayload() + .method(StompHeader.SUBSCRIBE) + .header("id", String.valueOf(id)) + .destination(destination) + .header("ack", "auto") + .getBuilt() + ); + + stompSubscriptionMap.put(id, listener); + } + + + public void disconnect() { + makeSureStompIsConnected(); + stompClientStatus =StompClientStatus.DISCONNECTING; + + StompPayload stompPayload = new StompPayload().method(StompHeader.DISCONNECT).header("receipt", String.valueOf(++idIncrement)); + + send(stompPayload.getBuilt()); + receiptMap.put(idIncrement, stompPayload); + } + + + public enum StompClientStatus { + CONNECTING, CONNECTED, ERROR, DISCONNECTING, DISCONNECTED + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompDiedEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompDiedEvent.java new file mode 100644 index 00000000..33913424 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompDiedEvent.java @@ -0,0 +1,15 @@ +package kr.syeyoung.dungeonsguide.mod.stomp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@EqualsAndHashCode(callSuper=false) +@AllArgsConstructor +public class StompDiedEvent extends Event { + int code; + String reason; + boolean remote; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompHeader.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompHeader.java new file mode 100644 index 00000000..7755d8a6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompHeader.java @@ -0,0 +1,24 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.stomp; + + +public enum StompHeader { + SEND, SUBSCRIBE, UNSUBSCRIBE, BEGIN, COMMIT, ABORT, ACK, NACK, DISCONNECT, CONNECT, STOMP, CONNECTED, MESSAGE, RECEIPT, ERROR +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompManager.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompManager.java new file mode 100644 index 00000000..31b3b961 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompManager.java @@ -0,0 +1,73 @@ +package kr.syeyoung.dungeonsguide.mod.stomp; + +import com.google.common.base.Throwables; +import kr.syeyoung.dungeonsguide.auth.AuthManager; +import kr.syeyoung.dungeonsguide.mod.events.impl.StompConnectedEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.net.URI; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +public class StompManager { + Logger logger = LogManager.getLogger("StompManager"); + public static final String STOMP_URL = "wss://dungeons.guide/ws"; + // private String stompURL = "ws://localhost/ws"; + static StompManager instance; + + public static StompManager getInstance() { + if (instance == null) { + instance = new StompManager(); + MinecraftForge.EVENT_BUS.register(instance); + } + return instance; + } + + public void init() { + connectStomp(); + } + + private StompClient stompConnection; + + + public boolean isStompConnected(){ + if(stompConnection != null && stompConnection.getStompClientStatus() == StompClient.StompClientStatus.CONNECTED) return true; + return false; + } + + public void send(StompPayload payload){ + if(stompConnection != null){ + stompConnection.sendfake(payload); + } else { + logger.error("OOPS STOMP CONNECTION IS NULL AND SOMEONE TRIED TO SEND SOMETHING THIS SHOULD NOT HAPPEN"); + } + } + + ScheduledExecutorService ex = Executors.newSingleThreadScheduledExecutor(); + + @SubscribeEvent + public void onStompDied(StompDiedEvent event) { + logger.info("Stomp Connection closed, trying to reconnect - {} - {}", event.reason, event.code); + connectStomp(); + } + + public void connectStomp() { + ex.schedule(() -> { + if (AuthManager.getInstance().getToken() == null) return; + try { + if (stompConnection != null) { + stompConnection.disconnect(); + } + stompConnection = new StompClient(new URI(StompManager.STOMP_URL), AuthManager.getInstance().getToken()); + MinecraftForge.EVENT_BUS.post(new StompConnectedEvent(stompConnection)); + } catch (Exception e) { + logger.error("Failed to connect to Stomp with message: {}", String.valueOf(Throwables.getRootCause(e))); + } + + }, 5L, TimeUnit.SECONDS); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompPayload.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompPayload.java new file mode 100644 index 00000000..8bfb8543 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompPayload.java @@ -0,0 +1,96 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.stomp; + +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.*; + +@Data +@Accessors(chain = true, fluent = true) +public class StompPayload { + private StompHeader method; + private Map headers = new HashMap<>(); + private String payload; + + public StompPayload header(String key, String value) { + headers.put(key, value); + return this; + } + + + public StompPayload destination(String value){ + headers.put("destination", value); + return this; + } + + public StompPayload id(String value){ + headers.put("id", value); + return this; + } + + public String getBuilt() { + StringBuilder sb = new StringBuilder(); + sb.append(method.name()); + sb.append("\n"); + for (Map.Entry stringStringEntry : headers.entrySet()) { + sb.append(stringStringEntry.getKey()); + sb.append(":"); + sb.append(stringStringEntry.getValue()); + sb.append("\n"); + if (stringStringEntry.getKey().contains(":")) throw new IllegalStateException("Illegal Character : inside headers"); + if (stringStringEntry.getValue().contains(":")) throw new IllegalStateException("Illegal Character : inside headers"); + } + sb.append("\n"); + if (payload != null) + sb.append(payload); + sb.append((char) 0); + if (FeatureRegistry.DEBUG.isEnabled()) System.out.println("Sending.. "+ sb); + return sb.toString(); + } + + public static StompPayload parse(String payload) { + if (FeatureRegistry.DEBUG.isEnabled()) System.out.println("Receving.. "+payload); + + Scanner scanner = new Scanner(payload); + StompPayload stompPayload = new StompPayload(); + stompPayload.method = StompHeader.valueOf(scanner.nextLine()); + String line; + while (!(line = scanner.nextLine()).isEmpty()) { + int index = line.indexOf(":"); + if (index == -1) throw new IllegalArgumentException("No : found in headers section"); + String name = line.substring(0, index); + String value; + if (index == line.length() - 1) + value = ""; + else + value = line.substring(index+1); + stompPayload.headers.put(name, value); + } + + List lines = new ArrayList<>(); + while (scanner.hasNextLine() && !(line = scanner.nextLine()).equals("\0")) { + lines.add(line); + } + stompPayload.payload = String.join("\n", lines); + return stompPayload; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompSubscription.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompSubscription.java new file mode 100644 index 00000000..965eaae9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompSubscription.java @@ -0,0 +1,6 @@ +package kr.syeyoung.dungeonsguide.mod.stomp; + +@FunctionalInterface +public interface StompSubscription { + void process(StompClient stompInterface, String stompPayload); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/AhUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/AhUtils.java new file mode 100644 index 00000000..6e6bdf52 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/AhUtils.java @@ -0,0 +1,98 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import com.google.common.base.Throwables; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import kr.syeyoung.dungeonsguide.auth.AuthManager; +import kr.syeyoung.dungeonsguide.auth.AuthUtil; +import kr.syeyoung.dungeonsguide.mod.events.impl.AuthChangedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import java.security.*; +import java.security.cert.CertificateException; +import java.util.*; + +public class AhUtils { + public static volatile Map auctions = new HashMap(); + + static Logger logger = LogManager.getLogger("AhUtils"); + + public static Timer timer = new Timer(); + + public static int totalAuctions = 0; + + @SubscribeEvent + public void onAuthChanged(AuthChangedEvent event) { + if(AuthManager.getInstance().isPlebUser()){ + registerTimer(); + } + } + + public static void registerTimer() { + timer.schedule(new TimerTask() { + public void run() { + try { + AhUtils.loadAuctions(); + } catch (CertificateException | NoSuchAlgorithmException | InvalidKeyException | InvalidAlgorithmParameterException | NoSuchPaddingException | BadPaddingException | KeyStoreException | IllegalBlockSizeException | KeyManagementException e) { + logger.error("Error loading auctions {}", String.valueOf(Throwables.getRootCause(e))); + } + } + }, 0L, 1800000L); + } + + public static void loadAuctions() throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchPaddingException, BadPaddingException, KeyStoreException, IllegalBlockSizeException, KeyManagementException { + try { + + Map semi_auctions = new HashMap(); + JsonElement object = AuthUtil.getJsonSecured("https://dungeons.guide/resource/keys"); + for (JsonElement element : object.getAsJsonArray()) { + JsonObject object1 = element.getAsJsonObject(); + AuctionData auctionData = new AuctionData(object1.get("id").getAsString()); + auctionData.lowestBin = object1.get("lowestBin").getAsInt(); + auctionData.sellPrice = object1.get("sellPrice").getAsInt(); + auctionData.buyPrice = object1.get("buyPrice").getAsInt(); + semi_auctions.put(auctionData.id, auctionData); + } + auctions = semi_auctions; + } catch (Throwable e) { + e.printStackTrace(); + } + } + + public static class AuctionData { + public String id; + + public long lowestBin = -1; + + public int sellPrice = -1; + + public int buyPrice = -1; + + public AuctionData(String id) { + this.id = id; + } + } +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ArrayUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ArrayUtils.java new file mode 100755 index 00000000..be5b1088 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ArrayUtils.java @@ -0,0 +1,40 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +public class ArrayUtils { + public static int[][] rotateCounterClockwise(int[][] arr) { + int[][] res = new int[arr[0].length][arr.length]; + for(int y=0; y cache = CacheBuilder.newBuilder() + .maximumSize(10000) + .expireAfterWrite(3, TimeUnit.SECONDS) + .build( + new CacheLoader() { + public IBlockState load(@NotNull BlockPos pos) { + return Minecraft.getMinecraft().theWorld.getBlockState(pos); + } + }); + + + @SuppressWarnings("UnstableApiUsage") + public IBlockState getBlockState(@NotNull BlockPos pos){ + if(FeatureRegistry.DEBUG_BLOCK_CACHING.isEnabled()){ + return cache.getUnchecked(pos); + } else { + return Minecraft.getMinecraft().theWorld.getBlockState(pos); + } + } + + + @SubscribeEvent @SuppressWarnings("UnstableApiUsage") + public void onWorldLoad(WorldEvent.Load e){ + cache.invalidateAll(); + } + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/GlStateUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/GlStateUtils.java new file mode 100644 index 00000000..4fee85d0 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/GlStateUtils.java @@ -0,0 +1,68 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import net.minecraft.client.renderer.GlStateManager; + +import java.lang.reflect.Field; +import java.util.*; + +public class GlStateUtils { + public static Map dumpStates() { + Map primitiveDump = new LinkedHashMap<>(); + try { + recursivelyDump(primitiveDump, "GlStateManager", null, GlStateManager.class); + } catch (IllegalAccessException e) { + e.printStackTrace(); + primitiveDump.put("$ERROR", true); + } + return primitiveDump; + } + + public static void printDump(Map dump) { + for (Map.Entry stringObjectEntry : dump.entrySet()) { + System.out.println(stringObjectEntry+": "+stringObjectEntry.getValue()); + } + } + + public static void compareDump(Map dump1, Map dump2) { + Set set = new HashSet<>(); + set.addAll(dump1.keySet()); + set.addAll(dump2.keySet()); + + for (String s : set) { + Object obj1 = dump1.get(s); + Object obj2 = dump2.get(s); + if (!Objects.equals(obj1, obj2)) System.out.println(s+": Prev {"+obj1+"} New {"+obj2+"}"); + } + } + + public static void recursivelyDump(Map primitiveDump, String objPath, Object obj, Class clazz) throws IllegalAccessException { + primitiveDump.put(objPath+".$class", clazz.getName()); + for (Field declaredField : clazz.getDeclaredFields()) { + declaredField.setAccessible(true); + Object fieldData = declaredField.get(obj); + if (fieldData.getClass().getName().startsWith("java.lang")) { + primitiveDump.put(objPath+"."+declaredField.getName(), fieldData); + } else { + recursivelyDump(primitiveDump, objPath+"."+declaredField.getName(), fieldData, fieldData.getClass()); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/MapUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/MapUtils.java new file mode 100755 index 00000000..cf16cb93 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/MapUtils.java @@ -0,0 +1,176 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import lombok.Getter; +import net.minecraft.block.material.MapColor; + +import javax.vecmath.Vector2d; +import java.awt.*; +import java.awt.image.BufferedImage; + +public class MapUtils { + + private static Color[] colorMasks = new Color[128 * 128]; + @Getter + private static byte[] colors; + + public static void clearMap() { + colorMasks = new Color[128 * 128]; + colors = null; + } + + public static void record(byte[] colors, int x, int y, Color c) { + MapUtils.colors = colors; + colorMasks[y *128 +x] = c; + } + + public static byte getMapColorAt(byte[] colors, int x, int y) { + if (y <0 || y>= 128 || x < 0 || x >= 128) return 0; + return colors[y * 128 +x]; + } + + public static BufferedImage getImage() { + BufferedImage bufferedImage = new BufferedImage(128, 128,BufferedImage.TYPE_INT_ARGB); + if (colors == null) return bufferedImage; + Graphics graphics = bufferedImage.getGraphics(); + for (int y = 0; y < 128; y++) { + for (int x = 0; x <128; x++) { + bufferedImage.setRGB(x,y, getRGBColorAt(colors, x, y)); + if (colorMasks[y * 128 + x] != null) { + graphics.setColor(colorMasks[y *128 +x]); + graphics.drawLine(x,y,x,y); + } + } + } + return bufferedImage; + } + + public static int getRGBColorAt(byte[] colors, int x, int y) { + if (y <0 || y>= 128 || x < 0 || x >= 128) return 0; + int i = y * 128 +x; + int j = colors[i] & 255; + + int theColor; + if (j / 4 == 0) + { + theColor = (i + i / 128 & 1) * 8 + 16 << 24; + } + else + { + theColor = MapColor.mapColorArray[j / 4].getMapColor(j & 3); + } + + return theColor; + } + + public static Point findFirstColorWithIn(byte[] colors, byte color, Rectangle dimension) { + boolean found = true; + for (int y = dimension.y; y < (dimension.y + dimension.height);y++) { + for (int x = dimension.x; x < (dimension.x + dimension.width); x ++) { + if (getMapColorAt(colors, x ,y) == color && found) { + record(colors, x, y, new Color(255, 0, 0, 40)); + return new Point(x,y); + } + found = getMapColorAt(colors, x,y) == 0; + } + } + return null; + } + + public static Point findFirstColorWithInNegate(byte[] colors, byte color, Rectangle dimension) { + for (int y = dimension.y; y < (dimension.y + dimension.height);y++) { + for (int x = dimension.x; x < (dimension.x + dimension.width); x ++) { + if (getMapColorAt(colors, x ,y) != color) { + record(colors, x, y, new Color(255, 0, 0, 40)); + return new Point(x,y); + } + } + } + return null; + } + + public static int getWidthOfColorAt(byte[] colors, byte color, Point point) { + for (int x = point.x; x < 128; x++) { + record(colors, x, point.y, new Color(0, 255, 0, 40)); + if (getMapColorAt(colors, x, point.y) != color) return x - point.x; + } + return 128 - point.x; + } + public static int getHeightOfColorAt(byte[] colors, byte color, Point point) { + for (int y = point.y; y < 128; y++) { + record(colors, point.x, y, new Color(0, 255, 0, 40)); + if (getMapColorAt(colors, point.x,y) != color) return y - point.y; + } + return 128 - point.y; + } + + public static int getLengthOfColorExtending(byte[] colors, byte color, Point basePoint, Vector2d vector2d) { + for (int i = 0; i < 128; i++) { + int x = (int) (basePoint.x + vector2d.x * i); + int y = (int) (basePoint.y + vector2d.y * i); + record(colors, x, y, new Color(0, 0, 255, 40)); + if (getMapColorAt(colors, x,y) != color) return i; + } + return -1; + } + + + public static boolean matches(byte[] colors, byte[] stencil, int targetColor, int x, int y) { + for (int i = y; i < y + stencil.length; i++) { + for (int j = x; j < x + 8; j++) { + boolean current = getMapColorAt(colors, j, i) == targetColor; + boolean expected = ((stencil[i - y] >> (7-(j-x))) & 0x1) == 1; + if (current != expected) return false; + } + } + return true; + } + + public static int readDigit(byte[] colors, int x, int y) { + for (int i = 0; i < NUMBER_STENCIL.length; i++) { + if (matches(colors, NUMBER_STENCIL[i],34, x, y)) return i; + } + return -1; + } + public static int readNumber(byte[] colors, int x, int y, int gap) { + int number = 0; + for (int i = x; i < 128; i += gap) { + int digit = readDigit(colors, i, y); + if (digit != -1) number = number * 10 + digit; + } + return number; + } + + private static final byte[][] NUMBER_STENCIL = { + {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, + {0x0, 0x1E, 0x1E, 0x1E, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0x0}, + {0x0, 0x7F, 0x7F, 0x7F, 0x77, 0x77, 0x7, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x7F, 0x0}, + {0x0, 0x7F, 0x7F, 0x7F, 0x7, 0x7, 0x1F, 0x1F, 0x7, 0x7, 0x7F, 0x7F, 0x7F, 0x0}, + {0x0, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x7F, 0x7F, 0x7F, 0xE, 0xE, 0xE, 0x0}, + {0x0, 0x7F, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x7, 0x77, 0x77, 0x7F, 0x7F, 0x7F, 0x0}, + {0x0, 0x7F, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, + {0x0, 0x7F, 0x7F, 0x7F, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x0}, + {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x3E, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, + {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x7, 0x7F, 0x7F, 0x7F, 0x0} + }; + + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/RenderUtils.java new file mode 100755 index 00000000..065986c5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/RenderUtils.java @@ -0,0 +1,1372 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import kr.syeyoung.dungeonsguide.mod.config.types.AColor; +import kr.syeyoung.dungeonsguide.mod.dungeon.doorfinder.DungeonDoor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.*; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import javax.vecmath.Vector3f; +import java.awt.*; +import java.util.List; + +public class RenderUtils { + public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); + private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png"); + + /** + * Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0 + * And modified to fit out need. + * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE + * @author Moulberry + */ + public static void renderBeaconBeam(double x, double y, double z, AColor aColor, float partialTicks) { + Entity player = Minecraft.getMinecraft().thePlayer; + double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; + double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; + double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; +//because of the way 3D rendering is done, all coordinates are relative to the camera. This "resets" the "0,0,0" position to the location that is (0,0,0) in the world. + + + GlStateManager.pushMatrix(); + GlStateManager.translate(-playerX, -playerY, -playerZ); + int height = 300; + int bottomOffset = 0; + int topOffset = bottomOffset + height; + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + + Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GlStateManager.disableLighting(); + GlStateManager.disableDepth(); + GlStateManager.enableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + + double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double)partialTicks; + double d1 = MathHelper.func_181162_h(-time * 0.2D - (double)MathHelper.floor_double(-time * 0.1D)); + + int c = getColorAt(x,y,z, aColor); + float alpha = ((c >> 24) & 0xFF) / 255.0f; + + float r = ((c >> 16) & 0xFF) / 255f; + float g = ((c >> 8) & 0xFF) / 255f; + float b = (c & 0xFF) / 255f; + double d2 = time * 0.025D * -1.5D; + double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D; + double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D; + double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D; + double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D; + double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D; + double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D; + double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D; + double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D; + double d14 = -1.0D + d1; + double d15 = (double)(height) * 2.5D + d14; + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); + worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); + worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); + worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); + worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); + tessellator.draw(); + + double d12 = -1.0D + d1; + double d13 = height + d12; + + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); + worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); + tessellator.draw(); + + GlStateManager.enableDepth(); + + GlStateManager.popMatrix(); + } + + + public static void drawTexturedRect(float x, float y, float width, float height, int filter) { + drawTexturedRect(x, y, width, height, 0.0F, 1.0F, 0.0F, 1.0F, filter); + } + private static float zLevel = 0; + public static int scrollY = 0; + public static boolean allowScrolling; + public static int scrollX = 0; + + public static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) + { + float f = (float)(startColor >> 24 & 255) / 255.0F; + float f1 = (float)(startColor >> 16 & 255) / 255.0F; + float f2 = (float)(startColor >> 8 & 255) / 255.0F; + float f3 = (float)(startColor & 255) / 255.0F; + float f4 = (float)(endColor >> 24 & 255) / 255.0F; + float f5 = (float)(endColor >> 16 & 255) / 255.0F; + float f6 = (float)(endColor >> 8 & 255) / 255.0F; + float f7 = (float)(endColor & 255) / 255.0F; + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.shadeModel(7425); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos((double)right, (double)top, (double)0).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos((double)left, (double)top, (double)0).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos((double)left, (double)bottom, (double)0).color(f5, f6, f7, f4).endVertex(); + worldrenderer.pos((double)right, (double)bottom, (double)0).color(f5, f6, f7, f4).endVertex(); + tessellator.draw(); + GlStateManager.shadeModel(7424); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + } + + public static void drawRect(int left, int top, int right, int bottom, AColor color) + { + if (left < right) + { + int i = left; + left = right; + right = i; + } + + if (top < bottom) + { + int j = top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color.getRGB() >> 24 & 255) / 255.0F; + float f = (float)(color.getRGB() >> 16 & 255) / 255.0F; + float f1 = (float)(color.getRGB() >> 8 & 255) / 255.0F; + float f2 = (float)(color.getRGB() & 255) / 255.0F; + if (!color.isChroma() && f3 == 0) return; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + if (!color.isChroma()) { + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(left, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, top, 0.0D).endVertex(); + worldrenderer.pos(left, top, 0.0D).endVertex(); + } else { + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + GlStateManager.shadeModel(GL11.GL_SMOOTH); + color(worldrenderer.pos(left, bottom, 0.0D), getColorAt(left, bottom, color)).endVertex(); + color(worldrenderer.pos(right, bottom, 0.0D), getColorAt(right, bottom, color)).endVertex(); + color(worldrenderer.pos(right, top, 0.0D), getColorAt(right, top, color)).endVertex(); + color(worldrenderer.pos(left, top, 0.0D), getColorAt(left, top, color)).endVertex(); + } + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + + public static void drawRoundedRectangle(int x, int y, int width, int height, int radius, double delta, int color) { + GlStateManager.pushMatrix(); + GlStateManager.translate(width/2.0+x, height/2.0+y, 0); + Tessellator t = Tessellator.getInstance(); + GlStateManager.disableTexture2D(); + RenderUtils.GL_SETCOLOR(color); + WorldRenderer wr = t.getWorldRenderer(); + wr.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION); + for (double i = 0.1; i < Math.PI*2; i+= delta) { + double cos = MathHelper.cos((float) i); + double sin = MathHelper.sin((float) i); + if (cos * MathHelper.cos((float) (i + delta)) <= 0) { + wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), + cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius),0).endVertex(); + wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), + cos * radius + (cos > 0 ? -1 : 1) * (height/2.0 - radius),0).endVertex(); + } else if (sin * MathHelper.sin((float) (i+delta)) <= 0) { + wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), + cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); + wr.pos(sin * radius + (sin > 0 ? -1 : 1) * (width/2.0 - radius), + cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); + } else { + wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), + cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); + } + } + t.draw(); + GlStateManager.popMatrix(); + } + + public static void GL_SETCOLOR(int color) { + float f3 = (float)(color >> 24 & 255) / 255.0F; + float f = (float)(color >> 16 & 255) / 255.0F; + float f1 = (float)(color >> 8 & 255) / 255.0F; + float f2 = (float)(color & 255) / 255.0F; + GlStateManager.color(f, f1, f2, f3); + } + + public static int blendTwoColors(int background, int newColor) { + float alpha = ((newColor >> 24) & 0xFF) /255.0f; + int r1 = (background >> 16) & 0xFF, r2 = (newColor >> 16) & 0xFF; + int g1 = (background >> 8) & 0xFF, g2 = (newColor >> 8) & 0xFF; + int b1 = (background) & 0xFF, b2 = (newColor) & 0xFF; + + int rr = (int) (r1 + (r2-r1) * alpha) & 0xFF; + int rg = (int) (g1 + (g2-g1) * alpha) & 0xFF; + int rb = (int) (b1 + (b2-b1) * alpha) & 0xFF; + return 0xFF000000 | ((rr << 16) & 0xFF0000) | ((rg << 8) & 0xFF00) | (rb & 0xFF); + } + + public static int blendAlpha(int origColor, float alphaPerc) { + return blendTwoColors(origColor, (int)(alphaPerc*255) << 24 | 0xFFFFFF); + } + + public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { + GlStateManager.enableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); + GL11.glTexParameteri(3553, 10241, filter); + GL11.glTexParameteri(3553, 10240, filter); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); + worldrenderer.pos(x + width, y + height, 0.0D).tex(uMax, vMax).endVertex(); + worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); + worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); + tessellator.draw(); + GL11.glTexParameteri(3553, 10241, 9728); + GL11.glTexParameteri(3553, 10240, 9728); + GlStateManager.disableBlend(); + } + public static void renderBar(float x, float y, float xSize, float completed) { + Minecraft.getMinecraft().getTextureManager().bindTexture(icons); + completed = (float)Math.round(completed / 0.05F) * 0.05F; + float notcompleted = 1.0F - completed; + int displayNum = 0; + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + float width = 0.0F; + if (completed < 0.5F && (displayNum == 1 || displayNum == 0)) { + width = (0.5F - completed) * xSize; + drawTexturedRect(x + xSize * completed, y, width, 5.0F, xSize * completed / 256.0F, xSize / 2.0F / 256.0F, 0.2890625F, 0.30859375F, 9728); + } + + if (completed < 1.0F && (displayNum == 2 || displayNum == 0)) { + width = Math.min(xSize * notcompleted, xSize / 2.0F); + drawTexturedRect(x + xSize / 2.0F + Math.max(xSize * (completed - 0.5F), 0.0F), y, width, 5.0F, (182.0F - xSize / 2.0F + Math.max(xSize * (completed - 0.5F), 0.0F)) / 256.0F, 0.7109375F, 0.2890625F, 0.30859375F, 9728); + } + + if (completed > 0.0F && (displayNum == 3 || displayNum == 0)) { + width = Math.min(xSize * completed, xSize / 2.0F); + drawTexturedRect(x, y, width, 5.0F, 0.0F, width / 256.0F, 0.30859375F, 0.328125F, 9728); + } + + if (completed > 0.5F && (displayNum == 4 || displayNum == 0)) { + width = Math.min(xSize * (completed - 0.5F), xSize / 2.0F); + drawTexturedRect(x + xSize / 2.0F, y, width, 5.0F, (182.0F - xSize / 2.0F) / 256.0F, (182.0F - xSize / 2.0F + width) / 256.0F, 0.30859375F, 0.328125F, 9728); + } + + } + + public static void drawUnfilledBox(int left, int top, int right, int bottom, int color, boolean chroma) + { + if (left < right) + { + int i = left; + left = right; + right = i; + } + + if (top < bottom) + { + int j = top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color >> 24 & 255) / 255.0F; + float f = (float)(color >> 16 & 255) / 255.0F; + float f1 = (float)(color >> 8 & 255) / 255.0F; + float f2 = (float)(color & 255) / 255.0F; + if (!chroma && f3 == 0) return; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + if (!chroma) { + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); + worldrenderer.pos(left, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, top, 0.0D).endVertex(); + worldrenderer.pos(left, top, 0.0D).endVertex(); + } else { + worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR); + float blah = (System.currentTimeMillis() / 10) % 360; + GlStateManager.shadeModel(GL11.GL_SMOOTH); + color(worldrenderer.pos(left, bottom, 0.0D), Color.HSBtoRGB((((blah + 20) % 360) / 360.0f), 1, 1)).endVertex(); + color(worldrenderer.pos(right, bottom, 0.0D), Color.HSBtoRGB((((blah + 40) % 360) / 360.0f), 1, 1)).endVertex(); + color(worldrenderer.pos(right, top, 0.0D), Color.HSBtoRGB((((blah + 20) % 360) / 360.0f), 1, 1)).endVertex(); + color(worldrenderer.pos(left, top, 0.0D), Color.HSBtoRGB(blah / 360.0f, 1, 1)).endVertex(); + } + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + + public static void drawUnfilledBox(int left, int top, int right, int bottom, AColor color) + { + if (left < right) + { + int i = left; + left = right; + right = i; + } + + if (top < bottom) + { + int j = top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color.getRGB() >> 24 & 255) / 255.0F; + float f = (float)(color.getRGB() >> 16 & 255) / 255.0F; + float f1 = (float)(color.getRGB() >> 8 & 255) / 255.0F; + float f2 = (float)(color.getRGB() & 255) / 255.0F; + if (!color.isChroma() && f3 == 0) return; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + if (!color.isChroma()) { + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); + worldrenderer.pos(left, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, top, 0.0D).endVertex(); + worldrenderer.pos(left, top, 0.0D).endVertex(); + } else { + worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR); + GlStateManager.shadeModel(GL11.GL_SMOOTH); + color(worldrenderer.pos(left, bottom, 0.0D), getColorAt(left, bottom, color)).endVertex(); + color(worldrenderer.pos(right, bottom, 0.0D), getColorAt(right, bottom, color)).endVertex(); + color(worldrenderer.pos(right, top, 0.0D), getColorAt(right, top, color)).endVertex(); + color(worldrenderer.pos(left, top, 0.0D), getColorAt(left, top, color)).endVertex(); + } + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static int getChromaColorAt(int x, int y, float speed, float s, float b, float alpha) { + double blah = ((double)(speed) * (System.currentTimeMillis() / 2)) % 360; + return (Color.HSBtoRGB((float) (((blah - (x + y) / 2.0f) % 360) / 360.0f), s,b) & 0xffffff) + | (((int)(alpha * 255)<< 24) & 0xff000000); + } + public static int getColorAt(double x, double y, AColor color) { + if (!color.isChroma()) + return color.getRGB(); + + double blah = ((double)(color.getChromaSpeed()) * (System.currentTimeMillis() / 2)) % 360; + float[] hsv = new float[3]; + Color.RGBtoHSB(color.getRed(), color.getBlue(), color.getGreen(), hsv); + + + return (Color.HSBtoRGB((float) (((blah - (x + y) / 2.0f) % 360) / 360.0f), hsv[1],hsv[2]) & 0xffffff) + | ((color.getAlpha() << 24) & 0xff000000); + } + public static int getColorAt(double x, double y,double z, AColor color) { + if (!color.isChroma()) + return color.getRGB(); + + double blah = ((double)(color.getChromaSpeed()) * (System.currentTimeMillis() / 2)) % 360; + float[] hsv = new float[3]; + Color.RGBtoHSB(color.getRed(), color.getBlue(), color.getGreen(), hsv); + + + return (Color.HSBtoRGB((float) (((blah - ((x + y+z) / 2.0f) % 360)) / 360.0f), hsv[1],hsv[2]) & 0xffffff) + | ((color.getAlpha() << 24) & 0xff000000); + } + + public static WorldRenderer color(WorldRenderer worldRenderer, int color ){ + return worldRenderer.color(((color >> 16) & 0xFF) / 255.0f, ((color >> 8) & 0xFF) / 255.0f, (color &0xFF) / 255.0f, ((color >> 24) & 0xFF) / 255.0f); + } + + public static void renderDoor(DungeonDoor dungeonDoor, float partialTicks) { + Entity player = Minecraft.getMinecraft().thePlayer; + double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; + double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; + double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; + + GlStateManager.pushMatrix(); + GlStateManager.translate(-playerX, -playerY, -playerZ); + GlStateManager.disableTexture2D(); + GlStateManager.enableAlpha(); + + if (dungeonDoor.getType().isExist()) + GlStateManager.color(0,1,0,1); + else + GlStateManager.color(1,0,0,1); + + double x = dungeonDoor.getPosition().getX() + 0.5; + double y = dungeonDoor.getPosition().getY() -0.99; + double z = dungeonDoor.getPosition().getZ() + 0.5; + GL11.glBegin(GL11.GL_QUADS); + + GL11.glVertex3d(x - 2.5, y, z - 2.5); + GL11.glVertex3d(x - 2.5, y, z + 2.5); + GL11.glVertex3d(x + 2.5, y, z + 2.5); + GL11.glVertex3d(x + 2.5, y, z - 2.5); + + GL11.glEnd(); + + if (dungeonDoor.getType().isExist()) { + GL11.glBegin(GL11.GL_QUADS); + + GlStateManager.color(0,0,1,1); + if (dungeonDoor.isZDir()) { + GL11.glVertex3d(x - 0.5, y + 0.1, z - 2.5); + GL11.glVertex3d(x - 0.5, y+ 0.1, z + 2.5); + GL11.glVertex3d(x + 0.5, y+ 0.1, z + 2.5); + GL11.glVertex3d(x + 0.5, y+ 0.1, z - 2.5); + } else { + GL11.glVertex3d(x - 2.5, y+ 0.1, z - 0.5); + GL11.glVertex3d(x - 2.5, y+ 0.1, z + 0.5); + GL11.glVertex3d(x + 2.5, y+ 0.1, z + 0.5); + GL11.glVertex3d(x + 2.5, y+ 0.1, z - 0.5); + } + + GL11.glEnd(); + } else { + GL11.glLineWidth(5); + GL11.glBegin(GL11.GL_LINE_LOOP); + GL11.glVertex3d(x - 2.5, y, z - 2.5); + GL11.glVertex3d(x + 2.5, y + 5, z - 2.5); + GL11.glVertex3d(x + 2.5, y, z + 2.5); + GL11.glVertex3d(x - 2.5, y + 5, z + 2.5); + GL11.glEnd(); + GL11.glBegin(GL11.GL_LINE_LOOP); + GL11.glVertex3d(x - 2.5, y +5, z - 2.5); + GL11.glVertex3d(x + 2.5, y, z - 2.5); + GL11.glVertex3d(x + 2.5, y + 5, z + 2.5); + GL11.glVertex3d(x - 2.5, y, z + 2.5); + GL11.glEnd(); + GL11.glLineWidth(1); + } +// GlStateManager.disableAlpha(); + GlStateManager.disableBlend(); + + GlStateManager.enableTexture2D(); + + + RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + GlStateManager.translate( dungeonDoor.getPosition().getX(), dungeonDoor.getPosition().getY(), dungeonDoor.getPosition().getZ()); + GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); + GlStateManager.rotate(renderManager.playerViewX, 1.0f, 0.0f, 0.0f); + + float lScale = 0.02f; + GlStateManager.scale(-lScale, -lScale, lScale); + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + String text = "Type: "+dungeonDoor.getType(); + int textWidth = fontRenderer.getStringWidth(text); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fontRenderer.drawString(text, -textWidth / 2, 0, 0xFF00FFFF); + + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GlStateManager.popMatrix(); + } + + public static void drawLine(Vec3 pos1, Vec3 pos2, Color colour, float partialTicks , boolean depth) { + Entity render = Minecraft.getMinecraft().getRenderViewEntity(); + WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); + + double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks; + double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks; + double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks; + + GlStateManager.pushMatrix(); + GlStateManager.translate(-realX, -realY, -realZ); + GlStateManager.disableTexture2D(); + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GL11.glLineWidth(2); + GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f); + worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + + worldRenderer.pos(pos1.xCoord, pos1.yCoord, pos1.zCoord).endVertex(); + worldRenderer.pos(pos2.xCoord, pos2.yCoord, pos2.zCoord).endVertex(); + Tessellator.getInstance().draw(); + + GlStateManager.translate(realX, realY, realZ); + GlStateManager.disableBlend(); + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.popMatrix(); + } + + public static void drawLinesVec3(List poses, AColor colour, float thickness, float partialTicks, boolean depth) { + Entity render = Minecraft.getMinecraft().getRenderViewEntity(); + WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); + + double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks; + double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks; + double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks; + + GlStateManager.pushMatrix(); + GlStateManager.translate(-realX, -realY, -realZ); + GlStateManager.disableTexture2D(); + GlStateManager.disableLighting(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GL11.glLineWidth(thickness); + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + +// GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f); + GlStateManager.color(1,1,1,1); + worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); + int num = 0; + for (Vec3 pos:poses) { + int i = getColorAt(num++ * 10,0, colour); + worldRenderer.pos(pos.xCoord, pos.yCoord, pos.zCoord).color( + ((i >> 16) &0xFF)/255.0f, + ((i >> 8) &0xFF)/255.0f, + (i &0xFF)/255.0f, + ((i >> 24) &0xFF)/255.0f + ).endVertex(); + } + Tessellator.getInstance().draw(); + + GlStateManager.translate(realX, realY, realZ); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.popMatrix(); + GL11.glLineWidth(1); + } + public static void drawLines(List poses, AColor colour, float thickness, float partialTicks, boolean depth) { + Entity render = Minecraft.getMinecraft().getRenderViewEntity(); + WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); + + double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks; + double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks; + double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks; + + GlStateManager.pushMatrix(); + GlStateManager.translate(-realX, -realY, -realZ); + GlStateManager.disableTexture2D(); + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GL11.glLineWidth(thickness); + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + +// GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f); + GlStateManager.color(1,1,1,1); + worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); + int num = 0; + for (BlockPos pos:poses) { + int i = getColorAt(num++ * 10,0, colour); + worldRenderer.pos(pos.getX() +0.5, pos.getY() +0.5, pos.getZ() +0.5).color( + ((i >> 16) &0xFF)/255.0f, + ((i >> 8) &0xFF)/255.0f, + (i &0xFF)/255.0f, + ((i >> 24) &0xFF)/255.0f + ).endVertex(); + } + Tessellator.getInstance().draw(); + + GlStateManager.translate(realX, realY, realZ); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.popMatrix(); + GL11.glLineWidth(1); + } + + public static void drawLines(List poses, Color colour, float thickness, float partialTicks, boolean depth) { + if (colour instanceof AColor) drawLines(poses, (AColor)colour, thickness, partialTicks,depth); + Entity render = Minecraft.getMinecraft().getRenderViewEntity(); + WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); + + double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks; + double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks; + double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks; + + GlStateManager.pushMatrix(); + GlStateManager.translate(-realX, -realY, -realZ); + GlStateManager.disableTexture2D(); + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GL11.glLineWidth(thickness); + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + + GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f); + worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION); + for (BlockPos pos:poses) { + worldRenderer.pos(pos.getX() +0.5, pos.getY() +0.5, pos.getZ() +0.5).endVertex(); + } + Tessellator.getInstance().draw(); + + GlStateManager.translate(realX, realY, realZ); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.popMatrix(); + } + + public static void highlightBlock(BlockPos blockpos, Color c, float partialTicks) { + highlightBlock(blockpos,c,partialTicks,false); + } + public static void highlightBlock(BlockPos blockpos, Color c, float partialTicks, boolean depth) { + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableTexture2D(); + + if (!depth) { + GlStateManager.disableDepth(); GL11.glDisable(GL11.GL_DEPTH_TEST); + GlStateManager.depthMask(false); + } + GlStateManager.color(c.getRed() /255.0f, c.getGreen() / 255.0f, c.getBlue()/ 255.0f, c.getAlpha()/ 255.0f); + + GlStateManager.translate(blockpos.getX(), blockpos.getY(), blockpos.getZ()); + + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 0, 1); + GL11.glVertex3d(0, 1, 1); + GL11.glVertex3d(0, 1, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(1, 0, 1); + GL11.glVertex3d(1, 0, 0); + GL11.glVertex3d(1, 1, 0); + GL11.glVertex3d(1, 1, 1); + + GL11.glVertex3d(0, 1, 1); + GL11.glVertex3d(0, 0, 1); + GL11.glVertex3d(1, 0, 1); + GL11.glVertex3d(1, 1, 1); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 1, 0); + GL11.glVertex3d(1, 1, 0); + GL11.glVertex3d(1, 0, 0); + + GL11.glVertex3d(0,1,0); + GL11.glVertex3d(0,1,1); + GL11.glVertex3d(1,1,1); + GL11.glVertex3d(1,1,0); + + GL11.glVertex3d(0,0,1); + GL11.glVertex3d(0,0,0); + GL11.glVertex3d(1,0,0); + GL11.glVertex3d(1,0,1); + + + + GL11.glEnd(); + + + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.enableTexture2D(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + + +//... + + } + + public static void highlightBox(AxisAlignedBB axisAlignedBB, Color c, float partialTicks, boolean depth) { + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.disableTexture2D(); + + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + int rgb = c.getRGB(); + GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f); + + GlStateManager.translate(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ); + + double x = axisAlignedBB.maxX - axisAlignedBB.minX; + double y = axisAlignedBB.maxY - axisAlignedBB.minY; + double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, 0, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, y, z); + + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, y, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, 0, 0); + + GL11.glVertex3d(0,y,0); + GL11.glVertex3d(0,y,z); + GL11.glVertex3d(x,y,z); + GL11.glVertex3d(x,y,0); + + GL11.glVertex3d(0,0,z); + GL11.glVertex3d(0,0,0); + GL11.glVertex3d(x,0,0); + GL11.glVertex3d(x,0,z); + + + + GL11.glEnd(); + + + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.enableTexture2D(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + } + public static void highlightBoxAColor(AxisAlignedBB axisAlignedBB, AColor c, float partialTicks, boolean depth) { + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.disableTexture2D(); + + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + int rgb = RenderUtils.getColorAt(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ, c); + GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f); + + GlStateManager.translate(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ); + + double x = axisAlignedBB.maxX - axisAlignedBB.minX; + double y = axisAlignedBB.maxY - axisAlignedBB.minY; + double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, 0, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, y, z); + + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, y, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, 0, 0); + + GL11.glVertex3d(0,y,0); + GL11.glVertex3d(0,y,z); + GL11.glVertex3d(x,y,z); + GL11.glVertex3d(x,y,0); + + GL11.glVertex3d(0,0,z); + GL11.glVertex3d(0,0,0); + GL11.glVertex3d(x,0,0); + GL11.glVertex3d(x,0,z); + + + + GL11.glEnd(); + + + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.enableTexture2D(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + } + public static void highlightBox(Entity entity, AxisAlignedBB axisAlignedBB, AColor c, float partialTicks, boolean depth) { + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableTexture2D(); + + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + int rgb = RenderUtils.getColorAt(entity.posX * 10,entity.posY * 10,c); + GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f); + if (axisAlignedBB == null) { + if (entity instanceof EntityArmorStand) { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); + } else if (entity instanceof EntityBat) { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.4, -0.4, 0.4, 0.4, 0.4); + } else { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); + } + } + + Vec3 renderPos = new Vec3( + (float) (entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks), + (float) (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks), + (float) (entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks) + ); + GlStateManager.translate(axisAlignedBB.minX + renderPos.xCoord, axisAlignedBB.minY + renderPos.yCoord, axisAlignedBB.minZ + renderPos.zCoord); + + double x = axisAlignedBB.maxX - axisAlignedBB.minX; + double y = axisAlignedBB.maxY - axisAlignedBB.minY; + double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, 0, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, y, z); + + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, y, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, 0, 0); + + GL11.glVertex3d(0,y,0); + GL11.glVertex3d(0,y,z); + GL11.glVertex3d(x,y,z); + GL11.glVertex3d(x,y,0); + + GL11.glVertex3d(0,0,z); + GL11.glVertex3d(0,0,0); + GL11.glVertex3d(x,0,0); + GL11.glVertex3d(x,0,z); + + + + GL11.glEnd(); + + + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.enableTexture2D(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + } + + public static void highlightBox(Entity entity, AxisAlignedBB axisAlignedBB, Color c, float partialTicks, boolean depth) { + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableTexture2D(); + + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + GlStateManager.color(c.getRed()/ 255.0f, c.getGreen()/ 255.0f, c.getBlue()/ 255.0f, c.getAlpha()/ 255.0f); + if (axisAlignedBB == null) { + if (entity instanceof EntityArmorStand) { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); + } else if (entity instanceof EntityBat) { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.4, -0.4, 0.4, 0.4, 0.4); + } else { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); + } + } + + Vec3 renderPos = new Vec3( + (float) (entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks), + (float) (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks), + (float) (entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks) + ); + GlStateManager.translate(axisAlignedBB.minX + renderPos.xCoord, axisAlignedBB.minY + renderPos.yCoord, axisAlignedBB.minZ + renderPos.zCoord); + + double x = axisAlignedBB.maxX - axisAlignedBB.minX; + double y = axisAlignedBB.maxY - axisAlignedBB.minY; + double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, 0, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, y, z); + + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, y, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, 0, 0); + + GL11.glVertex3d(0,y,0); + GL11.glVertex3d(0,y,z); + GL11.glVertex3d(x,y,z); + GL11.glVertex3d(x,y,0); + + GL11.glVertex3d(0,0,z); + GlStateManager.disableDepth(); + GL11.glVertex3d(0,0,0); + GL11.glVertex3d(x,0,0); + GL11.glVertex3d(x,0,z); + + + + GL11.glEnd(); + + + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + } + public static void highlightBox(Entity entity, Color c, float partialTicks, boolean depth) { + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableTexture2D(); + + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + GlStateManager.color(c.getRed()/ 255.0f, c.getGreen()/ 255.0f, c.getBlue()/ 255.0f, c.getAlpha()/ 255.0f); + AxisAlignedBB axisAlignedBB; + if (entity instanceof EntityArmorStand) { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); + } else if (entity instanceof EntityBat) { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.4, -0.4, 0.4, 0.4, 0.4); + } else { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); + } + + Vec3 renderPos = new Vec3( + (float) (entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks), + (float) (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks), + (float) (entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks) + ); + GlStateManager.translate(axisAlignedBB.minX + renderPos.xCoord, axisAlignedBB.minY + renderPos.yCoord, axisAlignedBB.minZ + renderPos.zCoord); + + double x = axisAlignedBB.maxX - axisAlignedBB.minX; + double y = axisAlignedBB.maxY - axisAlignedBB.minY; + double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, 0, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, y, z); + + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, y, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, 0, 0); + + GL11.glVertex3d(0,y,0); + GL11.glVertex3d(0,y,z); + GL11.glVertex3d(x,y,z); + GL11.glVertex3d(x,y,0); + + GL11.glVertex3d(0,0,z); + GL11.glVertex3d(0,0,0); + GL11.glVertex3d(x,0,0); + GL11.glVertex3d(x,0,z); + + + + GL11.glEnd(); + + + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + + +//... + + } + + public static void highlightBox(Entity entity, AColor c, float partialTicks, boolean depth) { + Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); + + double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); + double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); + double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); + + GlStateManager.pushMatrix(); + + GlStateManager.translate(-x_fix, -y_fix, -z_fix); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableTexture2D(); + + if (!depth) { + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + } + + int rgb = RenderUtils.getColorAt(entity.posX % 20,entity.posY % 20,c); + GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f); + + AxisAlignedBB axisAlignedBB; + if (entity instanceof EntityArmorStand) { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); + } else if (entity instanceof EntityBat) { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.4, -0.4, 0.4, 0.4, 0.4); + } else { + axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); + } + + Vec3 renderPos = new Vec3( + (float) (entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks), + (float) (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks), + (float) (entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks) + ); + GlStateManager.translate(axisAlignedBB.minX + renderPos.xCoord, axisAlignedBB.minY + renderPos.yCoord, axisAlignedBB.minZ + renderPos.zCoord); + + double x = axisAlignedBB.maxX - axisAlignedBB.minX; + double y = axisAlignedBB.maxY - axisAlignedBB.minY; + double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, 0, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, y, z); + + GL11.glVertex3d(0, y, z); + GL11.glVertex3d(0, 0, z); + GL11.glVertex3d(x, 0, z); + GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT + + GL11.glVertex3d(0, 0, 0); + GL11.glVertex3d(0, y, 0); + GL11.glVertex3d(x, y, 0); + GL11.glVertex3d(x, 0, 0); + + GL11.glVertex3d(0,y,0); + GL11.glVertex3d(0,y,z); + GL11.glVertex3d(x,y,z); + GL11.glVertex3d(x,y,0); + + GL11.glVertex3d(0,0,z); + GL11.glVertex3d(0,0,0); + GL11.glVertex3d(x,0,0); + GL11.glVertex3d(x,0,z); + + + + GL11.glEnd(); + + + if (!depth) { + GlStateManager.enableDepth(); + GlStateManager.depthMask(true); + } + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + + + +//... + + } + public static void drawTextAtWorld(String text, float x, float y, float z, int color, float scale, boolean increase, boolean renderBlackBox, float partialTicks) { + float lScale = scale; + + RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + Vector3f renderPos = getRenderPos(x, y, z, partialTicks); + + if (increase) { + double distance = Math.sqrt(renderPos.x * renderPos.x + renderPos.y * renderPos.y + renderPos.z * renderPos.z); + double multiplier = distance / 120f; //mobs only render ~120 blocks away + lScale *= 0.45f * multiplier; + } + + GlStateManager.color(1f, 1f, 1f, 0.5f); + GlStateManager.pushMatrix(); + GlStateManager.translate(renderPos.x, renderPos.y, renderPos.z); + GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); + GlStateManager.rotate(renderManager.playerViewX, 1.0f, 0.0f, 0.0f); + GlStateManager.scale(-lScale, -lScale, lScale); + GlStateManager.disableLighting(); + GlStateManager.depthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + int textWidth = fontRenderer.getStringWidth(text); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + if (renderBlackBox) { + double j = textWidth / 2; + GlStateManager.disableTexture2D(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldRenderer.pos(-j - 1, -1, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldRenderer.pos(-j - 1, 8, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldRenderer.pos(j + 1, 8, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + worldRenderer.pos(j + 1, -1, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + } + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + fontRenderer.drawString(text, -textWidth / 2, 0, color); + + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GlStateManager.depthMask(true); + GlStateManager.enableDepth(); + GlStateManager.popMatrix(); + } + + public static Vector3f getRenderPos(float x, float y, float z, float partialTicks) { + EntityPlayerSP sp = Minecraft.getMinecraft().thePlayer; + return new Vector3f( + x - (float) (sp.lastTickPosX + (sp.posX - sp.lastTickPosX) * partialTicks), + y - (float) (sp.lastTickPosY + (sp.posY - sp.lastTickPosY) * partialTicks), + z - (float) (sp.lastTickPosZ + (sp.posZ - sp.lastTickPosZ) * partialTicks) + ); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ScoreBoardUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ScoreBoardUtils.java new file mode 100644 index 00000000..b14041e8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ScoreBoardUtils.java @@ -0,0 +1,58 @@ +package kr.syeyoung.dungeonsguide.mod.utils; + +import net.minecraft.client.Minecraft; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; + +import java.util.function.Consumer; + +public class ScoreBoardUtils { + + public static void forEachLine(Consumer lineConsumer){ + Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + for (Score sc : scoreboard.getSortedScores(objective)) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String line = ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()).trim(); + String stripped = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(line)); +// if (line.contains("[") && line.endsWith("โค")) { +// String name = stripped.split(" ")[stripped.split(" ").length - 2]; +// int health = Integer.parseInt(stripped.split(" ")[stripped.split(" ").length - 1]); +// if (health < lowestHealth) { +// lowestHealth = health; +// lowestHealthName = name; +// } +// } + + lineConsumer.accept(line); + + } + } + + public static void forEachLineClean(Consumer lineConsumer){ + Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); + ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); + for (Score sc : scoreboard.getSortedScores(objective)) { + ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); + String line = ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()).trim(); + String stripped = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(line)); +// if (line.contains("[") && line.endsWith("โค")) { +// String name = stripped.split(" ")[stripped.split(" ").length - 2]; +// int health = Integer.parseInt(stripped.split(" ")[stripped.split(" ").length - 1]); +// if (health < lowestHealth) { +// lowestHealth = health; +// lowestHealthName = name; +// } +// } + + lineConsumer.accept(stripped); + + } + } + + + + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ShortUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ShortUtils.java new file mode 100755 index 00000000..523988d1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/ShortUtils.java @@ -0,0 +1,47 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +public class ShortUtils { + public static short rotateCounterClockwise(short integer) { + int res = 0; + for(int i=0; i<16; i++){ + int x = i % 4; + int y = i / 4; + res |= (integer >> i & 0x1) << ((4-x-1)*4 + y); + } + return (short) (res & 0xFFFF); + } + public static short rotateClockwise(short integer) { + int res = 0; + for(int i=0; i<16; i++){ + int x = i % 4; + int y = i / 4; + res |= (integer >> i & 0x1) << (x *4 +(4 - y - 1)); + } + return (short) (res & 0xFFFF); + } + + public static short topLeftifyInt(short integer) { + int it = integer & 0xFFFF; + while ((it & (0x1111)) == 0) it >>= 1; + while ((it & (0xF)) == 0) it >>= 4; + return (short) (it & 0xFFFF); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java new file mode 100755 index 00000000..6d7af229 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java @@ -0,0 +1,52 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +public class SkyblockUtils { + public static long getSkyblockYear() throws IOException { + URL url = new URL("https://hypixel-api.inventivetalent.org/api/skyblock/calendar"); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream()); + JsonObject object = (JsonObject) new JsonParser().parse(inputStreamReader); + if (!object.get("success").getAsBoolean()) { + return -1; + } + long now = System.currentTimeMillis() / 1000; + + JsonObject real = object.getAsJsonObject("real"); + long secondsPerYear = real.get("SECONDS_PER_MONTH").getAsLong() * 12; + JsonObject lastLog = object.getAsJsonObject("lastLog"); + long lastTime = lastLog.get("time").getAsLong(); + long year = lastLog.get("year").getAsLong(); + + long passedTime = now - lastTime; + year += passedTime / secondsPerYear; + return year; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TabListUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TabListUtil.java new file mode 100644 index 00000000..91ccb4fd --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TabListUtil.java @@ -0,0 +1,75 @@ +package kr.syeyoung.dungeonsguide.mod.utils; + +import kr.syeyoung.dungeonsguide.mod.features.impl.dungeon.FeatureDungeonMap; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TabListUtil { + final static Pattern tabListRegex = Pattern.compile("\\*[a-zA-Z0-9_]{2,16}\\*", Pattern.MULTILINE); + + public static List getPlayersInDungeon(){ + List players = new ArrayList<>(); + List list = FeatureDungeonMap.sorter.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); + + if(list.size() >= 20){ + for (int i = 1; i < 20; i++) { + + String na = getPlayerNameWithChecks(list.get(i)); + + if(na != null){ + players.add(na); + } + } + } + + return players; + } + + /** + * We make sure that the player is alive and regex their name out + * @param networkPlayerInfo the network player info of player + * @return the username of player + */ + @Nullable + public static String getPlayerNameWithChecks(NetworkPlayerInfo networkPlayerInfo) { + String name; + if (networkPlayerInfo.getDisplayName() != null) { + name = networkPlayerInfo.getDisplayName().getFormattedText(); + } else { + name = ScorePlayerTeam.formatPlayerName( + networkPlayerInfo.getPlayerTeam(), + networkPlayerInfo.getGameProfile().getName() + ); + } + + if (name.trim().equals("ยงr") || name.startsWith("ยงr ")) return null; + + name = TextUtils.stripColor(name); + + if(name.contains("(DEAD)")) { + return null; + } + + return getString(name, tabListRegex); + } + + @Nullable + public static String getString(String name, Pattern tabListRegex) { + name = name.replace(" ", "*"); + + Matcher matcher = tabListRegex.matcher(name); + if (!matcher.find()) return null; + + name = matcher.group(0); + name = name.substring(0, name.length() - 1); + name = name.substring(1); + return name; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TextUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TextUtils.java new file mode 100755 index 00000000..1da4e8e7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TextUtils.java @@ -0,0 +1,121 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.regex.Pattern; + +public class TextUtils { + private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)ยง[0-9A-FK-OR]"); + + private static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile("[^a-z A-Z:0-9/'.]"); + + private static final Pattern INTEGER_CHARACTERS = Pattern.compile("[^0-9]"); + + public static String stripColor(String input) { + return STRIP_COLOR_PATTERN.matcher(input).replaceAll(""); + } + + public static String keepScoreboardCharacters(String text) { + return SCOREBOARD_CHARACTERS.matcher(text).replaceAll(""); + } + + public static String keepIntegerCharactersOnly(String text) { + return INTEGER_CHARACTERS.matcher(text).replaceAll(""); + } + + public static String join(List list, String delimeter) { + if (list.isEmpty()) return ""; + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < list.size() - 1; i++) { + stringBuilder.append(list.get(i).toString()).append(delimeter); + } + stringBuilder.append(list.get(list.size() - 1).toString()); + return stringBuilder.toString(); + } + + + private static final TreeMap suffixes = new TreeMap(); + + static { + suffixes.put(1000L, "k"); + suffixes.put(1000000L, "m"); + suffixes.put(1000000000L, "b"); + } + + public static String format(long value) { +// return String.valueOf(value); + if (value == Long.MIN_VALUE) + return format(-9223372036854775807L); + if (value < 0L) + return "-" + format(-value); + if (value < 1000L) + return Long.toString(value); + Map.Entry e = suffixes.floorEntry(value); + Long divideBy = e.getKey(); + String suffix = e.getValue(); + long truncated = value * 10 / divideBy ; + boolean hasDecimal = (truncated < 100L && (truncated / 10.0D) != (truncated / 10L)); + return hasDecimal ? ((truncated / 10.0D) + suffix) : ((truncated / 10L) + suffix); + } + public static long reverseFormat(String str2) { + String str = str2.toLowerCase(); + String integerPart = str.substring(0, str.length() - 1); + long multiplier = 1; + if (str.endsWith("k")) multiplier = 1000; + else if (str.endsWith("m")) multiplier = 1000000; + else if (str.endsWith("b")) multiplier = 1000000000; + else integerPart = str; + return (long) (Double.parseDouble(integerPart) * multiplier); + } + + public static String formatTime(long ms) { + long seconds = (long) Math.ceil(ms / 1000.0); + long hr = seconds / (60 * 60); seconds -= hr * 60 * 60; + long min = seconds / 60; seconds -= min * 60; + + StringBuilder stringBuilder = new StringBuilder(); + if (hr > 0) { + stringBuilder.append(hr).append("h "); + } + if (hr > 0 || min > 0) { + stringBuilder.append(min).append("m "); + } + if (hr > 0 || min > 0 || seconds > 0) { + stringBuilder.append(seconds).append("s "); + } + + return stringBuilder.toString(); + } + public static String insertDashUUID(String uuid) { + StringBuilder sb = new StringBuilder(uuid); + sb.insert(8, "-"); + sb = new StringBuilder(sb.toString()); + sb.insert(13, "-"); + sb = new StringBuilder(sb.toString()); + sb.insert(18, "-"); + sb = new StringBuilder(sb.toString()); + sb.insert(23, "-"); + + return sb.toString(); + } + +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TimeScoreUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TimeScoreUtil.java new file mode 100644 index 00000000..def77def --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TimeScoreUtil.java @@ -0,0 +1,82 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import kr.syeyoung.dungeonsguide.Main; +import org.apache.commons.io.IOUtils; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +public class TimeScoreUtil { + private static final TreeMap min8 = new TreeMap(); + private static final TreeMap min10 = new TreeMap(); + private static final TreeMap min12 = new TreeMap(); + public static void init() { + try { + load("8.csv", min8); + } catch (IOException e) { + e.printStackTrace(); + } + try { + load("10.csv", min10); + } catch (IOException e) { + e.printStackTrace(); + } + try { + load("12.csv", min12); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void load(String name, TreeMap minutes) throws IOException { + minutes.clear(); + List lines = IOUtils.readLines(Main.class.getResourceAsStream("/timescore/"+name)); + for (String line:lines) { + String[] split = line.split(","); + minutes.put(Integer.parseInt(split[0]), Integer.parseInt(split[1])); + } + } + + public static int estimate(int mills, int drop) { + if (drop == 600) return estimate(mills, min10); + if (drop == 480) return estimate(mills, min8); + if (drop == 720) return estimate(mills, min12); + return -1; + } + + private static int estimate(int mills, TreeMap lookup_table){ + Map.Entry high = lookup_table.ceilingEntry(mills); + Map.Entry low = lookup_table.floorEntry(mills); + + + if (low == null && high == null) return 0; + if (low == null) return high.getValue(); + if (high == null) return low.getValue(); + + int distHigh = high.getKey() - mills; + int distLow = mills - low.getKey(); + + if (distHigh > distLow) return high.getValue(); + else return low.getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TitleRender.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TitleRender.java new file mode 100644 index 00000000..dfc0b0a1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/TitleRender.java @@ -0,0 +1,139 @@ +package kr.syeyoung.dungeonsguide.mod.utils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.MathHelper; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * STOLEN FROM VANILLA 1.8.9, DONT @ ME + * CREDS TO MOJANG AND THE CREW + */ +public class TitleRender { + + Logger logger = LogManager.getLogger("TitleRender"); + + private static TitleRender instance; + public static TitleRender getInstance() { + return instance == null ? instance = new TitleRender() : instance; + } + + private TitleRender() { + MinecraftForge.EVENT_BUS.register(this); + } + + protected static int titlesTimer; + /** + * The current title displayed + */ + protected static String displayedTitle = ""; + /** + * The current sub-title displayed + */ + protected static String displayedSubTitle = ""; + /** + * The time that the title take to fade in + */ + protected static int titleFadeIn; + /** + * The time that the title is display + */ + protected static int titleDisplayTime; + + /** + * The time that the title take to fade out + */ + protected static int titleFadeOut; + Minecraft mc = Minecraft.getMinecraft(); + + FontRenderer fontRenderer = mc.fontRendererObj; + + + @SubscribeEvent + public void onClinetTick(TickEvent.ClientTickEvent e){ + if(e.phase == TickEvent.Phase.START){ + tick(); + } + } + + @SubscribeEvent + public void onGameOverLay(RenderGameOverlayEvent.Post e){ + if (!(e.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || e.type == RenderGameOverlayEvent.ElementType.JUMPBAR)) return; + GlStateManager.enableBlend(); + draw(e.partialTicks); + } + + + void tick(){ + if (titlesTimer > 0) { + --titlesTimer; + if (titlesTimer <= 0) { + displayedTitle = ""; + displayedSubTitle = ""; + } + } + } + + + public static void clearTitle(){ + displayedTitle = ""; + displayedSubTitle = ""; + titlesTimer = 0; + } + + + public static void displayTitle(@NotNull String title, String subTitle, int timeFadeIn, int displayTime, int timeFadeOut) { + displayedTitle = title; + displayedSubTitle = subTitle; + titleFadeIn = timeFadeIn; + titleDisplayTime = displayTime; + titleFadeOut = timeFadeOut; + titlesTimer = titleFadeIn + titleDisplayTime + titleFadeOut; + } + + void draw(float partialTicks){ + float g; + int l; + ScaledResolution scaledResolution = new ScaledResolution(mc); + int i = scaledResolution.getScaledWidth(); + int j = scaledResolution.getScaledHeight(); + if (titlesTimer > 0) { + g = titlesTimer - partialTicks; + l = 255; + if (titlesTimer > titleFadeOut + titleDisplayTime) { + float h = (float)(titleFadeIn + titleDisplayTime + titleFadeOut) - g; + l = (int)(h * 255.0f / (float)titleFadeIn); + } + if (titlesTimer <= titleFadeOut) { + float h = g; + l = (int)(h * 255.0f / (float)titleFadeOut); + } + if ((l = MathHelper.clamp_int(l, 0, 255)) > 8) { + GlStateManager.pushMatrix(); + GlStateManager.translate(i / 2, j / 2, 0.0f); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.pushMatrix(); + GlStateManager.scale(6.0f, 6.0f, 6.0f); + int m = l << 24 & 0xFF000000; + fontRenderer.drawString(displayedTitle, -fontRenderer.getStringWidth(displayedTitle) / 2, -10.0f, 0xFFFFFF | m, true); + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + GlStateManager.scale(2.0f, 2.0f, 2.0f); + fontRenderer.drawString(displayedSubTitle, -fontRenderer.getStringWidth(displayedSubTitle) / 2, 5.0f, 0xFFFFFF | m, true); + GlStateManager.popMatrix(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + } + } + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/VectorUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/VectorUtils.java new file mode 100755 index 00000000..f3e51578 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/VectorUtils.java @@ -0,0 +1,51 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.util.Vec3; + +import javax.vecmath.Vector2d; + +public class VectorUtils { + // Ior rooms, different coordinate system is used. Y Increses as marker goes down. X is same. + + + public static Vector2d rotateCounterClockwise(Vector2d vector2d) { + return new Vector2d(vector2d.y, -vector2d.x); + } + public static Vector2d rotateClockwise(Vector2d vector2d) { + return new Vector2d(-vector2d.y, vector2d.x); + } + + @Data @AllArgsConstructor + public static class ProjectionResult { + private float x; + private float y; + private boolean back; + } + + public static double distSquared(Vec3 lookVec, Vec3 posVec, Vec3 objectVec) { + Vec3 v = objectVec.subtract(posVec); + double t = v.dotProduct(lookVec); + Vec3 p = posVec.addVector(lookVec.xCoord * t, lookVec.yCoord * t, lookVec.zCoord * t); + return p.squareDistanceTo(objectVec) / p.squareDistanceTo(posVec); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/XPUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/XPUtils.java new file mode 100644 index 00000000..12804565 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/XPUtils.java @@ -0,0 +1,222 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils; + +import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.dataclasses.Skill; +import lombok.Data; + +import java.util.Map; +import java.util.TreeMap; + +public class XPUtils { + @Data + public static class XPCalcResult { + private int level; + private double remainingXp; + private double nextLvXp; + } + + private static final TreeMap catacombXp = new TreeMap<>(); + private static final TreeMap skillXp = new TreeMap<>(); + private static final TreeMap skillXp2 = new TreeMap<>(); + static { + catacombXp.put(50.0, 1); + catacombXp.put(125.0, 2); + catacombXp.put(235.0, 3); + catacombXp.put(395.0, 4); + catacombXp.put(625.0, 5); + catacombXp.put(955.0, 6); + catacombXp.put(1425.0, 7); + catacombXp.put(2095.0, 8); + catacombXp.put(3045.0, 9); + catacombXp.put(4385.0, 10); + catacombXp.put(6275.0, 11); + catacombXp.put(8940.0, 12); + catacombXp.put(12700.0, 13); + catacombXp.put(17960.0, 14); + catacombXp.put(25340.0, 15); + catacombXp.put(35640.0, 16); + catacombXp.put(50040.0, 17); + catacombXp.put(70040.0, 18); + catacombXp.put(97640.0, 19); + catacombXp.put(135640.0, 20); + catacombXp.put(188140.0, 21); + catacombXp.put(259640.0, 22); + catacombXp.put(356640.0, 23); + catacombXp.put(488640.0, 24); + catacombXp.put(668640.0, 25); + catacombXp.put(911640.0, 26); + catacombXp.put(1239640.0, 27); + catacombXp.put(1684640.0, 28); + catacombXp.put(2284640.0, 29); + catacombXp.put(3084640.0, 30); + catacombXp.put(4149640.0, 31); + catacombXp.put(5559640.0, 32); + catacombXp.put(7459640.0, 33); + catacombXp.put(9959640.0, 34); + catacombXp.put(13259640.0, 35); + catacombXp.put(17559640.0, 36); + catacombXp.put(23159640.0, 37); + catacombXp.put(30359640.0, 38); + catacombXp.put(39559640.0, 39); + catacombXp.put(51559640.0, 40); + catacombXp.put(66559640.0, 41); + catacombXp.put(85559640.0, 42); + catacombXp.put(109559640.0, 43); + catacombXp.put(139559640.0, 44); + catacombXp.put(177559640.0, 45); + catacombXp.put(225559640.0, 46); + catacombXp.put(285559640.0, 47); + catacombXp.put(360559640.0, 48); + catacombXp.put(453559640.0, 49); + catacombXp.put(569809640.0, 50); + skillXp.put(0.0, 0); + skillXp.put(50.0, 1); + skillXp.put(175.0, 2); + skillXp.put(375.0, 3); + skillXp.put(675.0, 4); + skillXp.put(1175.0, 5); + skillXp.put(1925.0, 6); + skillXp.put(2925.0, 7); + skillXp.put(4425.0, 8); + skillXp.put(6425.0, 9); + skillXp.put(9925.0, 10); + skillXp.put(14925.0, 11); + skillXp.put(22425.0, 12); + skillXp.put(32425.0, 13); + skillXp.put(47425.0, 14); + skillXp.put(67425.0, 15); + skillXp.put(97425.0, 16); + skillXp.put(147425.0, 17); + skillXp.put(222425.0, 18); + skillXp.put(322425.0, 19); + skillXp.put(522425.0, 20); + skillXp.put(822425.0, 21); + skillXp.put(1222425.0, 22); + skillXp.put(1722425.0, 23); + skillXp.put(2322425.0, 24); + skillXp.put(3022425.0, 25); + skillXp.put(3822425.0, 26); + skillXp.put(4722425.0, 27); + skillXp.put(5722425.0, 28); + skillXp.put(6822425.0, 29); + skillXp.put(8022425.0, 30); + skillXp.put(9322425.0, 31); + skillXp.put(10722425.0, 32); + skillXp.put(12222425.0, 33); + skillXp.put(13722425.0, 34); + skillXp.put(15522425.0, 35); + skillXp.put(17322425.0, 36); + skillXp.put(19222425.0, 37); + skillXp.put(21222425.0, 38); + skillXp.put(23322425.0, 39); + skillXp.put(25522425.0, 40); + skillXp.put(27822425.0, 41); + skillXp.put(30222425.0, 42); + skillXp.put(32722425.0, 43); + skillXp.put(35322425.0, 44); + skillXp.put(38072425.0, 45); + skillXp.put(40972425.0, 46); + skillXp.put(44072425.0, 47); + skillXp.put(47472425.0, 48); + skillXp.put(51172425.0, 49); + skillXp.put(55172425.0, 50); + skillXp.put(59472425.0, 51); + skillXp.put(64072425.0, 52); + skillXp.put(68972425.0, 53); + skillXp.put(74172425.0, 54); + skillXp.put(79672425.0, 55); + skillXp.put(85472425.0, 56); + skillXp.put(91572425.0, 57); + skillXp.put(97972425.0, 58); + skillXp.put(104672425.0, 59); + skillXp.put(111672425.0, 60); + skillXp2.put(0.0, 0); + skillXp2.put(50.0, 1); + skillXp2.put(150.0, 2); + skillXp2.put(275.0, 3); + skillXp2.put(435.0, 4); + skillXp2.put(635.0, 5); + skillXp2.put(885.0, 6); + skillXp2.put(1200.0, 7); + skillXp2.put(1600.0, 8); + skillXp2.put(2100.0, 9); + skillXp2.put(2725.0, 10); + skillXp2.put(3510.0, 11); + skillXp2.put(4510.0, 12); + skillXp2.put(5760.0, 13); + skillXp2.put(7324.0, 14); + skillXp2.put(9325.0, 15); + skillXp2.put(11825.0, 16); + skillXp2.put(14950.0, 17); + skillXp2.put(18950.0, 18); + skillXp2.put(23950.0, 19); + skillXp2.put(30200.0, 20); + skillXp2.put(38050.0, 21); + skillXp2.put(47850.0, 22); + skillXp2.put(60100.0, 23); + skillXp2.put(75400.0, 24); + skillXp2.put(94450.0, 25); + } + + public static XPCalcResult getCataXp(double totalXp) { + Map.Entry totalXpEn = catacombXp.floorEntry(totalXp); + XPCalcResult xpCalcResult = new XPCalcResult(); + if (totalXpEn == null) { + xpCalcResult.setLevel(0); + xpCalcResult.remainingXp = totalXp; + } else { + xpCalcResult.level = totalXpEn.getValue(); + xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); + } + Map.Entry asdasd = catacombXp.ceilingEntry(totalXp); + xpCalcResult.nextLvXp = asdasd == null ? 0 : (asdasd.getKey() - (totalXpEn != null ? totalXpEn.getKey() : 0)); + return xpCalcResult; + } + public static XPCalcResult getSkillXp(Skill skill, double totalXp) { + switch(skill) { + case RUNECRAFTING: + Map.Entry totalXpEn = skillXp2.floorEntry(totalXp); + XPCalcResult xpCalcResult = new XPCalcResult(); + if (totalXpEn == null) { + xpCalcResult.setLevel(0); + xpCalcResult.remainingXp = totalXp; + } else { + xpCalcResult.level = totalXpEn.getValue(); + xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); + } + Map.Entry asdasd = catacombXp.ceilingEntry(totalXp); + xpCalcResult.nextLvXp = asdasd == null ? 0 : (asdasd.getKey() - (totalXpEn != null ? totalXpEn.getKey() : 0)); + return xpCalcResult; + default: + totalXpEn = skillXp.floorEntry(totalXp); + xpCalcResult = new XPCalcResult(); + if (totalXpEn == null) { + xpCalcResult.setLevel(0); + xpCalcResult.remainingXp = totalXp; + } else { + xpCalcResult.level = totalXpEn.getValue(); + xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); + } + asdasd = catacombXp.ceilingEntry(totalXp); + xpCalcResult.nextLvXp = asdasd == null ? 0 : (asdasd.getKey() - (totalXpEn != null ? totalXpEn.getKey() : 0)); + return xpCalcResult; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/CursorReader.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/CursorReader.java new file mode 100644 index 00000000..48dcc357 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/CursorReader.java @@ -0,0 +1,95 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils.cursor; + +import com.google.common.io.LittleEndianDataInputStream; +import com.twelvemonkeys.imageio.plugins.bmp.CURImageReader; +import lombok.Data; + +import javax.imageio.ImageIO; +import javax.imageio.stream.ImageInputStream; +import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +public class CursorReader { + public static List readFromInputStream(InputStream inputStream) throws IOException { + LittleEndianDataInputStream dataInputStream = new LittleEndianDataInputStream(new BufferedInputStream(inputStream)); + dataInputStream.mark(Integer.MAX_VALUE); + + + int magicValue = dataInputStream.readUnsignedShort(); + if (magicValue != 0) throw new RuntimeException("Invalid Cursor file"); + int type = dataInputStream.readUnsignedShort(); + if (type != 2) throw new RuntimeException("not cursor"); + int size = dataInputStream.readShort(); + + List directoryList = new ArrayList<>(); + for (int i = 0; i < size; i++) { + + CursorData directory = new CursorData(); + directory.setWidth((short) dataInputStream.readUnsignedByte()); + directory.setHeight((short) dataInputStream.readUnsignedByte()); + directory.setColorCnt((short) dataInputStream.readUnsignedByte()); + directory.setMagicValue(dataInputStream.readByte()); + directory.setXHotSpot(dataInputStream.readShort()); + directory.setYHotSpot(dataInputStream.readShort()); + directory.setSizeBitmap(dataInputStream.readInt() & 0x00000000ffffffffL); + directory.setOffset(dataInputStream.readInt() & 0x00000000ffffffffL); + + directoryList.add(directory); + } + dataInputStream.reset(); + + try (ImageInputStream imageInputStream = ImageIO.createImageInputStream(dataInputStream)) { + CURImageReader imageReader = new CURImageReader(); + imageReader.setInput(imageInputStream); + + for (int i = 0; i < directoryList.size(); i++) { + directoryList.get(i).setBufferedImage(imageReader.read(i)); + } + } + inputStream.close(); + + return directoryList; + } + + private static void setIntLittleEndian(byte[] bytes, int index, int value) { + byte[] ins = new byte[] { + (byte) ((value >> 24)& 0xFF), (byte) ((value >> 16)& 0xFF), (byte) ((value >> 8)& 0xFF), (byte) (value & 0xFF) + }; + bytes[index+3] = ins[0]; + bytes[index+2] = ins[1]; + bytes[index+1] = ins[2]; + bytes[index] = ins[3]; + } + + + @Data + public static class CursorData { + private short width, height, colorCnt, magicValue; + private int xHotSpot, yHotSpot; + private long sizeBitmap; + private long offset; + private BufferedImage bufferedImage; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/EnumCursor.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/EnumCursor.java new file mode 100644 index 00000000..e7762ba5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/EnumCursor.java @@ -0,0 +1,54 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils.cursor; + +import lombok.AllArgsConstructor; +import lombok.Getter; + + +@AllArgsConstructor +@Getter +public enum EnumCursor { + DEFAULT(32512,68,"arrowCursor","arrowCursor.cur"), + POINTING_HAND(32649,60,"pointingHandCursor", "pointingHandCursor.cur"), + OPEN_HAND(32646,58,"openHandCursor","openHandCursor.cur"), + CLOSED_HAND(32646,52,"closedHandCursor","closedHandCursor.cur"), + BEAM_CURSOR(32513, 152, "IBeamCursor", "IBeamCursor.cur"), + RESIZE_LEFT(32644, 70,"resizeLeftCursor", "resizeLeftCursor.cur"), + RESIZE_RIGHT(32644, 96,"resizeRightCursor", "resizeRightCursor.cur"), + RESIZE_LEFT_RIGHT(32644, 108, "resizeLeftRightCursor", "resizeLeftRightCursor.cur"), + RESIZE_UP(32645,138,"resizeUpCursor", "resizeUpCursor.cur"), + RESIZE_DOWN(32645,16,"resizeDownCursor", "resizeDownCursor.cur"), + RESIZE_UP_DOWN(32645,116,"resizeUpDownCursor", "resizeUpDownCursor.cur"), + RESIZE_TL(32642, 134, null, "resizeNW.cur"), + RESIZE_DR(32642, 14, null, "resizeSE.cur"), + RESIZE_TLDR(32642, 14, null, "resizeNWSE.cur"), + RESIZE_TR(32643, 136, null, "resizeNE.cur"), + RESIZE_DL(32643, 12, null, "resizeSW.cur"), + RESIZE_TRDL(32643, 12, null, "resizeNESW.cur"), + CROSS(32515, 34,"crosshairCursor", "crosshairCursor.cur"), + NOT_ALLOWED(32648, -1,"operationNotAllowedCursor", "operationNotAllowedCursor.cur"), + TEST(-1, -1, null, "testnonexistant.cur"); + + + private int windows; + private int linux; + private String macos; + private String altFileName; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/Foundation.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/Foundation.java new file mode 100644 index 00000000..7474c85a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/Foundation.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils.cursor; + +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Pointer; + + +public interface Foundation extends Library { + Foundation INSTANCE = (Foundation) Native.loadLibrary("Foundation", + Foundation.class); + + Pointer objc_getClass(String className); + Pointer sel_registerName(String selectorName); + Pointer objc_msgSend(Pointer receiver, Pointer selector, Object... args); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/GLCursors.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/GLCursors.java new file mode 100644 index 00000000..23f62fa5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/GLCursors.java @@ -0,0 +1,231 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils.cursor; + +import com.google.common.base.Throwables; +import com.sun.jna.Pointer; +import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.input.Cursor; +import sun.misc.Unsafe; + +import java.awt.image.BufferedImage; +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +@SuppressWarnings("unsafe") +public class GLCursors { + + static Logger logger = LogManager.getLogger("DG-GlCursors"); + + @SuppressWarnings("unsafe") + static boolean verbose = false; + + private static Unsafe unsafe; + private static Class cursorElement; + private static Constructor constructor; + private static Field cursorField; + + private static Map enumCursorCursorMap = new HashMap<>(); + + + static { + try { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + unsafe = (Unsafe) f.get(null); + cursorElement = Class.forName("org.lwjgl.input.Cursor$CursorElement"); + constructor = cursorElement.getDeclaredConstructor(Object.class, long.class, long.class); + constructor.setAccessible(true); + cursorField = Cursor.class.getDeclaredField("cursors"); + cursorField.setAccessible(true); + } catch (NoSuchFieldException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException e) { + e.printStackTrace(); + } + } + + public static void setupCursors() { + if (enumCursorCursorMap.size() != 0) return; + int platform = LWJGLUtil.getPlatform(); + for (EnumCursor value : EnumCursor.values()) { + Cursor c = null; + try { + switch(platform) { + case LWJGLUtil.PLATFORM_WINDOWS: + if (value.getWindows() != -1) + c = createCursorWindows(value.getWindows()); + break; + case LWJGLUtil.PLATFORM_LINUX: + if (value.getLinux() != -1) + c = createCursorLinux(value.getLinux()); + break; + case LWJGLUtil.PLATFORM_MACOSX: + if (value.getMacos() != null) + c = createCursorMac(value.getMacos()); + break; + } + } catch (Throwable e) { + if(verbose) logger.error("Error occured while loading cursor: {}", value); + e.printStackTrace(); + } + try { + if (c == null) { + int hotspotX = 0, hotspotY = 0; + BufferedImage bufferedImage = null; + int minC = Cursor.getMinCursorSize(), maxC = Cursor.getMaxCursorSize(); + try { + ResourceLocation cursorinfo = new ResourceLocation("dungeonsguide:cursors/"+value.getAltFileName()); + List cursorDataList = CursorReader.readFromInputStream(Minecraft.getMinecraft().getResourceManager().getResource(cursorinfo).getInputStream()); + List cursorDataList2 = cursorDataList.stream() + .filter(cdata -> cdata.getBufferedImage() != null) + .filter(cdata -> minC <= cdata.getHeight() && cdata.getHeight() <= maxC && minC <= cdata.getWidth() && cdata.getWidth() <= maxC) + .sorted(Comparator.comparingInt(CursorReader.CursorData::getWidth)).collect(Collectors.toList()); + + CursorReader.CursorData cursorData = + cursorDataList2.size() == 0 ? cursorDataList.get(0) : cursorDataList2.get(0); + if(verbose) logger.info(cursorData); + bufferedImage = cursorData.getBufferedImage(); + hotspotX = cursorData.getXHotSpot(); + hotspotY = cursorData.getYHotSpot(); + } catch (Throwable t) { + if(verbose) logger.error("loading currsor failed with message, {}", String.valueOf(Throwables.getRootCause(t))); + } + + + int width = bufferedImage == null ? 16 : bufferedImage.getWidth(); + int height = bufferedImage == null ? 16 : bufferedImage.getHeight(); + int effWidth = MathHelper.clamp_int(width, Cursor.getMinCursorSize(), Cursor.getMaxCursorSize()); + int effHeight = MathHelper.clamp_int(height, Cursor.getMinCursorSize(), Cursor.getMaxCursorSize()); + int length = effHeight * effWidth; + IntBuffer intBuffer = BufferUtils.createIntBuffer(length); + for (int i = 0; i < length; i++) { + int x = i % effWidth; + int y = i / effWidth; + if (bufferedImage == null) { + intBuffer.put(RenderUtils.getChromaColorAt(x,y,1.0f, 1.0f, 1.0f, 1.0f)); + } else if (x >= width || y >= height) { + intBuffer.put(0); + } else { + intBuffer.put(bufferedImage.getRGB(x, height - y - 1)); + } + } + intBuffer.flip(); + c = new Cursor(effWidth, effHeight, hotspotX, height - hotspotY - 1,1,intBuffer, null); + } + } catch (Throwable e) { + if(verbose) logger.error("Error occured while loading cursor from resource: "+value); + e.printStackTrace(); + } + if (c != null) { + try { + Object arr = cursorField.get(c); + Object cursor = Array.get(arr, 0); + for (Field declaredField : cursor.getClass().getDeclaredFields()) { + declaredField.setAccessible(true); + Object obj = declaredField.get(cursor); + if(verbose) logger.info(declaredField.getName()+": "+obj+" - "+(obj instanceof ByteBuffer)); + if (obj instanceof ByteBuffer) { + ByteBuffer b = (ByteBuffer) declaredField.get(cursor); + StringBuilder sb = new StringBuilder("Contents: "); + for (int i = 0; i < b.limit(); i++) { + sb.append(Integer.toHexString(b.get(i) & 0xFF)).append(" "); + } + if(verbose) logger.info(sb.toString()); + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + enumCursorCursorMap.put(value, c); + } + } + } + + public static Cursor getCursor(EnumCursor enumCursor) { + return enumCursorCursorMap.get(enumCursor); + } + + private static Cursor createCursorWindows(int cursor) throws LWJGLException, InstantiationException, InvocationTargetException, IllegalAccessException { + User32 user32 = User32.INSTANCE; + Pointer hIcon = user32 + .LoadCursorW(Pointer.NULL, cursor); + long ptrVal = Pointer.nativeValue(hIcon); + ByteBuffer handle = BufferUtils.createByteBuffer(Pointer.SIZE); // Why does it have to be direct? well it crashes without it. + if (handle.order() == ByteOrder.LITTLE_ENDIAN) { + for (int i = 0; i < Pointer.SIZE; i++) { + byte value = (byte) ((ptrVal >> i * 8) & 0xFF); + handle.put(value); + } + } else { + for (int i = Pointer.SIZE; i >= 0; i++) { + byte value = (byte) ((ptrVal >> i * 8) & 0xFF); + handle.put(value); + } + } + handle.position(0); + return createCursor(handle); + } + private static Cursor createCursorLinux(int cursor) throws LWJGLException, InstantiationException, InvocationTargetException, IllegalAccessException { + X11.Display display = X11.INSTANCE.XOpenDisplay(null); + Pointer fontCursor = X11.INSTANCE.XCreateFontCursor(display, cursor); + long iconPtr = Pointer.nativeValue(fontCursor); + + return createCursor(iconPtr); + } + private static Cursor createCursorMac(String cursor) throws LWJGLException, InstantiationException, InvocationTargetException, IllegalAccessException { + // trust me, it's horrible. + Foundation foundation = Foundation.INSTANCE; + Pointer nsCursor = foundation.objc_getClass("NSCursor"); + Pointer selector = foundation.sel_registerName(cursor); + Pointer thePointer = foundation.objc_msgSend(nsCursor, selector); + long iconPtr = Pointer.nativeValue(thePointer); + + return createCursor(iconPtr); + } + + + private static Cursor createCursor(Object handle) throws IllegalAccessException, InvocationTargetException, InstantiationException { + // Yes. I had no way. + Cursor ADANGEROUSOBJECT = (Cursor) unsafe.allocateInstance(Cursor.class); + Object cursorElement = constructor.newInstance(handle, 0, LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_LINUX ? -1 : System.currentTimeMillis()); + Object array = Array.newInstance(GLCursors.cursorElement, 1); + Array.set(array, 0, cursorElement); + cursorField.set(ADANGEROUSOBJECT, array); + return ADANGEROUSOBJECT; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/User32.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/User32.java new file mode 100644 index 00000000..dfbbc03d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/User32.java @@ -0,0 +1,67 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils.cursor; + +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Pointer; + +public interface User32 extends Library { + + public static User32 INSTANCE = (User32) Native + .loadLibrary("User32", User32.class); + + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_ARROW = 32512; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_IBEAM = 32513; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_WAIT = 32514; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_CROSS = 32515; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_UPARROW = 32516; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_SIZENWSE = 32642; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_SIZENESW = 32643; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_SIZEWE = 32644; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_SIZENS = 32645; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_SIZEALL = 32646; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_NO = 32648; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_HAND = 32649; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_APPSTARTING = 32650; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_HELP = 32651; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_ICON = 32641; + /** @see #LoadCursorW(Pointer, int) */ + public static final int IDC_SIZE = 32640; + + /** http://msdn.microsoft.com/en-us/library/ms648391(VS.85).aspx */ + public Pointer LoadCursorW(Pointer hInstance, + int lpCursorName); + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/X11.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/X11.java new file mode 100644 index 00000000..dc5a8894 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/cursor/X11.java @@ -0,0 +1,37 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.utils.cursor; + +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; + +public interface X11 extends Library { + X11 INSTANCE = (X11) Native.loadLibrary("X11", X11.class); + public Pointer XCreateFontCursor(Display display, + int shape); + public Display XOpenDisplay(String var1); + + public static class Display extends PointerType { + public Display() { + } + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/wsresource/StaticResource.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/wsresource/StaticResource.java new file mode 100644 index 00000000..f682513f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/wsresource/StaticResource.java @@ -0,0 +1,30 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.wsresource; + +import lombok.Data; + +import java.util.UUID; + +@Data +public class StaticResource { + private UUID resourceID; + private String value; + private boolean exists; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/mod/wsresource/StaticResourceCache.java b/src/main/java/kr/syeyoung/dungeonsguide/mod/wsresource/StaticResourceCache.java new file mode 100644 index 00000000..cd213115 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/mod/wsresource/StaticResourceCache.java @@ -0,0 +1,77 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.mod.wsresource; + +import kr.syeyoung.dungeonsguide.mod.events.impl.StompConnectedEvent; +import kr.syeyoung.dungeonsguide.mod.stomp.*; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public class StaticResourceCache { + public static final StaticResourceCache INSTANCE = new StaticResourceCache(); + + private Map staticResourceMap = new HashMap<>(); + + private Map> staticResourceRequest = new HashMap<>(); + + public void purgeCache() { + staticResourceRequest.clear(); + staticResourceMap.clear(); + } + + public CompletableFuture getResource(UUID resourceID) { + if (staticResourceMap.containsKey(resourceID)) return CompletableFuture.completedFuture(staticResourceMap.get(resourceID)); + if (staticResourceRequest.containsKey(resourceID)) return staticResourceRequest.get(resourceID); + + StompManager.getInstance().send(new StompPayload().destination("/app/staticresource.get").payload(resourceID.toString())); + CompletableFuture comp = new CompletableFuture<>(); + staticResourceRequest.put(resourceID, comp); + return comp; + } + + @SubscribeEvent + public void stompConnect(StompConnectedEvent event) { + + event.getStompInterface().subscribe("/user/queue/staticresource.get", (stompClient ,payload) -> { + JSONObject object = new JSONObject(payload); + StaticResource staticResource = new StaticResource(); + staticResource.setResourceID(UUID.fromString(object.getString("resourceID"))); + staticResource.setExists(object.getBoolean("exists")); + staticResource.setValue((!object.has("value") || object.isNull("value")) ? null : object.getString("value")); + + staticResourceMap.put(staticResource.getResourceID(), staticResource); + CompletableFuture completed = staticResourceRequest.remove(staticResource.getResourceID()); + if (completed != null) completed.complete(staticResource); + }); + + + getResource(BONUS_SCORE); + getResource(TRIVIA_ANSWERS); + getResource(DATA_COLLECTION); + } + + public static final UUID BONUS_SCORE = UUID.fromString("13f10001-66b5-46e5-94f9-1a5161a23429"); + public static final UUID TRIVIA_ANSWERS = UUID.fromString("5657f2cc-2bb8-4fcd-b55c-ffc0a35b9349"); + public static final UUID DATA_COLLECTION = UUID.fromString("c11f026f-9f26-4d14-8d52-88325dd6397a"); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/AStarCornerCut.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/AStarCornerCut.java deleted file mode 100644 index ee71f90b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/AStarCornerCut.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.pathfinding; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import net.minecraft.util.*; -import net.minecraft.world.World; - -import java.util.*; - -public class AStarCornerCut { - private final BlockPos min, max; - private final World world; - - int lastSx, lastSy, lastSz; - final int dx, dy, dz; - private DungeonRoom dungeonRoom; - - @Getter - private AxisAlignedBB destinationBB; - - public AStarCornerCut(DungeonRoom dungeonRoom, Vec3 destination) { - this.min = new BlockPos(dungeonRoom.getMinx(), 0, dungeonRoom.getMinz()); - this.max = new BlockPos(dungeonRoom.getMaxx(), 255, dungeonRoom.getMaxz()); - - this.world = dungeonRoom.getCachedWorld(); - this.dungeonRoom = dungeonRoom; - - this.dx = (int) (destination.xCoord * 2); - this.dy = (int) (destination.yCoord * 2); - this.dz = (int) (destination.zCoord * 2); - destinationBB = AxisAlignedBB.fromBounds(dx-2, dy-2, dz-2, dx+2, dy+2, dz+2); - } - - private Map nodeMap = new HashMap<>(); - - private Node openNode(int x, int y, int z) - { - Node.Coordinate coordinate = new Node.Coordinate(x,y,z); - Node node = this.nodeMap.get(coordinate); - - if (node == null) - { - node = new Node(coordinate); - this.nodeMap.put(coordinate, node); - } - - return node; - } - - @Getter - private LinkedList route = new LinkedList<>(); - - @Getter - private PriorityQueue open = new PriorityQueue<>(Comparator.comparing((Node a) -> a == null ? Float.MAX_VALUE : a.f).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.x).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.y).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.z)); - - private int pfindIdx = 0; - - public boolean pathfind(Vec3 from, long timeout) { - pfindIdx ++; - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) - open.clear(); - - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); - - Node startNode = openNode(dx, dy, dz); - Node goalNode = openNode(lastSx, lastSy, lastSz); - - if (goalNode.parent != null) { - LinkedList route = new LinkedList<>(); - Node curr =goalNode; - while(curr.parent != null) { - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - curr = curr.parent; - } - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - this.route = route; - return true; - } - - startNode.g = 0; - startNode.f = 0; - goalNode.g = Integer.MAX_VALUE; goalNode.f = Integer.MAX_VALUE; - - - open.add(startNode); - - long end = System.currentTimeMillis() + timeout; - - while (!open.isEmpty()) { - if (System.currentTimeMillis() > end) { - return false; - } - - Node n = open.poll(); - if (n.lastVisited == pfindIdx) continue; - n.lastVisited = pfindIdx; - - if (n == goalNode) { - // route = reconstructPath(startNode) - LinkedList route = new LinkedList<>(); - Node curr =goalNode; - while(curr.parent != null) { - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - curr = curr.parent; - } - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - this.route = route; - return true; - } - - for (int z = -1; z <= 1; z++) {for (int y = -1; y <= 1; y ++) { for(int x = -1; x <= 1; x++) { - if (x == 0 && y == 0 && z == 0) continue; - Node neighbor = openNode(n.coordinate.x +x, n.coordinate.y +y, n.coordinate.z + z); - - // check blocked. - if (!((destinationBB.minX <= neighbor.coordinate.x && neighbor.coordinate.x <= destinationBB.maxX && - destinationBB.minY <= neighbor.coordinate.y && neighbor.coordinate.y <= destinationBB.maxY && - destinationBB.minZ <= neighbor.coordinate.z && neighbor.coordinate.z <= destinationBB.maxZ) // near destination - || !dungeonRoom.isBlocked(neighbor.coordinate.x, neighbor.coordinate.y, neighbor.coordinate.z))) { // not blocked - continue; - } - if (neighbor.lastVisited == pfindIdx) continue; - - - float gScore = n.g + MathHelper.sqrt_float(x*x + y*y + z*z); // altho it's sq, it should be fine - if (gScore < neighbor.g ) { - neighbor.parent = n; - neighbor.g = gScore; - neighbor.f = gScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); - open.add(neighbor); - } else if (neighbor.lastVisited != pfindIdx) { - neighbor.f = gScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); - open.add(neighbor); - } - }}} - } - return true; - } - - private int manhatten(int x, int y, int z) {return Math.abs(x)+ Math.abs(y)+ Math.abs(z);} - private float distSq(float x, float y, float z) { - return MathHelper.sqrt_float(x * x + y * y + z * z); - } - - @RequiredArgsConstructor - @Data - public static final class Node { - @Data - @RequiredArgsConstructor - public static final class Coordinate { - private final int x, y, z; - } - private final Coordinate coordinate; - - private float f = Float.MAX_VALUE, g = Float.MAX_VALUE; - private int lastVisited; - - @EqualsAndHashCode.Exclude - private Node parent; - - public static long makeHash(int x, int y, int z) - { - return y & 32767L | ((short)x & 32767L) << 16 | ((short)z & 32767L) << 32; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/AStarFineGrid.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/AStarFineGrid.java deleted file mode 100644 index 94fa8a87..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/AStarFineGrid.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.pathfinding; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import net.minecraft.util.*; -import net.minecraft.world.World; - -import java.util.*; - -public class AStarFineGrid { - private final BlockPos min, max; - private final World world; - - int lastSx, lastSy, lastSz; - final int dx, dy, dz; - private DungeonRoom dungeonRoom; - - @Getter - private AxisAlignedBB destinationBB; - - public AStarFineGrid(DungeonRoom dungeonRoom, Vec3 destination) { - this.min = new BlockPos(dungeonRoom.getMinx(), 0, dungeonRoom.getMinz()); - this.max = new BlockPos(dungeonRoom.getMaxx(), 255, dungeonRoom.getMaxz()); - - this.world = dungeonRoom.getCachedWorld(); - this.dungeonRoom = dungeonRoom; - - this.dx = (int) (destination.xCoord * 2); - this.dy = (int) (destination.yCoord * 2); - this.dz = (int) (destination.zCoord * 2); - destinationBB = AxisAlignedBB.fromBounds(dx-2, dy-2, dz-2, dx+2, dy+2, dz+2); - } - - private Map nodeMap = new HashMap<>(); - - private Node openNode(int x, int y, int z) - { - Node.Coordinate coordinate = new Node.Coordinate(x,y,z); - Node node = this.nodeMap.get(coordinate); - - if (node == null) - { - node = new Node(coordinate); - this.nodeMap.put(coordinate, node); - } - - return node; - } - - @Getter - private LinkedList route = new LinkedList<>(); - - @Getter - private PriorityQueue open = new PriorityQueue<>(Comparator.comparing((Node a) -> a == null ? Float.MAX_VALUE : a.f).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.x).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.y).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.z)); - - private int pfindIdx = 0; - - public boolean pathfind(Vec3 from, long timeout) { - pfindIdx ++; - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) - open.clear(); - - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); - - Node startNode = openNode(dx, dy, dz); - Node goalNode = openNode(lastSx, lastSy, lastSz); - startNode.g = 0; - startNode.f = 0; - goalNode.g = Integer.MAX_VALUE; goalNode.f = Integer.MAX_VALUE; - if (goalNode.parent != null) { - LinkedList route = new LinkedList<>(); - Node curr =goalNode; - while(curr.parent != null) { - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - curr = curr.parent; - } - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - this.route = route; - return true; - } - open.add(startNode); - - long end = System.currentTimeMillis() + timeout; - - while (!open.isEmpty()) { - if (System.currentTimeMillis() > end) { - return false; - } - - Node n = open.poll(); - if (n.lastVisited == pfindIdx) continue; - n.lastVisited = pfindIdx; - - if (n == goalNode) { - // route = reconstructPath(startNode) - LinkedList route = new LinkedList<>(); - Node curr =goalNode; - while(curr.parent != null) { - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - curr = curr.parent; - } - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - this.route = route; - return true; - } - - for (EnumFacing value : EnumFacing.VALUES) { - Node neighbor = openNode(n.coordinate.x + value.getFrontOffsetX(), n.coordinate.y + value.getFrontOffsetY(), n.coordinate.z + value.getFrontOffsetZ()); - - // check blocked. - if (!((destinationBB.minX <= neighbor.coordinate.x && neighbor.coordinate.x <= destinationBB.maxX && - destinationBB.minY <= neighbor.coordinate.y && neighbor.coordinate.y <= destinationBB.maxY && - destinationBB.minZ <= neighbor.coordinate.z && neighbor.coordinate.z <= destinationBB.maxZ) // near destination - || !dungeonRoom.isBlocked(neighbor.coordinate.x, neighbor.coordinate.y, neighbor.coordinate.z))) { // not blocked - continue; - } - - float gScore = n.g + 1; // altho it's sq, it should be fine - if (gScore < neighbor.g) { - neighbor.parent = n; - neighbor.g = gScore; - neighbor.f = gScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); - open.add(neighbor); - } else if (neighbor.lastVisited != pfindIdx) { - neighbor.f = gScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); - open.add(neighbor); - } - } - } - return true; - } - - private int manhatten(int x, int y, int z) {return Math.abs(x)+ Math.abs(y)+ Math.abs(z);} - private float distSq(float x, float y, float z) { - return MathHelper.sqrt_float(x * x + y * y + z * z); - } - - @RequiredArgsConstructor - @Data - public static final class Node { - @Data - @RequiredArgsConstructor - public static final class Coordinate { - private final int x, y, z; - } - private final Coordinate coordinate; - - private float f = Float.MAX_VALUE, g = Float.MAX_VALUE; - private int lastVisited; - - @EqualsAndHashCode.Exclude - private Node parent; - - public static long makeHash(int x, int y, int z) - { - return y & 32767L | ((short)x & 32767L) << 16 | ((short)z & 32767L) << 32; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/CachedWorld.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/CachedWorld.java deleted file mode 100644 index ac9234c6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/CachedWorld.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.pathfinding; - -import lombok.AllArgsConstructor; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.profiler.Profiler; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.IProgressUpdate; -import net.minecraft.world.*; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.storage.ISaveHandler; -import net.minecraft.world.storage.WorldInfo; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.util.List; - -public class CachedWorld extends World { - private ChunkCache chunkCache; - - public CachedWorld(ChunkCache chunkCache) { - super(null, null, new WorldProviderSurface(), null, true); - this.chunkCache = chunkCache; - } - - @Override - protected IChunkProvider createChunkProvider() { - return null; - } - - @Override - protected int getRenderDistanceChunks() { - return 999; - } - - @Override - public boolean extendedLevelsInChunkCache() { - return chunkCache.extendedLevelsInChunkCache(); - } - - @Override - public TileEntity getTileEntity(BlockPos pos) { - return chunkCache.getTileEntity(pos); - } - - @Override - public int getCombinedLight(BlockPos pos, int lightValue) { - return chunkCache.getCombinedLight(pos, lightValue); - } - - @Override - public IBlockState getBlockState(BlockPos pos) { - return chunkCache.getBlockState(pos); - } - - @Override - public int getLightFor(EnumSkyBlock type, BlockPos pos) { - return chunkCache.getLightFor(type, pos); - } - - @Override - public boolean isAirBlock(BlockPos pos) { - return chunkCache.isAirBlock(pos); - } - - @Override - public int getStrongPower(BlockPos pos, EnumFacing direction) { - return chunkCache.getStrongPower(pos, direction); - } - - @Override - public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default) { - return chunkCache.isSideSolid(pos, side, _default); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java deleted file mode 100644 index 5d48ccb2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.pathfinding; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.util.*; -import net.minecraft.world.ChunkCache; -import net.minecraft.world.World; - -import java.lang.reflect.Proxy; -import java.util.*; - -public class JPSPathfinder { - private final BlockPos min, max; - private final World world; - - private Vec3 start; - private Vec3 destination; - private DungeonRoom dungeonRoom; - - @Getter - private AxisAlignedBB destinationBB; - - public JPSPathfinder(DungeonRoom dungeonRoom){ - this.min = new BlockPos(dungeonRoom.getMinx(), 0, dungeonRoom.getMinz()); - this.max = new BlockPos(dungeonRoom.getMaxx(), 255, dungeonRoom.getMaxz()); - - this.world = dungeonRoom.getCachedWorld(); - this.dungeonRoom = dungeonRoom; - } - - private IntHashMap nodeMap = new IntHashMap(); - - private Node openNode(int x, int y, int z) - { - int i = Node.makeHash(x, y, z); - Node node = this.nodeMap.lookup(i); - - if (node == null) - { - node = new Node(x, y, z); - this.nodeMap.addKey(i, node); - } - - return node; - } - - @Getter - private LinkedList route = new LinkedList<>(); - - @Getter - private PriorityQueue open = new PriorityQueue<>(Comparator.comparing((Node a) -> a == null ? Float.MAX_VALUE : a.f).thenComparing(a -> a == null ? Float.MAX_VALUE : a.x).thenComparing(a -> a == null ? Float.MAX_VALUE : a.y).thenComparing(a -> a == null ? Float.MAX_VALUE : a.z)); - - private int tx, ty, tz; - - private Node addNode(Node parent, Node jumpPt, boolean addToOpen) { - float ng = parent.g + distSq(jumpPt.x - parent.x, jumpPt.y - parent.y, jumpPt.z - parent.z); - - if (ng < jumpPt.g) { - if (addToOpen) - open.remove(jumpPt); - jumpPt.g = ng; - jumpPt.h = jumpPt.h == -1 ? distSq(tx - jumpPt.x, ty - jumpPt.y, tz - jumpPt.z) : jumpPt.h; - jumpPt.f = jumpPt.h + jumpPt.g; - jumpPt.parent = parent; - if (addToOpen) - open.add(jumpPt); - } - return jumpPt; - } - - - long arr[]; - - public boolean pathfind(Vec3 from, Vec3 to, float within, long timeout) { - route.clear(); nodeMap.clearMap(); - - { - from = new Vec3(((int)(from.xCoord * 2)) / 2.0, ((int)(from.yCoord * 2)) / 2.0, ((int)(from.zCoord* 2)) / 2.0); - to = new Vec3(((int)(to.xCoord * 2)) / 2.0, ((int)(to.yCoord * 2)) / 2.0, ((int)(to.zCoord* 2)) / 2.0); - } - - this.start = from; this.destination = to; - tx = (int)(to.xCoord * 2); - ty = (int)(to.yCoord * 2); - tz = (int)(to.zCoord * 2); - - destinationBB = AxisAlignedBB.fromBounds((to.xCoord - within)* 2, (to.yCoord - within) * 2, (to.zCoord - within) * 2, (to.xCoord + within) * 2, (to.yCoord + within)* 2, (to.zCoord + within) *2); - open.clear(); - Node start; - open.add(start = openNode((int)from.xCoord * 2 + 1, (int)from.yCoord * 2, (int)from.zCoord * 2+1)); - start.g = 0; start.f = 0; start.h = (float) from.squareDistanceTo(to); - - Node end = null; float minDist = Float.MAX_VALUE; - long forceEnd = System.currentTimeMillis() + timeout + 999999999L; - while(!open.isEmpty()) { - if (forceEnd < System.currentTimeMillis() && timeout != -1) break; - Node n = open.poll(); - n.closed= true; - if (minDist > n.h) { - minDist = n.h; - end = n; - } - if (n.x > destinationBB.minX && n.x < destinationBB.maxX && n.y > destinationBB.minY && n.y < destinationBB.maxY && n.z > destinationBB.minZ && n.z < destinationBB.maxZ) { - break; - } - - for (Node neighbor : getNeighbors(n.parent == null ? n : n.parent, n)) { - Node jumpPT = expand(n.x, n.y, n.z, neighbor.x - n.x, neighbor.y - n.y, neighbor.z - n.z); - if (jumpPT == null || jumpPT.closed) continue; - - addNode(n, jumpPT, true); - } - } - - if (end == null) return false; - Node p = end; - while (p != null) { - route.addLast(new Vec3(p.x / 2.0f, p.y / 2.0f + 0.1, p.z / 2.0f)); - p = p.parent; - } - - - return true; - } - - private float distSq(float x, float y, float z) { - return MathHelper.sqrt_float(x * x + y * y + z * z); - } - - public Set getNeighbors(Node prevN, Node n) { -// if (true) throw new RuntimeException("ah"); - int dx = MathHelper.clamp_int(n.x - prevN.x, -1, 1); - int dy = MathHelper.clamp_int(n.y - prevN.y, -1, 1); - int dz = MathHelper.clamp_int(n.z - prevN.z, -1, 1); - int x = n.x, y = n.y, z = n.z; - int nx = n.x + dx, ny = n.y + dy, nz = n.z + dz; - - Set nexts = new HashSet<>(); - int determinant = Math.abs(dx) + Math.abs(dy) + Math.abs(dz); - if (determinant == 0) { - for (int i = -1; i <= 1; i++) - for (int j = -1; j <= 1; j++) - for (int k = -1; k <= 1; k++) { - if (i == 0 && j == 0 && k == 0) continue; - nexts.add(openNode(x+i, y+j, z+k)); - } - } else if (determinant == 1) { - nexts.add(openNode(nx,ny,nz)); - for (int i = -1; i<=1; i++) { - for (int j = - 1; j<=1; j++) { - if (i == 0 && j == 0) continue; - if (dx != 0 && dungeonRoom.isBlocked(x, y + i, z + j)) nexts.add(openNode(nx,y+i,z+j)); - if (dy != 0 && dungeonRoom.isBlocked(x + i, y, z + j)) nexts.add(openNode(x+i,ny,z+j)); - if (dz != 0 && dungeonRoom.isBlocked(x + i, y + j, z)) nexts.add(openNode(x+i,y+j,nz)); - } - } - } else if (determinant == 2) { - if (dz != 0) nexts.add(openNode(x,y,nz)); - if (dy != 0) nexts.add(openNode(x,ny,z)); - if (dx != 0) nexts.add(openNode(nx,y,z)); - nexts.add(openNode(nx,ny,nz)); - if (dx == 0) { - if (dungeonRoom.isBlocked(x, y, z-dz)) { - nexts.add(openNode(x, ny, z-dz)); - if (dungeonRoom.isBlocked(x+1, y, z-dz)) nexts.add(openNode(x+1, ny, z-dz)); - if (dungeonRoom.isBlocked(x-1, y, z-dz)) nexts.add(openNode(x-1, ny, z-dz)); - } - if (dungeonRoom.isBlocked(x, y-dy, z)) { - nexts.add(openNode(x, y-dy, nz)); - if (dungeonRoom.isBlocked(x+1, y-dy, z)) nexts.add(openNode(x+1, y-dy, nz)); - if (dungeonRoom.isBlocked(x-1, y-dy, z)) nexts.add(openNode(x+1, y-dy, nz)); - } - } else if (dy == 0) { - if (dungeonRoom.isBlocked(x, y, z-dz)) { - nexts.add(openNode(nx, y, z-dz)); - if (dungeonRoom.isBlocked(x, y+1, z-dz)) nexts.add(openNode(nx, y+1, z-dz)); - if (dungeonRoom.isBlocked(x, y-1, z-dz)) nexts.add(openNode(nx, y-1, z-dz)); - } - if (dungeonRoom.isBlocked(x-dx, y, z)) { - nexts.add(openNode(x-dx, y, nz)); - if (dungeonRoom.isBlocked(x-dx, y+1, z)) nexts.add(openNode(x-dx, y+1, nz)); - if (dungeonRoom.isBlocked(x-dx, y-1, z)) nexts.add(openNode(x-dx, y-1, nz)); - } - } else if (dz == 0) { - if (dungeonRoom.isBlocked(x, y-dy, z)) { - nexts.add(openNode(nx, y-dy, z)); - if (dungeonRoom.isBlocked(x, y-dy, z+1)) nexts.add(openNode(nx, y-dy, z+1)); - if (dungeonRoom.isBlocked(x, y-dy, z-1)) nexts.add(openNode(nx, y-dy, z-1)); - } - if (dungeonRoom.isBlocked(x-dx, y, z)) { - nexts.add(openNode(x-dx, ny, z)); - if (dungeonRoom.isBlocked(x-dx, y, z+1)) nexts.add(openNode(x-dx, ny, z+1)); - if (dungeonRoom.isBlocked(x-dx, y, z-1)) nexts.add(openNode(x-dx, ny, z-1)); - } - } - } else if (determinant == 3) { - nexts.add(openNode(x,y,nz)); - nexts.add(openNode(x,ny,z)); - nexts.add(openNode(nx,y,z)); - nexts.add(openNode(nx,y,nz)); - nexts.add(openNode(x,ny,nz)); - nexts.add(openNode(nx,ny,z)); - nexts.add(openNode(nx,ny,nz)); - - if (dungeonRoom.isBlocked(x,y,z-dz)) { - nexts.add(openNode(x,ny,z-dz)); - nexts.add(openNode(nx,ny,z-dz)); - nexts.add(openNode(nx,y,z-dz)); - } - if (dungeonRoom.isBlocked(x-dx,y,z)) { - nexts.add(openNode(x-dx,ny,nz)); - nexts.add(openNode(x-dx,ny,z)); - nexts.add(openNode(x-dx,y,nz)); - } - if (dungeonRoom.isBlocked(x,y-dy,z)) { - nexts.add(openNode(x,y-dy,nz)); - nexts.add(openNode(nx,y-dy,z)); - nexts.add(openNode(nx,y-dy,nz)); - } - } - return nexts; - } - - public Node expand(int x, int y, int z, int dx, int dy, int dz) { - while(true) { - int nx = x + dx, ny = y + dy, nz = z + dz; - if (dungeonRoom.isBlocked(nx, ny, nz)) return null; - - if (nx > destinationBB.minX && nx < destinationBB.maxX && ny > destinationBB.minY && ny < destinationBB.maxY && nz > destinationBB.minZ && nz < destinationBB.maxZ) return openNode(nx,ny,nz); - - int determinant = Math.abs(dx) + Math.abs(dy) + Math.abs(dz); - if (determinant == 1) { - for (int i = -1; i<=1; i++) { - for (int j = - 1; j<=1; j++) { - if (i == 0 && j == 0) continue; - if (dx != 0 && dungeonRoom.isBlocked(nx, ny + i, nz + j) && !dungeonRoom.isBlocked(nx+dx, ny + i, nz + j)) return openNode(nx,ny,nz); - if (dy != 0 && dungeonRoom.isBlocked(nx + i, ny, nz + j) && !dungeonRoom.isBlocked(nx + i, ny+dy, nz + j)) return openNode(nx,ny,nz); - if (dz != 0 && dungeonRoom.isBlocked(nx + i, ny + j , nz) && !dungeonRoom.isBlocked(nx + i, ny + j , nz+dz)) return openNode(nx,ny,nz); - } - } - } else if (determinant == 2) { - for (EnumFacing value : EnumFacing.VALUES) { - if (value.getFrontOffsetX() == dx || value.getFrontOffsetY() == dy || value.getFrontOffsetZ() == dz) continue; - int tx = nx + value.getFrontOffsetX(); - int ty = ny + value.getFrontOffsetY(); - int tz = nz + value.getFrontOffsetZ(); - if (dungeonRoom.isBlocked(tx, ty, tz)) return openNode(nx, ny, nz); - } - if (dx != 0 && expand(nx, ny, nz, dx, 0,0) != null) return openNode(nx,ny,nz); - if (dy != 0 && expand(nx, ny, nz, 0, dy,0) != null) return openNode(nx,ny,nz); - if (dz != 0 && expand(nx, ny, nz, 0, 0,dz) != null) return openNode(nx,ny,nz); - } else if (determinant == 3) { - if (dungeonRoom.isBlocked(x, ny, nz ) || dungeonRoom.isBlocked(nx, y , nz) || dungeonRoom.isBlocked(nx, ny, z)) return openNode(nx,ny,nz); - if (expand(nx, ny, nz, dx, 0, 0) != null || - expand(nx, ny, nz, dx, dy, 0) != null || - expand(nx, ny, nz, dx, 0, dz) != null || - expand(nx, ny, nz, 0, dy, 0) != null || - expand(nx, ny, nz, 0, dy, dz) != null || - expand(nx, ny, nz, 0, 0, dz) != null) return openNode(nx,ny,nz); - } - x = nx; y = ny; z = nz; - } - } - - @RequiredArgsConstructor - @Data - public static final class Node { - private final int x, y, z; - - private float f, g = Float.MAX_VALUE, h = -1; - private boolean closed; - - @EqualsAndHashCode.Exclude - private Node parent; - - public static int makeHash(int x, int y, int z) - { - return y & 255 | (x & 32767) << 8 | (z & 32767) << 24 | (x < 0 ? Integer.MIN_VALUE : 0) | (z < 0 ? 32768 : 0); - } - - public Node close() { - this.closed = true; - return this; - } - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/NodeProcessorDungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/NodeProcessorDungeonRoom.java deleted file mode 100644 index 91b86e22..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/NodeProcessorDungeonRoom.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.pathfinding; - -import com.google.common.collect.Sets; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; -import net.minecraft.pathfinding.PathPoint; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Vec3i; -import net.minecraft.world.pathfinder.NodeProcessor; - -import java.util.Set; - -public class NodeProcessorDungeonRoom extends NodeProcessor { - private final DungeonRoom dungeonRoom; - private final BlockPos sub; - public NodeProcessorDungeonRoom(DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - sub = dungeonRoom.getMax().subtract(dungeonRoom.getMin()); - } - - @Override - public PathPoint getPathPointTo(Entity entityIn) { - return openPoint((int)entityIn.posX - dungeonRoom.getMin().getX(), (int)entityIn.posY - dungeonRoom.getMin().getY(), - (int)entityIn.posZ - dungeonRoom.getMin().getZ()); - } - - @Override - public PathPoint getPathPointToCoords(Entity entityIn, double x, double y, double z) { - return openPoint((int)x- dungeonRoom.getMin().getX(), (int)y - dungeonRoom.getMin().getY(), - (int)z - dungeonRoom.getMin().getZ()); - } - - private static final EnumFacing[] values2 = new EnumFacing[6]; - static { - values2[0] = EnumFacing.DOWN; - values2[1] = EnumFacing.NORTH; - values2[2] = EnumFacing.SOUTH; - values2[3] = EnumFacing.EAST; - values2[4] = EnumFacing.WEST; - values2[5] = EnumFacing.UP; - } - - @Override - public int findPathOptions(PathPoint[] pathOptions, Entity entityIn, PathPoint currentPoint, PathPoint targetPoint, float maxDistance) { - - int i = 0; - for (EnumFacing ef:values2) { - Vec3i dir = ef.getDirectionVec(); - int newX = currentPoint.xCoord + dir.getX(); - int newY = currentPoint.yCoord + dir.getY(); - int newZ = currentPoint.zCoord + dir.getZ(); - if (newX < 0 || newZ < 0) continue; - if (newX > sub.getX()|| newZ > sub.getZ()) continue; - IBlockState curr = entityIn.getEntityWorld().getBlockState(dungeonRoom.getMin().add(newX, newY, newZ)); - IBlockState up = entityIn.getEntityWorld().getBlockState(dungeonRoom.getMin().add(newX, newY + 1, newZ)); - if (isValidBlock(curr) - && isValidBlock(up )) { - PathPoint pt = openPoint(newX, newY, newZ); - if (pt.visited) continue; - pathOptions[i++] = pt; - continue; - } - - if (curr.getBlock() == Blocks.air) { - if (up.getBlock() == Blocks.stone_slab - || up.getBlock() == Blocks.wooden_slab - || up.getBlock() == Blocks.stone_slab2) { - IBlockState up2 = entityIn.getEntityWorld().getBlockState(dungeonRoom.getMin().add(newX, newY -1, newZ)); - if (up2.getBlock() == Blocks.stone_slab - || up2.getBlock() == Blocks.wooden_slab - || up2.getBlock() == Blocks.stone_slab2) { - PathPoint pt = openPoint(newX, newY, newZ); - if (pt.visited) continue; - pathOptions[i++] = pt; - continue; - } - } - } - - if (dir.getY() == 0 && curr.getBlock() == Blocks.iron_bars && up.getBlock() == Blocks.air && - entityIn.getEntityWorld().getBlockState(new BlockPos(currentPoint.xCoord, currentPoint.yCoord, currentPoint.zCoord)).getBlock() != Blocks.iron_bars) { - boolean theFlag = false; - if (dir.getZ() == 0) { - if (entityIn.getEntityWorld().getBlockState(dungeonRoom.getMin().add(newX, newY, newZ) - .add(0,0,1)).getBlock() == Blocks.air) { - theFlag = true; - } else if (entityIn.getEntityWorld().getBlockState(dungeonRoom.getMin().add(newX, newY, newZ) - .add(0,0,-1)).getBlock() == Blocks.air) { - theFlag = true; - } - } else if (dir.getX() == 0) { - if (entityIn.getEntityWorld().getBlockState(dungeonRoom.getMin().add(newX, newY, newZ) - .add(-1,0,0)).getBlock() == Blocks.air) { - theFlag = true; - } else if (entityIn.getEntityWorld().getBlockState(dungeonRoom.getMin().add(newX, newY, newZ) - .add(1,0,0)).getBlock() == Blocks.air) { - theFlag = true; - } - } - if (theFlag) { - PathPoint pt = openPoint(newX, newY, newZ); - if (pt.visited) continue; - pathOptions[i++] = pt; - continue; - } - } - } - return i; - } - - public static final Set allowed = Sets.newHashSet(Blocks.air, Blocks.water, Blocks.lava, Blocks.flowing_water, Blocks.flowing_lava, Blocks.vine, Blocks.ladder - , Blocks.standing_sign, Blocks.wall_sign, Blocks.trapdoor, Blocks.iron_trapdoor, Blocks.wooden_button, Blocks.stone_button, Blocks.fire, - Blocks.torch, Blocks.rail, Blocks.golden_rail, Blocks.activator_rail, Blocks.detector_rail, Blocks.carpet, Blocks.redstone_torch); - public static final IBlockState preBuilt = Blocks.stone.getStateFromMeta(2); - public static boolean isValidBlock(IBlockState state) { - Block b = state.getBlock(); - return state.equals(preBuilt) || allowed.contains(b); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/ThetaStar.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/ThetaStar.java deleted file mode 100644 index 032223f0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/ThetaStar.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.pathfinding; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.*; -import net.minecraft.util.*; -import net.minecraft.world.World; - -import java.util.*; - -public class ThetaStar { - private final BlockPos min, max; - private final World world; - - int lastSx, lastSy, lastSz; - final int dx, dy, dz; - private DungeonRoom dungeonRoom; - - @Getter - private AxisAlignedBB destinationBB; - - public ThetaStar(DungeonRoom dungeonRoom, Vec3 destination) { - this.min = new BlockPos(dungeonRoom.getMinx(), 0, dungeonRoom.getMinz()); - this.max = new BlockPos(dungeonRoom.getMaxx(), 255, dungeonRoom.getMaxz()); - - this.world = dungeonRoom.getCachedWorld(); - this.dungeonRoom = dungeonRoom; - - this.dx = (int) (destination.xCoord * 2); - this.dy = (int) (destination.yCoord * 2); - this.dz = (int) (destination.zCoord * 2); - destinationBB = AxisAlignedBB.fromBounds(dx-2, dy-2, dz-2, dx+2, dy+2, dz+2); - } - - private Map nodeMap = new HashMap<>(); - - private Node openNode(int x, int y, int z) - { - Node.Coordinate coordinate = new Node.Coordinate(x,y,z); - Node node = this.nodeMap.get(coordinate); - - if (node == null) - { - node = new Node(coordinate); - this.nodeMap.put(coordinate, node); - } - - return node; - } - - @Getter - private LinkedList route = new LinkedList<>(); - - @Getter - private PriorityQueue open = new PriorityQueue<>(Comparator.comparing((Node a) -> a == null ? Float.MAX_VALUE : a.f).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.x).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.y).thenComparing(a -> a == null ? Float.MAX_VALUE : a.coordinate.z)); - - private int pfindIdx = 0; - - public boolean pathfind(Vec3 from, long timeout) { - - pfindIdx ++; - if (lastSx != (int)Math.round(from.xCoord * 2) || lastSy != (int)Math.round(from.yCoord*2) || lastSz != (int)Math.round(from.zCoord * 2)) - open.clear(); - - this.lastSx = (int) Math.round(from.xCoord * 2); - this.lastSy = (int) Math.round(from.yCoord * 2); - this.lastSz = (int) Math.round(from.zCoord * 2); - if (dungeonRoom.isBlocked(lastSx, lastSy, lastSz)) return false; - - Node startNode = openNode(dx, dy, dz); - Node goalNode = openNode(lastSx, lastSy, lastSz); - startNode.g = 0; - startNode.f = 0; - goalNode.g = Integer.MAX_VALUE; goalNode.f = Integer.MAX_VALUE; - if (goalNode.parent != null) { - LinkedList route = new LinkedList<>(); - Node curr =goalNode; - while(curr.parent != null) { - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - curr = curr.parent; - } - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - this.route = route; - return true; - } - open.add(startNode); - - long end = System.currentTimeMillis() + timeout; - - while (!open.isEmpty()) { - if (System.currentTimeMillis() > end) { - return false; - } - Node n = open.poll(); - if (n.lastVisited == pfindIdx) continue; - n.lastVisited = pfindIdx; - - if (n == goalNode) { - // route = reconstructPath(startNode) - LinkedList route = new LinkedList<>(); - Node curr =goalNode; - while(curr.parent != null) { - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - curr = curr.parent; - } - route.addLast(new Vec3(curr.coordinate.x / 2.0, curr.coordinate.y / 2.0 + 0.1, curr.coordinate.z/ 2.0)); - this.route = route; - return true; - } - - for (EnumFacing value : EnumFacing.VALUES) { - Node neighbor = openNode(n.coordinate.x + value.getFrontOffsetX(), n.coordinate.y + value.getFrontOffsetY(), n.coordinate.z + value.getFrontOffsetZ()); - - // check blocked. - if (!((destinationBB.minX <= neighbor.coordinate.x && neighbor.coordinate.x <= destinationBB.maxX && - destinationBB.minY <= neighbor.coordinate.y && neighbor.coordinate.y <= destinationBB.maxY && - destinationBB.minZ <= neighbor.coordinate.z && neighbor.coordinate.z <= destinationBB.maxZ) // near destination - || !dungeonRoom.isBlocked(neighbor.coordinate.x, neighbor.coordinate.y, neighbor.coordinate.z))) { // not blocked - continue; - } - if (neighbor.lastVisited == pfindIdx) continue; - - boolean flag = false; - if (n. parent != null) { - float tempGScore = n.parent.g + distSq(n.parent.coordinate.x - neighbor.coordinate.x, n.parent.coordinate.y - neighbor.coordinate.y, n.parent.coordinate.z - neighbor.coordinate.z); - if (tempGScore < neighbor.g && lineofsight(n.parent, neighbor)) { - neighbor.parent = n.parent; - neighbor.g = tempGScore; - neighbor.f = tempGScore + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); - open.add(neighbor); - flag = true; - } - } - if (!flag) { - float gScore = n.g + 1; // altho it's sq, it should be fine - if (gScore < neighbor.g) { - neighbor.parent = n; - neighbor.g = gScore; - neighbor.f = gScore +distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); - open.add(neighbor); - } else if (neighbor.lastVisited != pfindIdx) { - neighbor.f = neighbor.g + distSq(goalNode.coordinate.x - neighbor.coordinate.x, goalNode.coordinate.y - neighbor.coordinate.y, goalNode.coordinate.z - neighbor.coordinate.z); - open.add(neighbor); - } - } - } - } - return true; - } - - private boolean lineofsight(Node a, Node b) { - if (a == null || b == null) return false; - float sx = a.coordinate.x, sy = a.coordinate.y, sz = a.coordinate.z; - int ex = b.coordinate.x, ey = b.coordinate.y, ez = b.coordinate.z; - - float dx = ex - sx, dy = ey - sy, dz = ez - sz; - float len = distSq(dx, dy, dz); - dx /= len; dy /= len; dz /= len; - - for (int d = 0; d <= len; d += 1) { - if (dungeonRoom.isBlocked(Math.round(sx), (int) Math.ceil(sy), Math.round(sz))) return false; - if (dungeonRoom.isBlocked(Math.round(sx)+1, (int) Math.ceil(sy), Math.round(sz)+1)) return false; - if (dungeonRoom.isBlocked(Math.round(sx)-1, (int) Math.ceil(sy), Math.round(sz)-1)) return false; - if (dungeonRoom.isBlocked(Math.round(sx)+1, (int) Math.ceil(sy), Math.round(sz)-1)) return false; - if (dungeonRoom.isBlocked(Math.round(sx)-1, (int) Math.ceil(sy), Math.round(sz)+1)) return false; - sx += dx; sy += dy; sz += dz; - } - return true; - } - - private int manhatten(int x, int y, int z) {return Math.abs(x)+ Math.abs(y)+ Math.abs(z);} - private float distSq(float x, float y, float z) { - return MathHelper.sqrt_float(x * x + y * y + z * z); - } - - @RequiredArgsConstructor - @Data - public static final class Node { - @Data - @RequiredArgsConstructor - public static final class Coordinate { - private final int x, y, z; - } - - private final Coordinate coordinate; - - private float f = Float.MAX_VALUE, g = Float.MAX_VALUE; - private int lastVisited; - - @EqualsAndHashCode.Exclude - @ToString.Exclude - private Node parent; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/resources/DGTexturePack.java b/src/main/java/kr/syeyoung/dungeonsguide/resources/DGTexturePack.java deleted file mode 100644 index b9646993..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/resources/DGTexturePack.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.resources; - -import kr.syeyoung.dungeonsguide.Authenticator; -import lombok.AllArgsConstructor; -import net.minecraft.client.resources.IResourcePack; -import net.minecraft.client.resources.data.IMetadataSection; -import net.minecraft.client.resources.data.IMetadataSerializer; -import net.minecraft.util.ResourceLocation; - -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.Set; - -@AllArgsConstructor -public class DGTexturePack implements IResourcePack { - - private final Authenticator authenticator; - - @Override - public InputStream getInputStream(ResourceLocation location) throws IOException { - InputStream inputStream = this.getClass().getResourceAsStream("/assets/dg/"+location.getResourcePath()); - if (inputStream != null) return inputStream; - return new ByteArrayInputStream(authenticator.getResources().get("assets/dg/"+location.getResourcePath())); - } - - @Override - public boolean resourceExists(ResourceLocation location) { - return authenticator.getResources().containsKey("assets/dg/"+location.getResourcePath()) - || this.getClass().getResourceAsStream("/assets/dg/"+location.getResourcePath()) != null; - } - - @Override - public Set getResourceDomains() { - return Collections.singleton("dungeonsguide"); - } - - @Override - public T getPackMetadata(IMetadataSerializer p_135058_1_, String p_135058_2_) throws IOException { - return null; - } - - @Override - public BufferedImage getPackImage() throws IOException { - return new BufferedImage(512,512, BufferedImage.TYPE_INT_RGB); - } - - @Override - public String getPackName() { - return "Dungeons Guide Default Pack"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java deleted file mode 100755 index 1cafcbc7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; - -import java.util.LinkedList; -import java.util.Stack; - -public class EditingContext { - - private static EditingContext editingContext; - - public static void createEditingContext(DungeonRoom dungeonRoom) { - editingContext = new EditingContext(dungeonRoom); - } - - public static EditingContext getEditingContext() { - return editingContext; - } - - public static void endEditingSession() { - editingContext = null; - Minecraft.getMinecraft().displayGuiScreen(null); - } - - - private EditingContext(DungeonRoom dungeonRoom) { - this.room = dungeonRoom; - } - - @Getter - private final DungeonRoom room; - - @Getter - private final Stack guiStack = new Stack(); - - public boolean isEditingSecrets() { - return guiDungeonRoomEdit.isEditingSelected(); - } - public void endEditing() { - guiDungeonRoomEdit.endEditing(); - } - - private GuiDungeonRoomEdit guiDungeonRoomEdit; - @Getter - private GuiScreen current; - - public void openGui(GuiScreen gui) { - if (gui instanceof GuiDungeonRoomEdit) guiDungeonRoomEdit = (GuiDungeonRoomEdit) gui; - guiStack.push(current); - this.current = gui; - Minecraft.getMinecraft().displayGuiScreen(gui); - } - - public void goBack() { - current = guiStack.pop(); - Minecraft.getMinecraft().displayGuiScreen(current); - } - - public void reopen() { - Minecraft.getMinecraft().displayGuiScreen(current); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java deleted file mode 100755 index eb4d8987..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -public class Parameter { - private String name; - private Object previousData; - private Object newData; - - public Parameter(String name, Object previousData, Object newData) { - this.name = name; this.previousData = previousData; this.newData = newData; - } - - private Runnable onSetNewData; - - public void setNewData(Object newData) { - this.newData = newData; - if (onSetNewData != null) onSetNewData.run(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java deleted file mode 100755 index 4410d08e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.gui; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.gui.MGui; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditOffsetPointSet; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class GuiDungeonAddSet extends MGui { - - private final ValueEditOffsetPointSet valueEditOffsetPointSet; - - private final MButton add; - private final MButton back; - - - @Getter - private final OffsetPoint start; - @Getter - private final OffsetPoint end; - - public void onWorldRender(float partialTicks) { - for (OffsetPoint pos:getBlockPoses()) { - RenderUtils.highlightBlock(pos.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,255,50), partialTicks); - } - RenderUtils.highlightBlock(start.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(255,0,0,100), partialTicks); - RenderUtils.highlightBlock(end.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,0,100), partialTicks); - } - - public List getBlockPoses() { - int minX = Math.min(start.getX(), end.getX()); - int minY = Math.min(start.getY(), end.getY()); - int minZ = Math.min(start.getZ(), end.getZ()); - int maxX = Math.max(start.getX(), end.getX()); - int maxY = Math.max(start.getY(), end.getY()); - int maxZ = Math.max(start.getZ(), end.getZ()); - - List offsetPoints = new ArrayList(); - for (int z = minZ; z <= maxZ; z++) { - for (int x = minX; x <=maxX; x++) { - for (int y = maxY; y >= minY; y --) { - offsetPoints.add(new OffsetPoint(x,y,z)); - } - } - } - return offsetPoints; - } - - public void add() { - valueEditOffsetPointSet.addAll(getBlockPoses()); - } - - public GuiDungeonAddSet(final ValueEditOffsetPointSet processorParameterEditPane) { - this.valueEditOffsetPointSet = processorParameterEditPane; - getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179)); - { - start = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); - end = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); - } - { - MValue mValue = new MValue(start, Collections.emptyList()); - mValue.setBounds(new Rectangle(0,0,150,20)); - getMainPanel().add(mValue); - MValue mValue2 = new MValue(end,Collections.emptyList()); - mValue2.setBounds(new Rectangle(0,20,150,20)); - getMainPanel().add(mValue2); - } - { - add = new MButton() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20)); - } - }; - add.setText("Add"); - add.setBackgroundColor(Color.red); - add.setOnActionPerformed(new Runnable() { - @Override - public void run() { - add(); - EditingContext.getEditingContext().goBack(); - } - }); - - back = new MButton(){ - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20)); - } - }; - back.setText("Go back"); - back.setBackgroundColor(Color.green); - back.setOnActionPerformed(new Runnable() { - @Override - public void run() { - EditingContext.getEditingContext().goBack(); - } - }); - getMainPanel().add(add); - getMainPanel().add(back); - } - } - - @Override - public void initGui() { - super.initGui(); - // update bounds - getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java deleted file mode 100755 index 584d8472..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.gui; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MGui; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; - -public class GuiDungeonParameterEdit extends MGui { - - private final Parameter parameter; - private final DungeonRoom dungeonRoom; - - private String classSelection; - - private final MPanel currentValueEdit; - - private final MButton save; - private final MButton delete; - - @Getter - private ValueEdit valueEdit; - - public GuiDungeonParameterEdit(final MParameter parameter2, final DynamicEditor processorParameterEditPane) { - dungeonRoom = EditingContext.getEditingContext().getRoom(); - getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179)); - this.parameter = parameter2.getParameter(); - { - MTextField mTextField = new MTextField() { - @Override - public void edit(String str) { - parameter.setName(str); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Name", mTextField); - - mTextField.setText(parameter.getName()); - mLabelAndElement.setBounds(new Rectangle(0,0,200, 20)); - getMainPanel().add(mLabelAndElement); - } - { - classSelection = parameter.getNewData() == null ?"null" : parameter.getNewData().getClass().getName(); - final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(processorParameterEditPane.allowedClass(), classSelection) { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, 20, parentWidth,20)); - } - - @Override - public String selectionToDisplay(String selection) { - String[] split = selection.split("\\."); - return super.selectionToDisplay(split[split.length - 1]); - } - }; - - mStringSelectionButton.setOnUpdate(new Runnable() { - @Override - public void run() { - classSelection = mStringSelectionButton.getSelected(); - updateClassSelection(); - } - }); - mStringSelectionButton.setBounds(new Rectangle(0,20,150,20)); - getMainPanel().add(mStringSelectionButton); - } - { - currentValueEdit = new MPanel(){ - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, 40, parentWidth,parentHeight - 60)); - } - }; - getMainPanel().add(currentValueEdit); - } - { - delete = new MButton() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20)); - } - }; - delete.setText("Delete"); - delete.setBackgroundColor(Color.red); - delete.setOnActionPerformed(new Runnable() { - @Override - public void run() { - processorParameterEditPane.delete(parameter2); - EditingContext.getEditingContext().goBack(); - } - }); - - save = new MButton(){ - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20)); - } - }; - save.setText("Go back"); - save.setBackgroundColor(Color.green); - save.setOnActionPerformed(new Runnable() { - @Override - public void run() { - EditingContext.getEditingContext().goBack(); - } - }); - getMainPanel().add(delete); - getMainPanel().add(save); - } - updateClassSelection(); - } - - public void updateClassSelection() { - currentValueEdit.getChildComponents().clear(); - - ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(classSelection); - - if (!classSelection.equals(parameter.getNewData() == null ?"null" :parameter.getNewData().getClass().getName())) { - parameter.setNewData(valueEditCreator.createDefaultValue(parameter)); - parameter.setPreviousData(valueEditCreator.cloneObj(parameter.getNewData())); - } - - MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(parameter); - if (valueEdit == null) { - MLabel valueEdit2 = new MLabel() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, 0, parentWidth,20)); - } - }; - valueEdit2.setText("No Value Edit"); - valueEdit2.setBounds(new Rectangle(0,0,150,20)); - valueEdit = valueEdit2; - this.valueEdit = null; - } else{ - this.valueEdit = (ValueEdit) valueEdit; - } - valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height); - currentValueEdit.add(valueEdit); - } - @Override - public void initGui() { - super.initGui(); - // update bounds - getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java deleted file mode 100755 index 18c05ae5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.gui; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MGui; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MTabbedPane; -import kr.syeyoung.dungeonsguide.roomedit.panes.*; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.io.IOException; - -public class GuiDungeonRoomEdit extends MGui { - - private final DungeonRoom room; - - private final MTabbedPane tabbedPane; - @Getter - private final SecretEditPane sep; - - public GuiDungeonRoomEdit(DungeonRoom room) { - this.room = room; - - MTabbedPane tabbedPane = new MTabbedPane(); - getMainPanel().add(tabbedPane); - tabbedPane.setBackground2(new Color(17, 17, 17, 179)); - - - tabbedPane.addTab("General", new GeneralEditPane(room)); - tabbedPane.addTab("Match", new RoomDataDisplayPane(room)); - tabbedPane.addTab("Secrets", sep = new SecretEditPane(room)); - tabbedPane.addTab("Actions", new ActionDisplayPane(room)); - tabbedPane.addTab("Test", new RoommatchingPane(room)); - tabbedPane.addTab("Proc.Params", new ProcessorParameterEditPane(room)); - this.tabbedPane = tabbedPane; - } - - public boolean isEditingSelected() { - return "Secrets".equals(tabbedPane.getSelectedKey()); - } - public void endEditing() { - tabbedPane.setSelectedKey("General"); - } - - @Override - public void initGui() { - super.initGui(); - // update bounds - getMainPanel().setBounds(new Rectangle(Math.min((Minecraft.getMinecraft().displayWidth - 500) / 2, Minecraft.getMinecraft().displayWidth), Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),500,300)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java deleted file mode 100755 index 56192361..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.gui; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MGui; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.List; -import java.io.IOException; - -public class GuiDungeonValueEdit extends MGui { - private DungeonRoom dungeonRoom; - - - private MPanel currentValueEdit; - - private MButton save; - - @Getter - private ValueEdit valueEdit; - - private List addons; - - private Object editingObj; - - public GuiDungeonValueEdit(final Object object, final List addons) { - try { - dungeonRoom = EditingContext.getEditingContext().getRoom(); - this.addons = addons; - this.editingObj = object; - getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179)); - { - currentValueEdit = new MPanel() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, 0, parentWidth, parentHeight - 20 - addons.size() * 20)); - } - }; - getMainPanel().add(currentValueEdit); - } - - for (MPanel addon : addons) { - getMainPanel().add(addon); - } - { - save = new MButton() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, parentHeight - 20, parentWidth, 20)); - } - }; - save.setText("Go back"); - save.setBackgroundColor(Color.green); - save.setOnActionPerformed(new Runnable() { - @Override - public void run() { - EditingContext.getEditingContext().goBack(); - } - }); - getMainPanel().add(save); - } - updateClassSelection(); - } catch (Exception e){} - } - - public void updateClassSelection() { - currentValueEdit.getChildComponents().clear(); - - ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(editingObj == null ?"null":editingObj.getClass().getName()); - - MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(new Parameter("", editingObj, editingObj)); - if (valueEdit == null) { - MLabel valueEdit2 = new MLabel() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, 0, parentWidth,20)); - } - }; - valueEdit2.setText("No Value Edit"); - valueEdit2.setBounds(new Rectangle(0,0,150,20)); - valueEdit = valueEdit2; - this.valueEdit = null; - } else{ - this.valueEdit = (ValueEdit) valueEdit; - } - valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height); - currentValueEdit.add(valueEdit); - } - @Override - public void initGui() { - super.initGui(); - // update bounds - getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300)); - - - for (int i = 0; i < addons.size(); i++) { - addons.get(i).setBounds(new Rectangle(0, getMainPanel().getBounds().height - (i+1) * 20 - 20, getMainPanel().getBounds().width, 20)); - } - save.setBounds(new Rectangle(0 ,getMainPanel().getBounds().height - 20, getMainPanel().getBounds().width, 20)); - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java deleted file mode 100755 index 04ae7643..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonBreakableWall; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.init.Blocks; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Collections; - -public class ValueEditBreakableWall extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonBreakableWall dungeonBreakableWall; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - private final MButton updateOnlyAir; - - public ValueEditBreakableWall(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonBreakableWall = (DungeonBreakableWall) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Wall Points"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonBreakableWall.getSecretPoint(), Collections.emptyList()); - add(value); - - updateOnlyAir = new MButton(); - updateOnlyAir.setText("Update Air"); - updateOnlyAir.setBackgroundColor(Color.green); - updateOnlyAir.setForeground(Color.black); - updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); - add(updateOnlyAir); - updateOnlyAir.setOnActionPerformed(new Runnable() { - @Override - public void run() { - OffsetPointSet ofs = dungeonBreakableWall.getSecretPoint(); - List filtered = new ArrayList(); - for (OffsetPoint offsetPoint : ofs.getOffsetPointList()) { - if (offsetPoint.getBlock(EditingContext.getEditingContext().getRoom()) != Blocks.air) continue; - filtered.add(offsetPoint); - } - dungeonBreakableWall.getSecretPoint().setOffsetPointList(filtered); - } - }); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonBreakableWall.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonBreakableWall.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(preRequisite2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonBreakableWall.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditBreakableWall createValueEdit(Parameter parameter) { - return new ValueEditBreakableWall(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonBreakableWall(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonBreakableWall)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDoor.java deleted file mode 100755 index 0fc7de4c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDoor.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDoor; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.init.Blocks; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class ValueEditDoor extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonDoor dungeonDoor; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite_par; - private final MTextField preRequisite2; - private final MLabelAndElement preRequisite2_par; - private final MButton updateOnlyAir; - - public ValueEditDoor(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonDoor = (DungeonDoor) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Wall Points"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonDoor.getSecretPoint(), Collections.emptyList()); - add(value); - - updateOnlyAir = new MButton(); - updateOnlyAir.setText("Update Air"); - updateOnlyAir.setBackgroundColor(Color.green); - updateOnlyAir.setForeground(Color.black); - updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); - add(updateOnlyAir); - updateOnlyAir.setOnActionPerformed(new Runnable() { - @Override - public void run() { - OffsetPointSet ofs = dungeonDoor.getSecretPoint(); - List filtered = new ArrayList(); - for (OffsetPoint offsetPoint : ofs.getOffsetPointList()) { - if (offsetPoint.getBlock(EditingContext.getEditingContext().getRoom()) != Blocks.air) continue; - filtered.add(offsetPoint); - } - dungeonDoor.getSecretPoint().setOffsetPointList(filtered); - } - }); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonDoor.setOpenPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonDoor.getOpenPreRequisite(), ",")); - preRequisite_par = new MLabelAndElement("Open Req.",preRequisite); - preRequisite_par.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(preRequisite_par); - - preRequisite2 = new MTextField() { - @Override - public void edit(String str) { - dungeonDoor.setClosePreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite2.setText(TextUtils.join(dungeonDoor.getClosePreRequisite(), ",")); - preRequisite2_par = new MLabelAndElement("Close Req.",preRequisite2); - preRequisite2_par.setBounds(new Rectangle(0,80,getBounds().width,20)); - add(preRequisite2_par); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); - preRequisite_par.setBounds(new Rectangle(0,60,getBounds().width,20)); - preRequisite2_par.setBounds(new Rectangle(0,80,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonDoor.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditDoor createValueEdit(Parameter parameter) { - return new ValueEditDoor(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonDoor(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonDoor)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDummy.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDummy.java deleted file mode 100755 index 7c211b52..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditDummy.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDummy; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonNPC; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MTextField; -import kr.syeyoung.dungeonsguide.gui.elements.MValue; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - -public class ValueEditDummy extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonDummy dungeonSecret; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - - public ValueEditDummy(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonSecret = (DungeonDummy) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Dummy Point"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); - add(value); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(preRequisite2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditDummy createValueEdit(Parameter parameter) { - return new ValueEditDummy(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonDummy(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonDummy)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java deleted file mode 100755 index 7ac9ac1a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - -public class ValueEditFairySoul extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonFairySoul dungeonSecret; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - - public ValueEditFairySoul(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonSecret = (DungeonFairySoul) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("FairySoul Point"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); - add(value); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(preRequisite2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditFairySoul createValueEdit(Parameter parameter) { - return new ValueEditFairySoul(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonFairySoul(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonFairySoul)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditJournal.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditJournal.java deleted file mode 100755 index f56b1630..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditJournal.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonJournal; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MTextField; -import kr.syeyoung.dungeonsguide.gui.elements.MValue; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - - -public class ValueEditJournal extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonJournal dungeonSecret; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - - public ValueEditJournal(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonSecret = (DungeonJournal) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Journal Point"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); - add(value); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(preRequisite2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditJournal createValueEdit(Parameter parameter) { - return new ValueEditJournal(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonJournal(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonJournal)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java deleted file mode 100755 index aaeb607f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonLever; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - -public class ValueEditLever extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonLever dungeonLever; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - private final MTextField target; - private final MLabelAndElement target2; - - public ValueEditLever(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonLever = (DungeonLever) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Secret Point"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonLever.getLeverPoint(), Collections.emptyList()); - add(value); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonLever.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonLever.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(preRequisite2); - - - target = new MTextField() { - @Override - public void edit(String str) { - dungeonLever.setTriggering(str); - } - }; - target.setText(dungeonLever.getTriggering()); - target2 = new MLabelAndElement("Target",target); - target2.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(target2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - target2.setBounds(new Rectangle(0,60,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonLever.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditLever createValueEdit(Parameter parameter) { - return new ValueEditLever(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonLever(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonLever)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditNPC.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditNPC.java deleted file mode 100755 index 4146b491..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditNPC.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonNPC; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MTextField; -import kr.syeyoung.dungeonsguide.gui.elements.MValue; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - -public class ValueEditNPC extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonNPC dungeonSecret; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - - public ValueEditNPC(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonSecret = (DungeonNPC) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("NPC Point"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); - add(value); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(preRequisite2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditNPC createValueEdit(Parameter parameter) { - return new ValueEditNPC(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonNPC(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonNPC)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java deleted file mode 100755 index ede6ee43..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayDoor; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.init.Blocks; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class ValueEditOnewayDoor extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonOnewayDoor dungeonDoor; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - private final MButton updateOnlyAir; - - public ValueEditOnewayDoor(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonDoor = (DungeonOnewayDoor) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Wall Points"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonDoor.getSecretPoint(), Collections.emptyList()); - add(value); - - updateOnlyAir = new MButton(); - updateOnlyAir.setText("Update Air"); - updateOnlyAir.setBackgroundColor(Color.green); - updateOnlyAir.setForeground(Color.black); - updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); - add(updateOnlyAir); - updateOnlyAir.setOnActionPerformed(new Runnable() { - @Override - public void run() { - OffsetPointSet ofs = dungeonDoor.getSecretPoint(); - List filtered = new ArrayList(); - for (OffsetPoint offsetPoint : ofs.getOffsetPointList()) { - if (offsetPoint.getBlock(EditingContext.getEditingContext().getRoom()) != Blocks.air) continue; - filtered.add(offsetPoint); - } - dungeonDoor.getSecretPoint().setOffsetPointList(filtered); - } - }); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonDoor.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonDoor.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(preRequisite2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - updateOnlyAir.setBounds(new Rectangle(0,40,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonDoor.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditOnewayDoor createValueEdit(Parameter parameter) { - return new ValueEditOnewayDoor(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonOnewayDoor(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonOnewayDoor)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java deleted file mode 100755 index 2a15adad..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayLever; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MTextField; -import kr.syeyoung.dungeonsguide.gui.elements.MValue; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - -public class ValueEditOnewayLever extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonOnewayLever dungeonLever; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - private final MTextField target; - private final MLabelAndElement target2; - - - public ValueEditOnewayLever(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonLever = (DungeonOnewayLever) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Secret Point"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonLever.getLeverPoint(), Collections.emptyList()); - add(value); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonLever.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonLever.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(preRequisite2); - - - target = new MTextField() { - @Override - public void edit(String str) { - dungeonLever.setTriggering(str); - } - }; - target.setText(dungeonLever.getTriggering()); - target2 = new MLabelAndElement("Target",target); - target2.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(target2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - target2.setBounds(new Rectangle(0,60,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonLever.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditOnewayLever createValueEdit(Parameter parameter) { - return new ValueEditOnewayLever(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonOnewayLever(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonOnewayLever)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java deleted file mode 100755 index 99d60baa..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonPressurePlate; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MTextField; -import kr.syeyoung.dungeonsguide.gui.elements.MValue; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - -public class ValueEditPressurePlate extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonPressurePlate dungeonPressureplate; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - private final MTextField target; - private final MLabelAndElement target2; - - - public ValueEditPressurePlate(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonPressureplate = (DungeonPressurePlate) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Secret Point"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonPressureplate.getPlatePoint(), Collections.emptyList()); - add(value); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonPressureplate.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonPressureplate.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(preRequisite2); - - - target = new MTextField() { - @Override - public void edit(String str) { - dungeonPressureplate.setTriggering(str); - } - }; - target.setText(dungeonPressureplate.getTriggering()); - target2 = new MLabelAndElement("Target",target); - target2.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(target2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - target2.setBounds(new Rectangle(0,60,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonPressureplate.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditPressurePlate createValueEdit(Parameter parameter) { - return new ValueEditPressurePlate(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonPressurePlate(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonPressurePlate)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java deleted file mode 100755 index 72cb410b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - -public class ValueEditSecret extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonSecret dungeonSecret; - - private final MLabel label; - private final MValue value; - private final MStringSelectionButton selectionButton; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - - public ValueEditSecret(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonSecret = (DungeonSecret) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Secret Point"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); - add(value); - - selectionButton = new MStringSelectionButton(Arrays.asList("CHEST", "BAT", "ITEM_DROP", "ESSENCE"), dungeonSecret.getSecretType().name()); - selectionButton.setOnUpdate(new Runnable() { - @Override - public void run() { - dungeonSecret.setSecretType(DungeonSecret.SecretType.valueOf(selectionButton.getSelected())); - } - }); - add(selectionButton); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(preRequisite2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - selectionButton.setBounds(new Rectangle(0,40,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,60,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditSecret createValueEdit(Parameter parameter) { - return new ValueEditSecret(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonSecret(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonSecret)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java deleted file mode 100755 index 042a8258..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonTomb; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.utils.TextUtils; - -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; - -public class ValueEditTomb extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - private final DungeonTomb dungeonTomb; - - private final MLabel label; - private final MValue value; - private final MTextField preRequisite; - private final MLabelAndElement preRequisite2; - - public ValueEditTomb(final Parameter parameter2) { - this.parameter = parameter2; - this.dungeonTomb = (DungeonTomb) parameter2.getNewData(); - - - label = new MLabel(); - label.setText("Tomb Points"); - label.setAlignment(MLabel.Alignment.LEFT); - add(label); - - value = new MValue(dungeonTomb.getSecretPoint(), Collections.emptyList()); - add(value); - - preRequisite = new MTextField() { - @Override - public void edit(String str) { - dungeonTomb.setPreRequisite(Arrays.asList(str.split(","))); - } - }; - preRequisite.setText(TextUtils.join(dungeonTomb.getPreRequisite(), ",")); - preRequisite2 = new MLabelAndElement("Req.",preRequisite); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(preRequisite2); - } - - @Override - public void onBoundsUpdate() { - label.setBounds(new Rectangle(0,0,getBounds().width, 20)); - value.setBounds(new Rectangle(0,20,getBounds().width, 20)); - preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - dungeonTomb.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditTomb createValueEdit(Parameter parameter) { - return new ValueEditTomb(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new DungeonTomb(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((DungeonTomb)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java deleted file mode 100755 index 68ccdf6c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; - -import java.awt.*; - -public class ActionDisplayPane extends MPanel { - private final DungeonRoom dungeonRoom; - - private ActionTreeDisplayPane displayPane; - - private final MTextField textField; - private final MButton calculate; - public ActionDisplayPane(final DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - - { - textField = new MTextField(); - textField.setBounds(new Rectangle(0,0,getBounds().width - 100, 20)); - add(textField); - } - { - calculate = new MButton(); - calculate.setBounds(new Rectangle(getBounds().width - 100,0,100, 20)); - calculate.setText("calculate"); - calculate.setOnActionPerformed(new Runnable() { - @Override - public void run() { - try { - remove(displayPane); - - String text = textField.getText(); - String target = text.split(":")[0]; - String state = text.split(":")[1]; - ActionChangeState actionChangeState = new ActionChangeState(target, state); - ActionTree tree= ActionTree.buildActionTree(actionChangeState, dungeonRoom); - - displayPane = new ActionTreeDisplayPane(dungeonRoom, tree); - displayPane.setBounds(new Rectangle(0,25,getBounds().width,getBounds().height-25)); - add(displayPane); - } catch (Throwable t) { - t.printStackTrace(); - } - } - }); - add(calculate); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - @Override - public void onBoundsUpdate() { - textField.setBounds(new Rectangle(0,0,getBounds().width - 100, 20)); - calculate.setBounds(new Rectangle(getBounds().width - 100,0,100, 20)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java deleted file mode 100755 index dd8331a7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.dungeon.actions.Action; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTreeUtil; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class ActionTreeDisplayPane extends MPanel { - - private int offsetX = 0; - private int offsetY = 0; - - private float scale; - - private final DungeonRoom dungeonRoom; - private final ActionTree tree; - private List linearified; - public ActionTreeDisplayPane(DungeonRoom dungeonRoom, ActionTree tree) { - this.dungeonRoom = dungeonRoom; - this.tree = tree; - try { - this.linearified = ActionTreeUtil.linearifyActionTree(tree); - } catch (Exception e) { - linearified = new ArrayList(); - e.printStackTrace(); - } - scale = 1.0f; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - GlStateManager.pushMatrix(); - GlStateManager.translate(offsetX, offsetY, 0); - GlStateManager.scale(scale,scale,1); - int x = renderTree(tree, 5, 5, Minecraft.getMinecraft().fontRendererObj, null, new HashMap()); - renderLinearified(linearified, x, 5, fr); - GlStateManager.popMatrix(); - } - - public int renderTree(ActionTree actionTree, int x, int y, FontRenderer fr, Point drawLineFrom, HashMap drawmPoints) { - if (drawmPoints.containsKey(actionTree)) { - // recursive, fu - Point pt = drawmPoints.get(actionTree); - - GlStateManager.pushMatrix(); - - GlStateManager.enableBlend(); - GlStateManager.disableDepth(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(770, 771); - GlStateManager.enableBlend(); - GL11.glLineWidth(1); - GlStateManager.color(1, 0, 0, 1); - GL11.glBegin(2); - GL11.glVertex2d(drawLineFrom.x, drawLineFrom.y); - GL11.glVertex2d(pt.x, pt.y); - GL11.glEnd(); - GlStateManager.disableBlend(); - GlStateManager.enableTexture2D(); - GlStateManager.enableDepth(); - GlStateManager.disableBlend(); - GlStateManager.popMatrix(); - - return 0; - } - - Dimension dim = renderAction(actionTree.getCurrent(), x, y, fr); - if (drawLineFrom != null) { - GlStateManager.pushMatrix(); - - - GlStateManager.enableBlend(); - GlStateManager.disableDepth(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(770, 771); - GlStateManager.enableBlend(); - GL11.glLineWidth(1); - GlStateManager.color(1, 1, 1, 1); - GL11.glBegin(2); - GL11.glVertex2d(drawLineFrom.x, drawLineFrom.y); - GL11.glVertex2d(x + dim.width / 2, y); - GL11.glEnd(); - GlStateManager.disableBlend(); - GlStateManager.enableTexture2D(); - GlStateManager.enableDepth(); - GlStateManager.disableBlend(); - GlStateManager.popMatrix(); - - } - Point pt = new Point(x + dim.width / 2, y + dim.height); - - drawmPoints.put(actionTree, new Point(x + dim.width / 2, y + dim.height / 2)); - int xOff = 0; - for (ActionTree tree:actionTree.getChildren()) { - xOff += renderTree(tree, x + xOff, y + dim.height + 10, fr, pt, drawmPoints) + 10; - } - return Math.max(xOff, dim.width); - } - - public void renderLinearified(List actions, int x, int y, FontRenderer fr) { - Point lastPt = null; - int y2 = y; - - for (Action action : actions) { - Dimension dim = renderAction(action, x, y2, fr); - if (lastPt != null) { - GlStateManager.pushMatrix(); - - - GlStateManager.enableBlend(); - GlStateManager.disableDepth(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(770, 771); - GlStateManager.enableBlend(); - GL11.glLineWidth(1); - GlStateManager.color(1, 1, 1, 1); - GL11.glBegin(2); - GL11.glVertex2d(lastPt.x, lastPt.y); - GL11.glVertex2d(x + dim.width / 2, y2); - GL11.glEnd(); - GlStateManager.disableBlend(); - GlStateManager.enableTexture2D(); - GlStateManager.enableDepth(); - GlStateManager.disableBlend(); - GlStateManager.popMatrix(); - - } - lastPt = new Point(x + dim.width / 2, y2 + dim.height); - - y2 += dim.height + 10; - } - } - - public Dimension renderAction(Action action, int x, int y, FontRenderer fr) { - String[] lines = action.toString().split("\n"); - int maxWidth = 0; - for (String line : lines) { - if (fr.getStringWidth(line) > maxWidth) maxWidth= fr.getStringWidth(line); - } - int offset = 2; - int height = (fr.FONT_HEIGHT + offset) * lines.length; - - Gui.drawRect(x,y,x + maxWidth +10, y + height + 10, 0xff000000); - Gui.drawRect(x+1,y+1,x + maxWidth +8, y + height + 8, 0xff4d4d4d); - for (int i = 0; i < lines.length; i++) { - fr.drawString(lines[i], x + 5, y + 5 + i*(fr.FONT_HEIGHT + offset), 0xffffffff); - } - - return new Dimension(maxWidth + 10, height + 10); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,25,parentWidth,parentHeight-25)); - } - - - private int lastX; - private int lastY; - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - lastX = absMouseX; - lastY = absMouseY; - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - int dX = absMouseX - lastX; - int dY = absMouseY - lastY; - offsetX += dX; - offsetY += dY; - lastX = absMouseX; - lastY = absMouseY; - } - - @Override - public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (scrollAmount > 0) scale += 0.1; - if (scrollAmount < 0) scale -= 0.1; - - if (scale < 0) scale = 0.1f; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/DynamicEditor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/DynamicEditor.java deleted file mode 100755 index 1c10e647..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/DynamicEditor.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.gui.elements.MParameter; - -import java.util.List; - -public interface DynamicEditor { - void delete(MParameter parameter); - - List allowedClass(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java deleted file mode 100755 index 1133a8a9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; - -import java.awt.*; -import java.io.*; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.UUID; -import java.util.zip.GZIPOutputStream; - -public class GeneralEditPane extends MPanel { - private final DungeonRoom dungeonRoom; - - private final MLabelAndElement uuid; - private final MLabelAndElement name; - private final MLabelAndElement secrets; - - private final MLabelAndElement shape; - private final MLabelAndElement rotation; - private final MLabelAndElement shape2; - - private MButton save; - private final MButton end; - private final MButton schematic; - - private final MLabelAndElement roomProcessor; - - public GeneralEditPane(final DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - { - MLabel la; - uuid = new MLabelAndElement("Room UUID: ", la = new MLabel()); - la.setText(dungeonRoom.getDungeonRoomInfo().getUuid().toString()); - uuid.setBounds(new Rectangle(0,0,getBounds().width, 20)); - add(uuid); - } - { - MTextField la = new MTextField() { - @Override - public void edit(String str) { - dungeonRoom.getDungeonRoomInfo().setName(str); - } - }; - name = new MLabelAndElement("Room Name: ", la); - la.setText(dungeonRoom.getDungeonRoomInfo().getName()); - name.setBounds(new Rectangle(0,20,getBounds().width, 20)); - add(name); - } - { - final MIntegerSelectionButton la = new MIntegerSelectionButton(dungeonRoom.getDungeonRoomInfo().getTotalSecrets()); - la.setOnUpdate(new Runnable() { - @Override - public void run() { - dungeonRoom.getDungeonRoomInfo().setTotalSecrets(la.getData()); - } - }); - secrets = new MLabelAndElement("Room Secrets: ", la); - secrets.setBounds(new Rectangle(0,40,getBounds().width, 20)); - add(secrets); - } - - { - MLabel la; - shape = new MLabelAndElement("Room Shape: ", la = new MLabel()); - la.setText(dungeonRoom.getDungeonRoomInfo().getShape()+""); - shape.setBounds(new Rectangle(0,60,getBounds().width, 20)); - add(shape); - } - - { - MLabel la; - rotation = new MLabelAndElement("Found Room Rotation: ", la = new MLabel()); - la.setText(dungeonRoom.getRoomMatcher().getRotation()+""); - rotation.setBounds(new Rectangle(0,80,getBounds().width, 20)); - add(rotation); - } - { - MLabel la; - shape2 = new MLabelAndElement("Found Room Shape: ", la = new MLabel()); - la.setText(dungeonRoom.getShape()+""); - shape2.setBounds(new Rectangle(0,100,getBounds().width, 20)); - add(shape2); - } - { - final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList(ProcessorFactory.getProcessors()), dungeonRoom.getDungeonRoomInfo().getProcessorId()); - roomProcessor = new MLabelAndElement("Room Processor: ", mStringSelectionButton); - roomProcessor.setBounds(new Rectangle(0,120,getBounds().width, 20)); - add(roomProcessor); - - mStringSelectionButton.setOnUpdate(new Runnable() { - @Override - public void run() { - dungeonRoom.getDungeonRoomInfo().setProcessorId(mStringSelectionButton.getSelected()); - dungeonRoom.updateRoomProcessor(); - } - }); - } - { - end = new MButton(); - end.setText("End Editing Session"); - end.setOnActionPerformed(new Runnable() { - @Override - public void run() { - EditingContext.endEditingSession(); - } - }); - end.setBackgroundColor(Color.green); - end.setBounds(new Rectangle(0,140,getBounds().width, 20)); - add(end); - } - { - schematic = new MButton(); - schematic.setText("Save Schematic"); - schematic.setOnActionPerformed(new Runnable() { - @Override - public void run() { - try { - NBTTagCompound nbtTagCompound2 = createNBT(); - - File f=new File(DungeonsGuide.getDungeonsGuide().getConfigDir(), "schematics/"+ - dungeonRoom.getDungeonRoomInfo().getName()+"-"+dungeonRoom.getDungeonRoomInfo().getUuid().toString()+"-"+ UUID.randomUUID()+".schematic"); - - Method method = null; - try { - method = NBTTagCompound.class.getDeclaredMethod("write", DataOutput.class); - method.setAccessible(true); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - return; - } - FileOutputStream fos = new FileOutputStream(f); - DataOutputStream dataoutputstream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fos))); - - try - { - dataoutputstream.writeByte(nbtTagCompound2.getId()); - - dataoutputstream.writeUTF("Schematic"); - method.invoke(nbtTagCompound2, dataoutputstream); - } - finally - { - dataoutputstream.close(); - } - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงfSaved to "+f.getName())); - } catch (Throwable e) { - e.printStackTrace(); - } - - } - }); - schematic.setBackgroundColor(Color.orange); - schematic.setBounds(new Rectangle(0,180,getBounds().width, 20)); - add(schematic); - } - { - if (dungeonRoom.getDungeonRoomInfo().isRegistered()) return; - save = new MButton(); - save.setText("Save RoomData"); - save.setOnActionPerformed(new Runnable() { - @Override - public void run() { - DungeonRoomInfoRegistry.register(dungeonRoom.getDungeonRoomInfo()); - remove(save); - } - }); - save.setBackgroundColor(Color.green); - save.setBounds(new Rectangle(0,10,getBounds().width, 20)); - add(save); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - @Override - public void onBoundsUpdate() { - if (save != null) - save.setBounds(new Rectangle(0,160,getBounds().width, 20)); - end.setBounds(new Rectangle(1,140,getBounds().width-2, 20)); - if (schematic != null) - schematic.setBounds(new Rectangle(0,180,getBounds().width, 20)); - } - - private NBTTagCompound createNBT() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setShort("Width", (short) (dungeonRoom.getMax().getX() - dungeonRoom.getMin().getX() + 1)); - compound.setShort("Height", (short) 255); - compound.setShort("Length", (short) (dungeonRoom.getMax().getZ() - dungeonRoom.getMin().getZ() + 1)); - int size =compound.getShort("Width") * compound.getShort("Height") * compound.getShort("Length"); - - byte[] blocks = new byte[size]; - byte[] meta = new byte[size]; - byte[] extra = new byte[size]; - byte[] extranibble = new byte[(int) Math.ceil(size / 2.0)]; - - boolean extraEx = false; - NBTTagList tileEntitiesList = new NBTTagList(); - for (int x = 0; x < compound.getShort("Width"); x++) { - for (int y = 0; y < compound.getShort("Height"); y++) { - for (int z = 0; z < compound.getShort("Length"); z++) { - int index = x + (y * compound.getShort("Length") + z) * compound.getShort("Width"); - BlockPos pos = dungeonRoom.getRelativeBlockPosAt(x,y - 70,z); - IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); - boolean acc = dungeonRoom.canAccessRelative(x,z); - int id = Block.getIdFromBlock(blockState.getBlock()); - blocks[index] = acc ? (byte) id : 0; - meta[index] = acc ? (byte) blockState.getBlock().getMetaFromState(blockState) : 0; - if ((extra[index] = (byte) ((acc ? id : 0) >> 8)) > 0) { - extraEx = true; - } - - if (blockState.getBlock().hasTileEntity(blockState)) { - TileEntity tileEntity = dungeonRoom.getContext().getWorld().getTileEntity(pos); - try { - final NBTTagCompound tileEntityCompound = new NBTTagCompound(); - tileEntity.writeToNBT(tileEntityCompound); - tileEntitiesList.appendTag(tileEntityCompound); - } catch (final Exception e) { - final BlockPos tePos = tileEntity.getPos(); - - blocks[index] = (byte) 7; - meta[index] = 0; - extra[index] = 0; - } - } - } - } - } - for (int i = 0; i < extranibble.length; i++) { - if (i * 2 + 1 < extra.length) { - extranibble[i] = (byte) ((extra[i * 2 + 0] << 4) | extra[i * 2 + 1]); - } else { - extranibble[i] = (byte) (extra[i * 2 + 0] << 4); - } - } - - - compound.setByteArray("Blocks", blocks); - compound.setByteArray("Data", meta); - compound.setString("Materials", "Alpha"); - if (extraEx) { - compound.setByteArray("AddBlocks", extranibble); - } - compound.setTag("Entities", new NBTTagList()); - compound.setTag("TileEntities", tileEntitiesList); - - return compound; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java deleted file mode 100755 index d719185d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MParameter; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -public class ProcessorParameterEditPane extends MPanel implements DynamicEditor { - private final DungeonRoom dungeonRoom; - - private MButton save; - private MButton create; - private final List parameters = new ArrayList(); - - public ProcessorParameterEditPane(DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - buildElements(); - } - - public void buildElements() { - { - create = new MButton(); - create.setText("Create New Parameter"); - create.setBackgroundColor(Color.cyan); - create.setBounds(new Rectangle(0,0,100,20)); - create.setOnActionPerformed(new Runnable() { - @Override - public void run() { - MParameter parameter; - parameters.add(parameter = new MParameter(new Parameter(UUID.randomUUID().toString(), null, null), ProcessorParameterEditPane.this)); - parameter.setParent(ProcessorParameterEditPane.this); - parameter.setBounds(new Rectangle(0,0,getBounds().width, 20)); - } - }); - - save = new MButton(); - save.setText("Save"); - save.setBackgroundColor(Color.green); - save.setBounds(new Rectangle(0,0,100,20)); - save.setOnActionPerformed(new Runnable() { - @Override - public void run() { - DungeonRoomInfo dungeonRoomInfo = dungeonRoom.getDungeonRoomInfo(); - dungeonRoomInfo.getProperties().clear(); - - for (MParameter parameter : parameters) { - Parameter real = parameter.getParameter(); - - ValueEditCreator vec = ValueEditRegistry.getValueEditMap(real.getNewData() == null ? "null" :real.getNewData().getClass().getName()); - - real.setPreviousData(vec.cloneObj(real.getNewData())); - dungeonRoomInfo.getProperties().put(real.getName(), real.getNewData()); - } - } - }); - create.setParent(this); save.setParent(this); - } - { - for (Map.Entry en : dungeonRoom.getDungeonRoomInfo().getProperties().entrySet()) { - ValueEditCreator vec = ValueEditRegistry.getValueEditMap(en.getValue() == null ? "null" :en.getValue().getClass().getName()); - - MParameter mParameter = new MParameter(new Parameter(en.getKey(), vec.cloneObj(en.getValue()), vec.cloneObj(en.getValue())), this); - mParameter.setBounds(new Rectangle(0,0,getBounds().width,20)); - parameters.add(mParameter); - mParameter.setParent(this); - } - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - - public void delete(MParameter parameter) { - parameters.remove(parameter); - } - - @Override - public List allowedClass() { - return ValueEditRegistry.getClassesSupported(); - } - - - @Override - public List getChildComponents() { - ArrayList panels = new ArrayList(parameters); - panels.add(create); - panels.add(save); - return panels; - } - - private int offsetY = 0; - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - int heights = 0; - for (MPanel panel:getChildComponents()) { - panel.setPosition(new Point(0, -offsetY + heights)); - heights += panel.getBounds().height; - } - } - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (scrollAmount > 0) offsetY -= 20; - else if (scrollAmount < 0) offsetY += 20; - if (offsetY < 0) offsetY = 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java deleted file mode 100755 index bd3da672..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomDataDisplayPane.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import java.awt.*; - -public class RoomDataDisplayPane extends MPanel { - - private int offsetX = 0; - private int offsetY = 0; - - private int selectedX = -1; - private int selectedY = -1; - - private final DungeonRoom dungeonRoom; - public RoomDataDisplayPane(DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - int[][] blocks = dungeonRoom.getDungeonRoomInfo().getBlocks(); - // draw Axis; - Gui.drawRect(0,0,10,10,0x77777777); - clip(clip.x + 10, clip.y, clip.width - 10, 10); - Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); - for (int x = 0; x < blocks[0].length; x++) { - fr.drawString(x+"", x * 16 +10 + offsetX, 0, 0xFFFFFFFF); - } - clip(clip.x, clip.y +10, 10, clip.height-10); - Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); - for (int z = 0; z < blocks.length; z++) { - fr.drawString(z+"", 2, z * 16 + 10 + offsetY, 0xFFFFFFFF); - } - - int hoverX = (relMousex0 - offsetX - 10) / 16; - int hoverY = (relMousey0 - offsetY - 10) / 16; - // draw Content - clip(clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10); - for (int z = 0; z < blocks.length; z++) { - for (int x = 0; x < blocks[z].length; x++) { - int data = blocks[z][x]; - if (z == selectedY && x == selectedX){ - Gui.drawRect(x *16 +10+offsetX, z *16 +10 + offsetY, x *16 +26 +offsetX, z *16 +26 + offsetY, 0xAA707070); - } else if (z == hoverY && x == hoverX) { - Gui.drawRect(x *16 +10+offsetX, z *16 +10 + offsetY, x *16 +26 +offsetX, z *16 +26 + offsetY, 0xAA505050); - } - - - if (data == -1) fr.drawString("X", x *16 +10 + offsetX, z *16 +10 + offsetY,0xFFFFFF); - else drawItemStack(new ItemStack(Item.getItemFromBlock(Block.getBlockById(data)), 1), x * 16 +10 + offsetX, z *16 +10 + offsetY); - } - } - - } - private void drawItemStack(ItemStack stack, int x, int y) - { - Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, x, y); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - @Override - public void keyPressed(char typedChar, int keyCode) { - int[][] blocks = dungeonRoom.getDungeonRoomInfo().getBlocks(); - if (selectedX != -1 && selectedY != -1 && selectedY < blocks.length && selectedX < blocks[0].length) { - dungeonRoom.getDungeonRoomInfo().getBlocks()[selectedY][selectedX] = -1; - } - } - - private int lastX; - private int lastY; - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - lastX = absMouseX; - lastY = absMouseY; - - if (lastAbsClip.contains(absMouseX, absMouseY)) { - selectedX = (relMouseX - offsetX - 10) / 16; - selectedY = (relMouseY - offsetY - 10) / 16; - } - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - int dX = absMouseX - lastX; - int dY = absMouseY - lastY; - offsetX += dX; - offsetY += dY; - lastX = absMouseX; - lastY = absMouseY; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java deleted file mode 100755 index 3379098b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; -import kr.syeyoung.dungeonsguide.gui.elements.MTooltipText; -import kr.syeyoung.dungeonsguide.utils.ArrayUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import java.awt.*; -import java.util.Arrays; -import java.util.UUID; - -public class RoomMatchDisplayPane extends MPanel { - - private int offsetX = 0; - private int offsetY = 0; - - private final DungeonRoom dungeonRoom; - - private final int[][] currentBlocks; - private int[][] targetBlocks; - public RoomMatchDisplayPane(DungeonRoom dungeonRoom, UUID uid, int rotation) { - this.dungeonRoom = dungeonRoom; - - currentBlocks = dungeonRoom.getRoomMatcher().createNew().getBlocks(); - targetBlocks = DungeonRoomInfoRegistry.getByUUID(uid).getBlocks(); - for (int i = 0; i < rotation; i++) - targetBlocks = ArrayUtils.rotateCounterClockwise(targetBlocks); - } - - MTooltip mTooltip; - int lastTooltipX = -1, lastTooltipZ = -1; - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - int height = Math.max(currentBlocks.length, targetBlocks.length); - int width = Math.max(currentBlocks[0].length, targetBlocks[0].length); - - // draw Axis; - Gui.drawRect(0,0,10,10,0x77777777); - clip(clip.x + 10, clip.y, clip.width - 10, 10); - Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); - for (int x = 0; x < width; x++) { - fr.drawString(x+"", x * 16 +10 + offsetX, 0, 0xFFFFFFFF); - } - clip(clip.x, clip.y +10, 10, clip.height-10); - Gui.drawRect(0,0,getBounds().width, getBounds().height, 0x77777777); - for (int z = 0; z < height; z++) { - fr.drawString(z+"", 2, z * 16 + 10 + offsetY, 0xFFFFFFFF); - } - - int hoverX = (relMousex0 - offsetX - 10) / 16; - int hoverY = (relMousey0 - offsetY - 10) / 16; - // draw Content - clip(clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10); - boolean tooltiped=false; - for (int z = 0; z < height; z++) { - for (int x = 0; x < width; x++) { - int data1; - try { data1 = currentBlocks[z][x]; } catch (Exception e) { - data1 = -2; - } - int data2; - try { data2 = targetBlocks[z][x]; } catch (Exception e) { - data2 = -2; - } - - if (z == hoverY && x == hoverX) { - Gui.drawRect(x *16 +10+offsetX, z *16 +10 + offsetY, x *16 +26 +offsetX, z *16 +26 + offsetY, 0xAA505050); - } - - if (data1 == data2) drawItemStack(new ItemStack(Item.getItemFromBlock(Block.getBlockById(data1)), 1), x * 16 +10 + offsetX, z *16 +10 + offsetY); - else if (data2 == -1 || data1 == -1) { - drawItemStack(new ItemStack(Item.getItemFromBlock(Block.getBlockById(data1 == -1 ? data2 : data1)), 1), x * 16 +10 + offsetX, z *16 +10 + offsetY); - fr.drawString("S", x *16 +10 + offsetX, z *16 +10 + offsetY,0xFFFFFF00); - } else { - fr.drawString("N", x *16 +10 + offsetX, z *16 +10 + offsetY,0xFFFF0000); - } - if (z == hoverY && x == hoverX) { - tooltiped = true; - if (lastTooltipX != x || lastTooltipZ != z){ - if (mTooltip != null) mTooltip.close(); - mTooltip = new MTooltipText(Arrays.asList("Expected "+data2 +" But found "+data1)); - mTooltip.open(this); - } - } - } - } - if (!tooltiped && mTooltip != null) { - mTooltip.close(); - mTooltip = null; - } - - } - private void drawItemStack(ItemStack stack, int x, int y) - { - Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, x, y); - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - private int lastX; - private int lastY; - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - lastX = absMouseX; - lastY = absMouseY; - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - int dX = absMouseX - lastX; - int dY = absMouseY - lastY; - offsetX += dX; - offsetY += dY; - lastX = absMouseX; - lastY = absMouseY; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoommatchingPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoommatchingPane.java deleted file mode 100755 index 00d7ae04..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoommatchingPane.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MTextField; - -import java.awt.*; -import java.util.UUID; - -public class RoommatchingPane extends MPanel { - private final DungeonRoom dungeonRoom; - - private RoomMatchDisplayPane displayPane; - - private final MTextField textField; - private final MButton calculate; - public RoommatchingPane(final DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - - { - textField = new MTextField(); - textField.setBounds(new Rectangle(0,0,getBounds().width - 100, 20)); - add(textField); - } - { - calculate = new MButton(); - calculate.setBounds(new Rectangle(getBounds().width - 100,0,100, 20)); - calculate.setText("match"); - calculate.setOnActionPerformed(new Runnable() { - @Override - public void run() { - try { - remove(displayPane); - - String text = textField.getText(); - String target = text.split(":")[0]; - String state = text.split(":")[1]; - - UUID uid = UUID.fromString(target); - int rotation = Integer.parseInt(state) % 4; - - - displayPane = new RoomMatchDisplayPane(dungeonRoom, uid, rotation); - displayPane.setBounds(new Rectangle(0,25,getBounds().width,getBounds().height-25)); - add(displayPane); - } catch (Throwable t) { - t.printStackTrace(); - } - } - }); - add(calculate); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - @Override - public void onBoundsUpdate() { - textField.setBounds(new Rectangle(0,0,getBounds().width - 100, 20)); - calculate.setBounds(new Rectangle(getBounds().width - 100,0,100, 20)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/SecretEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/SecretEditPane.java deleted file mode 100755 index 70b3e381..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/SecretEditPane.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.panes; - -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MParameter; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; -import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -public class SecretEditPane extends MPanel implements DynamicEditor { - private final DungeonRoom dungeonRoom; - - private MButton save; - private MButton create; - private final List parameters = new ArrayList(); - - private final List allowedClasses = new ArrayList(); - - public SecretEditPane(DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - buildElements(); - - for (String clazz : ValueEditRegistry.getClassesSupported()) { - if (clazz.contains("mechanics") || clazz.equals("null")) { - allowedClasses.add(clazz); - } - } - } - - public void createNewMechanic(String uid, DungeonMechanic data) { - MParameter parameter; - parameters.add(parameter = new MParameter(new Parameter(uid, data, data), SecretEditPane.this)); - parameter.setBounds(new Rectangle(0,0,getBounds().width, 20)); - parameter.setParent(SecretEditPane.this); - } - - public void buildElements() { - { - create = new MButton(); - create.setText("Create New Mechanic"); - create.setBackgroundColor(Color.cyan); - create.setBounds(new Rectangle(0,0,100,20)); - create.setOnActionPerformed(new Runnable() { - @Override - public void run() { - createNewMechanic(UUID.randomUUID().toString(), null); - } - }); - - save = new MButton(); - save.setText("Save"); - save.setBackgroundColor(Color.green); - save.setBounds(new Rectangle(0,0,100,20)); - save.setOnActionPerformed(new Runnable() { - @Override - public void run() { - DungeonRoomInfo dungeonRoomInfo = dungeonRoom.getDungeonRoomInfo(); - dungeonRoomInfo.getMechanics().clear(); - - for (MParameter parameter : parameters) { - Parameter real = parameter.getParameter(); - - ValueEditCreator vec = ValueEditRegistry.getValueEditMap(real.getNewData() == null ? "null" :real.getNewData().getClass().getName()); - - real.setPreviousData(vec.cloneObj(real.getNewData())); - dungeonRoomInfo.getMechanics().put(real.getName(), (DungeonMechanic) real.getNewData()); - } - } - }); - create.setParent(this); save.setParent(this); - } - { - for (Map.Entry en : dungeonRoom.getDungeonRoomInfo().getMechanics().entrySet()) { - ValueEditCreator vec = ValueEditRegistry.getValueEditMap(en.getValue() == null ? "null" :en.getValue().getClass().getName()); - - MParameter mParameter = new MParameter(new Parameter(en.getKey(), vec.cloneObj(en.getValue()), vec.cloneObj(en.getValue())), this); - mParameter.setBounds(new Rectangle(0,0,getBounds().width,20)); - parameters.add(mParameter); - mParameter.setParent(this); - } - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - - public void delete(MParameter parameter) { - parameters.remove(parameter); - } - - @Override - public List allowedClass() { - return allowedClasses; - } - - @Override - public List getChildComponents() { - ArrayList panels = new ArrayList(parameters); - panels.add(create); - panels.add(save); - return panels; - } - - private int offsetY = 0; - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - int heights = 0; - for (MPanel panel:getChildComponents()) { - panel.setPosition(new Point(0, -offsetY + heights)); - heights += panel.getBounds().height; - } - } - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (scrollAmount > 0) offsetY -= 20; - else if (scrollAmount < 0) offsetY += 20; - if (offsetY < 0) offsetY = 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java deleted file mode 100755 index b5c135c4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.roomedit.Parameter; - -public interface ValueEdit { - void setParameter(Parameter parameter); - - void renderWorld(float partialTicks); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java deleted file mode 100755 index e3e22bf7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MColor; -import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.MathHelper; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class ValueEditAColor extends MPanel implements ValueEdit { - private Parameter parameter; - private final MFloatSelectionButton h; - private final MFloatSelectionButton s; - private final MFloatSelectionButton v; - private final MFloatSelectionButton a; - - - @Override - public void renderWorld(float partialTicks) { - - } - public ValueEditAColor(final Parameter parameter2) { - this.parameter = parameter2; - { - MColor color = new MColor() { - @Override - public Color getColor() { - return (Color) parameter2.getPreviousData(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",color); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - MColor color = new MColor() { - @Override - public Color getColor() { - return (Color) parameter2.getNewData(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",color); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - - Color color = (Color) parameter2.getNewData(); - Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsv); - alpha = color.getAlpha() / 255.0f; - - { - h = new MFloatSelectionButton(hsv[0] * 360); - h.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[0] = h.getData() / 360; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("H", h); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - s = new MFloatSelectionButton(hsv[1] * 100); - s.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[1] = s.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("S", s); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - v = new MFloatSelectionButton(hsv[2] * 100); - v.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[2] = v.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("V", v); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - a = new MFloatSelectionButton(alpha * 100); - a.setOnUpdate(new Runnable() { - @Override - public void run() { - alpha = a.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("A", a); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - private final float[] hsv = new float[3]; - private float alpha = 0; - - public void update() { - if (hsv[2] > 1) hsv[2] = 1; - if (hsv[2] < 0) hsv[2] = 0; - if (hsv[1] > 1) hsv[1] = 1; - if (hsv[1] < 0) hsv[1] = 0; - parameter.setNewData(new AColor(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0xffffff | (MathHelper.clamp_int((int)(alpha * 255), 0, 255) << 24), true )); - h.setData((float) Math.floor(hsv[0] * 360)); - s.setData((float) Math.floor(hsv[1] * 100)); - v.setData((float) Math.floor(hsv[2] * 100)); - a.setData((float) Math.floor(alpha * 100)); - h.updateSelected(); - s.updateSelected(); - v.updateSelected(); - a.updateSelected(); - } - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - // draw CoolRect - int width = getBounds().width - 60; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - int shademodel = GL11.glGetInteger(GL11.GL_SHADE_MODEL); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - GlStateManager.enableBlend(); - GlStateManager.disableDepth(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - -// worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); - - int rgb = Color.HSBtoRGB(hsv[0], hsv[1], 1); - float r = (rgb >> 16 & 255) / 255.0f; - float g = (rgb >> 8 & 255) / 255.0f; - float b = (rgb & 255) / 255.0f; - GL11.glBegin(GL11.GL_TRIANGLES); - GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(25+width ,45, 0); - GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(10+width , 45, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(25+width , 45+width, 0); - - GlStateManager.color(0,0,0,alpha); GL11.glVertex3i(10+width , 45, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(10+width , 45 + width, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(25+width , 45+width, 0); - GL11.glEnd(); - rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); - r = (rgb >> 16 & 255) / 255.0f; - g = (rgb >> 8 & 255) / 255.0f; - b = (rgb & 255) / 255.0f; - GL11.glBegin(GL11.GL_TRIANGLES); - GlStateManager.color(r,g,b,0);GL11.glVertex3i(50+width ,45, 0); - GlStateManager.color(r,g,b,0);GL11.glVertex3i(35+width , 45, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(50+width , 45+width, 0); - -// GlStateManager.color(r,g,b,0); GL11.glVertex3i(35+width , 45, 0); -// GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width , 45 + width, 0); -// GlStateManager.color(r,g,b,1);GL11.glVertex3i(50+width , 45+width, 0); - GL11.glEnd(); - - - float radius = width/2f; - float cx = 5 + radius; - float cy = 45 + radius; - - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GlStateManager.color(1,1,1,alpha); - GL11.glVertex3f(cx,cy,0); - for (int i = 0; i <= 360; i++) { - float rad = 3.141592653f * i / 180; - int rgb2 = Color.HSBtoRGB(i / 360f, 1, hsv[2]); - float r2 = (rgb2 >> 16 & 255) / 255.0f; - float g2 = (rgb2 >> 8 & 255) / 255.0f; - float b2 = (rgb2 & 255) / 255.0f; - GlStateManager.color(r2,g2,b2, alpha); - GL11.glVertex3f(MathHelper.sin(rad) * radius + cx, MathHelper.cos(rad) * radius + cy, 0); - } - GL11.glEnd(); - GlStateManager.shadeModel(shademodel); - - GlStateManager.color(1,1,1,1); - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); - float rad2 = 2 * 3.141592653f * hsv[0] ; - float x = 5 + radius + (MathHelper.sin(rad2)) * hsv[1] * radius; - float y = 45 + radius + (MathHelper.cos(rad2))* hsv[1] * radius; - for (int i = 0; i < 100; i++) { - float rad = 2 * 3.141592653f * (i / 100f); - worldrenderer.pos(MathHelper.sin(rad) * 2 + x, MathHelper.cos(rad) * 2 + y, 0).endVertex(); - } - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(8+width, 45 + (hsv[2]) * width, 0.5).endVertex(); - worldrenderer.pos(27+width, 45 + (hsv[2]) * width, 0.5).endVertex(); - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(33+width, 45 + (alpha) * width, 0.5).endVertex(); - worldrenderer.pos(52+width, 45 + (alpha) * width, 0.5).endVertex(); - tessellator.draw(); - - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.color(1,1,1,1); - GlStateManager.color(1,1,1,1); - } - private int selected = 0; - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - int width = getBounds().width - 60; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 45 + radius; - selected = 0; - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (dx * dx + dy * dy <= radius * radius) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.sqrt_float(dx * dx + dy * dy) / radius; - selected = 1; - } - } - { - if (10+width <= relMouseX && relMouseX <= 25 + width && - 45 <= relMouseY && relMouseY <= 45 + width) { - hsv[2] = (relMouseY - 45) / (float)width; - selected = 2; - } - } - { - if (35+width <= relMouseX && relMouseX <= 50 + width && - 45 <= relMouseY && relMouseY <= 45 + width) { - alpha = (relMouseY - 45) / (float)width; - selected = 3; - } - } - update(); - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - int width = getBounds().width - 60; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 45 + radius; - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (selected == 1) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.clamp_float(MathHelper.sqrt_float(dx * dx + dy * dy) / radius, 0, 1); - } - } - { - if (selected == 2) { - hsv[2] = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); - } - if (selected == 3) { - alpha = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); - } - } - update(); - } - - @Override - public void onBoundsUpdate() { - int cnt = 0; - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); cnt++; - if (cnt > 2) { - panel.setPosition(new Point(0, getBounds().width + (cnt - 3) * 20)); - } - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditAColor createValueEdit(Parameter parameter) { - return new ValueEditAColor(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new AColor(255,0,0,255); - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java deleted file mode 100755 index dfd854bf..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; - -import java.awt.*; -import java.util.Arrays; - -public class ValueEditBoolean extends MPanel implements ValueEdit { - private Parameter parameter; - - - public ValueEditBoolean(Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - boolean newData = (Boolean) parameter.getNewData(); - final MStringSelectionButton textField = new MStringSelectionButton(Arrays.asList("true", "false"), Boolean.toString(newData)); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - parameter.setNewData(Boolean.valueOf(textField.getSelected())); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditBoolean createValueEdit(Parameter parameter) { - return new ValueEditBoolean(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return true; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java deleted file mode 100755 index 3e59154e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.MathHelper; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class ValueEditColor extends MPanel implements ValueEdit { - private Parameter parameter; - private final MFloatSelectionButton h; - private final MFloatSelectionButton s; - private final MFloatSelectionButton v; - - - @Override - public void renderWorld(float partialTicks) { - - } - public ValueEditColor(final Parameter parameter2) { - this.parameter = parameter2; - { - MColor color = new MColor() { - @Override - public Color getColor() { - return (Color) parameter2.getPreviousData(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",color); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - MColor color = new MColor() { - @Override - public Color getColor() { - return (Color) parameter2.getNewData(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",color); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - - Color color = (Color) parameter2.getNewData(); - Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsv); - - { - h = new MFloatSelectionButton(hsv[0] * 360); - h.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[0] = h.getData() / 360; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("H", h); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - s = new MFloatSelectionButton(hsv[1] * 100); - s.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[1] = s.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("S", s); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - v = new MFloatSelectionButton(hsv[2] * 100); - v.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[2] = v.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("V", v); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - private final float[] hsv = new float[3]; - - public void update() { - if (hsv[2] > 1) hsv[2] = 1; - if (hsv[2] < 0) hsv[2] = 0; - if (hsv[1] > 1) hsv[1] = 1; - if (hsv[1] < 0) hsv[1] = 0; - parameter.setNewData(new Color(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]))); - h.setData((float) Math.floor(hsv[0] * 360)); - s.setData((float) Math.floor(hsv[1] * 100)); - v.setData((float) Math.floor(hsv[2] * 100)); - h.updateSelected(); - s.updateSelected(); - v.updateSelected(); - } - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - // draw CoolRect - int width = getBounds().width - 30; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - int shademodel = GL11.glGetInteger(GL11.GL_SHADE_MODEL); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); -// worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); - - int rgb = Color.HSBtoRGB(hsv[0], hsv[1], 1); - float r = (rgb >> 16 & 255) / 255.0f; - float g = (rgb >> 8 & 255) / 255.0f; - float b = (rgb & 255) / 255.0f; - GL11.glBegin(GL11.GL_TRIANGLES); - GlStateManager.color(0,0,0,1);GL11.glVertex3i(25+width ,45, 0); - GlStateManager.color(0,0,0,1);GL11.glVertex3i(10+width , 45, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 45+width, 0); - - GlStateManager.color(0,0,0,1); GL11.glVertex3i(10+width , 45, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(10+width , 45 + width, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 45+width, 0); - GL11.glEnd(); - - float radius = width/2f; - float cx = 5 + radius; - float cy = 45 + radius; - - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GlStateManager.color(1,1,1,1); - GL11.glVertex3f(cx,cy,0); - for (int i = 0; i <= 360; i++) { - float rad = 3.141592653f * i / 180; - int rgb2 = Color.HSBtoRGB(i / 360f, 1, hsv[2]); - float r2 = (rgb2 >> 16 & 255) / 255.0f; - float g2 = (rgb2 >> 8 & 255) / 255.0f; - float b2 = (rgb2 & 255) / 255.0f; - GlStateManager.color(r2,g2,b2, 1); - GL11.glVertex3f(MathHelper.sin(rad) * radius + cx, MathHelper.cos(rad) * radius + cy, 0); - } - GL11.glEnd(); - GlStateManager.shadeModel(shademodel); - - GlStateManager.color(1,1,1,1); - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); - float rad2 = 2 * 3.141592653f * hsv[0] ; - float x = 5 + radius + (MathHelper.sin(rad2)) * hsv[1] * radius; - float y = 45 + radius + (MathHelper.cos(rad2))* hsv[1] * radius; - for (int i = 0; i < 100; i++) { - float rad = 2 * 3.141592653f * (i / 100f); - worldrenderer.pos(MathHelper.sin(rad) * 2 + x, MathHelper.cos(rad) * 2 + y, 0).endVertex(); - } - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(8+width, 45 + (hsv[2]) * width, 0.5).endVertex(); - worldrenderer.pos(27+width, 45 + (hsv[2]) * width, 0.5).endVertex(); - tessellator.draw(); - - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.color(1,1,1,1); - GlStateManager.color(1,1,1,1); - } - private int selected = 0; - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - int width = getBounds().width - 30; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 45 + radius; - selected = 0; - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (dx * dx + dy * dy <= radius * radius) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.sqrt_float(dx * dx + dy * dy) / radius; - selected = 1; - } - } - { - if (10+width <= relMouseX && relMouseX <= 25 + width && - 45 <= relMouseY && relMouseY <= 45 + width) { - hsv[2] = (relMouseY - 45) / (float)width; - selected = 2; - } - } - update(); - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - int width = getBounds().width - 30; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 45 + radius; - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (selected == 1) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.clamp_float(MathHelper.sqrt_float(dx * dx + dy * dy) / radius, 0, 1); - } - } - { - if (selected == 2) { - hsv[2] = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); - } - } - update(); - } - - @Override - public void onBoundsUpdate() { - int cnt = 0; - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); cnt++; - if (cnt > 2) { - panel.setPosition(new Point(0, getBounds().width + (cnt - 2) * 20)); - } - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditColor createValueEdit(Parameter parameter) { - return new ValueEditColor(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return Color.red; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java deleted file mode 100755 index dda484d9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.roomedit.Parameter; - -public interface ValueEditCreator { - T createValueEdit(Parameter parameter); - - Object createDefaultValue(Parameter parameter); - - Object cloneObj(Object object); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java deleted file mode 100755 index 4092cf28..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; - -import java.awt.*; - -public class ValueEditFloat extends MPanel implements ValueEdit { - private Parameter parameter; - - - @Override - public void renderWorld(float partialTicks) { - - } - public ValueEditFloat(final Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - float newData = (Float) parameter.getNewData(); - final MFloatSelectionButton textField = new MFloatSelectionButton(newData); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - parameter.setNewData(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditFloat createValueEdit(Parameter parameter) { - return new ValueEditFloat(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return 0.0f; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java deleted file mode 100755 index 8a5f36c9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MIntegerSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; - -import java.awt.*; - -public class ValueEditInteger extends MPanel implements ValueEdit { - private Parameter parameter; - - - @Override - public void renderWorld(float partialTicks) { - - } - public ValueEditInteger(final Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - int newData = (Integer) parameter.getNewData(); - final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - parameter.setNewData(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditInteger createValueEdit(Parameter parameter) { - return new ValueEditInteger(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return 0; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java deleted file mode 100755 index 4c9e32a7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.roomedit.Parameter; - -public class ValueEditNull implements ValueEditCreator { - @Override - public ValueEdit createValueEdit(Parameter parameter) { - return null; - } - - @Override - public Cloneable createDefaultValue(Parameter parameter) { - return null; - } - - @Override - public Object cloneObj(Object object) { - return null; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java deleted file mode 100755 index 1cd4deba..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; -import java.awt.*; - -public class ValueEditOffsetPoint extends MPanel implements ValueEdit { - private Parameter parameter; - - @Override - public void renderWorld(float partialTicks) { - RenderUtils.highlightBlock(((OffsetPoint)parameter.getPreviousData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(255,0,0,150), partialTicks); - RenderUtils.highlightBlock(((OffsetPoint)parameter.getNewData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,0,150), partialTicks); - } - - public ValueEditOffsetPoint(final Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - OffsetPoint newData = (OffsetPoint) parameter.getNewData(); - { - final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getX()); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - ((OffsetPoint) parameter.getNewData()).setX(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("x",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getY()); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - ((OffsetPoint) parameter.getNewData()).setY(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("y",textField); - mLabelAndElement.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(mLabelAndElement); - } - { - final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getZ()); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - ((OffsetPoint) parameter.getNewData()).setZ(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("z",textField); - mLabelAndElement.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(mLabelAndElement); - } - { - final MLabel setToHEre = new MLabel() { - @Override - public String getText() { - OffsetPoint offsetPoint = (OffsetPoint) parameter.getNewData(); - return Block.getIdFromBlock(offsetPoint.getBlock(EditingContext.getEditingContext().getRoom())) + - ":" + offsetPoint.getData(EditingContext.getEditingContext().getRoom()); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("newPt",setToHEre); - mLabelAndElement.setBounds(new Rectangle(0,80,getBounds().width,20)); - add(mLabelAndElement); - } - { - final MButton setToHEre2 = new MButton(); - setToHEre2.setText("Set to here"); - setToHEre2.setBackgroundColor(Color.green); - setToHEre2.setOnActionPerformed(new Runnable() { - @Override - public void run() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ); - ((OffsetPoint)parameter2.getNewData()).setPosInWorld(EditingContext.getEditingContext().getRoom(),pos ); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("set",setToHEre2); - mLabelAndElement.setBounds(new Rectangle(0,100,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditOffsetPoint createValueEdit(Parameter parameter) { - return new ValueEditOffsetPoint(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((OffsetPoint)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java deleted file mode 100755 index 0cdaab0d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MValue; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import net.minecraft.client.Minecraft; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class ValueEditOffsetPointSet extends MPanel implements ValueEdit { - private Parameter parameter; - - // scroll pane - // just create - // add set - - private final MPanel scroll; - @Getter - private final List MParameters = new ArrayList(); - - private final MButton add; - private final MButton addSet; - - public void delete(OffsetPoint offsetPoint) { - ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().remove(offsetPoint); - Iterator iterator = MParameters.iterator(); - while (iterator.hasNext()) { - MValue panel = (MValue) iterator.next(); - if (panel.getData() == offsetPoint) { - iterator.remove(); - break; - } - } - - } - - public ValueEditOffsetPointSet(final Parameter parameter2) { - this.parameter = parameter2; - { - scroll = new MPanel() { - private int offsetY = 0; - - @Override - public List getChildComponents() { - return MParameters; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - int heights = 0; - for (MPanel panel:getChildComponents()) { - panel.setPosition(new Point(0, -offsetY + heights)); - heights += panel.getBounds().height; - } - } - - @Override - public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { - if (!getBounds().contains(relMouseX0, relMouseY0)) { - return false; - } - - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - boolean noClip = true; - boolean focusedOverall = false; - for (MPanel childComponent : getChildComponents()) { - if (childComponent.mouseClicked0(absMouseX, absMouseY, relMousex, relMousey, mouseButton)) { - noClip = false; - focusedOverall = true; - } - } - - if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { - isFocused = true; - focusedOverall = true; - } else { - isFocused = false; - } - - mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); - return focusedOverall; - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (new Rectangle(new Point(0,0), getSize()).contains(relMouseX0, relMouseY0)) { - if (scrollAmount >0) offsetY += 20; - else if (scrollAmount < 0) offsetY -= 20; - if (offsetY <0) offsetY = 0; - } - } - }; - scroll.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height-20)); - add(scroll); - } - - { - add = new MButton() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20)); - } - }; - add.setText("Add"); - add.setBackgroundColor(Color.green); - add.setOnActionPerformed(new Runnable() { - @Override - public void run() { - OffsetPoint offsetPoint = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); - MValue mValue; - MParameters.add(mValue = new MValue(offsetPoint, buildAddonsFor(offsetPoint))); - ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().add(offsetPoint); - mValue.setSize(new Dimension(getBounds().width, 20)); - } - }); - - addSet = new MButton(){ - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20)); - } - }; - addSet.setText("Add Set"); - addSet.setBackgroundColor(Color.cyan); - addSet.setOnActionPerformed(new Runnable() { - @Override - public void run() { - EditingContext.getEditingContext().openGui(new GuiDungeonAddSet(ValueEditOffsetPointSet.this)); - } - }); - add(add); - add(addSet); - } - for (OffsetPoint offsetPoint : ((OffsetPointSet)parameter.getNewData()).getOffsetPointList()) { - MParameters.add(new MValue(offsetPoint, buildAddonsFor(offsetPoint))); - } - } - - public List buildAddonsFor(final OffsetPoint offsetPoint) { - ArrayList panels = new ArrayList(); - MButton mButton = new MButton(); - mButton.setText("Delete"); - mButton.setForeground(Color.white); - mButton.setBackgroundColor(Color.red); - mButton.setOnActionPerformed(new Runnable() { - @Override - public void run() { - delete(offsetPoint); - } - }); - panels.add(mButton); - return panels; - } - - @Override - public void onBoundsUpdate() { - scroll.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height-20)); - add.setBounds(new Rectangle(0,getBounds().height-20,getBounds().width / 2, 20)); - addSet.setBounds(new Rectangle(getBounds().width / 2,getBounds().height-20,getBounds().width / 2, 20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - for (OffsetPoint offsetPoint :((OffsetPointSet)parameter.getNewData()).getOffsetPointList()) { - RenderUtils.highlightBlock(offsetPoint.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,255,50), partialTicks); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public void addAll(List blockPoses) { - ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().addAll(blockPoses); - for (OffsetPoint blockPose : blockPoses) { - MParameters.add(new MValue(blockPose, buildAddonsFor(blockPose))); - } - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditOffsetPointSet createValueEdit(Parameter parameter) { - return new ValueEditOffsetPointSet(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new OffsetPointSet(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((OffsetPointSet)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java deleted file mode 100755 index 1df64a6c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.*; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ValueEditRegistry { - private static final Map valueEditMap = new HashMap(); - - public static ValueEditCreator getValueEditMap(String className) { - return valueEditMap.get(className); - } - - public static List getClassesSupported() { - return new ArrayList(valueEditMap.keySet()); - } - - static { - valueEditMap.put("null", new ValueEditNull()); - valueEditMap.put(String.class.getName(), new ValueEditString.Generator()); - valueEditMap.put(Boolean.class.getName(), new ValueEditBoolean.Generator()); - valueEditMap.put(Integer.class.getName(), new ValueEditInteger.Generator()); - valueEditMap.put(Float.class.getName(), new ValueEditFloat.Generator()); - valueEditMap.put(OffsetPoint.class.getName(), new ValueEditOffsetPoint.Generator()); - valueEditMap.put(OffsetPointSet.class.getName(), new ValueEditOffsetPointSet.Generator()); - valueEditMap.put(Color.class.getName(), new ValueEditColor.Generator()); - valueEditMap.put(AColor.class.getName(), new ValueEditAColor.Generator()); - - - valueEditMap.put(DungeonSecret.class.getName(), new ValueEditSecret.Generator()); - valueEditMap.put(DungeonFairySoul.class.getName(), new ValueEditFairySoul.Generator()); - valueEditMap.put(DungeonNPC.class.getName(), new ValueEditNPC.Generator()); - valueEditMap.put(DungeonTomb.class.getName(), new ValueEditTomb.Generator()); - valueEditMap.put(DungeonBreakableWall.class.getName(), new ValueEditBreakableWall.Generator()); - valueEditMap.put(DungeonJournal.class.getName(), new ValueEditJournal.Generator()); - valueEditMap.put(DungeonDummy.class.getName(), new ValueEditDummy.Generator()); - - valueEditMap.put(DungeonPressurePlate.class.getName(), new ValueEditPressurePlate.Generator()); - valueEditMap.put(DungeonOnewayLever.class.getName(), new ValueEditOnewayLever.Generator()); - valueEditMap.put(DungeonLever.class.getName(), new ValueEditLever.Generator()); - valueEditMap.put(DungeonDoor.class.getName(), new ValueEditDoor.Generator()); - valueEditMap.put(DungeonOnewayDoor.class.getName(), new ValueEditOnewayDoor.Generator()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java deleted file mode 100755 index 157e7b42..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MTextField; - -import java.awt.*; - -public class ValueEditString extends MPanel implements ValueEdit { - private Parameter parameter; - - @Override - public void renderWorld(float partialTicks) { - - } - - public ValueEditString(Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - String newData = (String) parameter.getNewData(); - MTextField textField = new MTextField() { - @Override - public void edit(String str) { - parameter.setNewData(str); - } - }; - textField.setText(newData); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator { - - @Override - public ValueEditString createValueEdit(Parameter parameter) { - return new ValueEditString(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return "default"; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java deleted file mode 100755 index 452c0003..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionComplete; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; -import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; -import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonRoomDoor; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.events.BlockUpdateEvent; -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.pathfinding.NodeProcessorDungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; -import kr.syeyoung.dungeonsguide.utils.VectorUtils; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.util.*; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.*; - -public class GeneralRoomProcessor implements RoomProcessor { - - @Getter - @Setter - private DungeonRoom dungeonRoom; - public GeneralRoomProcessor(DungeonRoom dungeonRoom) { - this.dungeonRoom = dungeonRoom; - } - private boolean ticked = false; - - - @Override - public void tick() { - if (!ticked && FeatureRegistry.SECRET_AUTO_START.isEnabled()) - searchForNextTarget(); - if (!ticked && FeatureRegistry.SECRET_PATHFIND_ALL.isEnabled()) { - for (Map.Entry value : getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonSecret && ((DungeonSecret) value.getValue()).getSecretStatus(dungeonRoom) != DungeonSecret.SecretStatus.FOUND) { - DungeonSecret dungeonSecret = (DungeonSecret) value.getValue(); - if (FeatureRegistry.SECRET_PATHFIND_ALL.isBat() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.BAT) - pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_BAT.getRouteProperties()); - if (FeatureRegistry.SECRET_PATHFIND_ALL.isChest() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.CHEST) - pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_CHEST.getRouteProperties()); - if (FeatureRegistry.SECRET_PATHFIND_ALL.isEssence() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.ESSENCE) - pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_ESSENCE.getRouteProperties()); - if (FeatureRegistry.SECRET_PATHFIND_ALL.isItemdrop() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.ITEM_DROP) - pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_ITEM_DROP.getRouteProperties()); - } - } - } - if (!ticked && FeatureRegistry.SECRET_BLOOD_RUSH.isEnabled()) { - for (Map.Entry value : getDungeonRoom().getMechanics().entrySet()) { - if (value.getValue() instanceof DungeonRoomDoor) { - DungeonRoomDoor dungeonDoor = (DungeonRoomDoor) value.getValue(); - if (dungeonDoor.getDoorfinder().getType().isHeadToBlood()) { - pathfind(value.getKey(), "navigate", FeatureRegistry.SECRET_BLOOD_RUSH_LINE_PROPERTIES.getRouteProperties()); - } - } - } - } - ticked = true; - - Set toRemove = new HashSet<>(); - path.entrySet().forEach(a -> { - a.getValue().onTick(); - if (a.getValue().getCurrentAction() instanceof ActionComplete) - toRemove.add(a.getKey()); - }); - toRemove.forEach(path::remove); - - - for (DungeonMechanic value : dungeonRoom.getMechanics().values()) { - if (value instanceof DungeonSecret) ((DungeonSecret) value).tick(dungeonRoom); - } - - if (toRemove.contains("AUTO-BROWSE") && FeatureRegistry.SECRET_AUTO_BROWSE_NEXT.isEnabled()) { - searchForNextTarget(); - } - } - private final Set visited = new HashSet(); - - public void searchForNextTarget() { - if (getDungeonRoom().getCurrentState() == DungeonRoom.RoomState.FINISHED) { - cancelAll(); - return; - } - - BlockPos pos = Minecraft.getMinecraft().thePlayer.getPosition(); - - double lowestCost = 99999999999999.0; - Map.Entry lowestWeightMechanic = null; - for (Map.Entry mech: dungeonRoom.getMechanics().entrySet()) { - if (!(mech.getValue() instanceof DungeonSecret)) continue; - if (visited.contains(mech.getKey())) continue; - if (((DungeonSecret) mech.getValue()).getSecretStatus(getDungeonRoom()) != DungeonSecret.SecretStatus.FOUND) { - double cost = 0; - if (((DungeonSecret) mech.getValue()).getSecretType() == DungeonSecret.SecretType.BAT && - ((DungeonSecret) mech.getValue()).getPreRequisite().size() == 0) { - cost += -100000000; - } - if (mech.getValue().getRepresentingPoint(getDungeonRoom()) == null) continue; - BlockPos blockpos = mech.getValue().getRepresentingPoint(getDungeonRoom()).getBlockPos(getDungeonRoom()); - - cost += blockpos.distanceSq(pos); - cost += ((DungeonSecret) mech.getValue()).getPreRequisite().size() * 100; - - if (cost < lowestCost) { - lowestCost = cost; - lowestWeightMechanic = mech; - } - } - } - if (lowestWeightMechanic != null) { - visited.add(lowestWeightMechanic.getKey()); - pathfind("AUTO-BROWSE", lowestWeightMechanic.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_AUTOPATHFIND.getRouteProperties()); - } else { - visited.clear(); - } - } - - @Override - public void drawScreen(float partialTicks) { - path.values().forEach(a -> { - a.onRenderScreen(partialTicks); - }); - - if (FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && FeatureRegistry.DEBUG.isEnabled()) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - if (Minecraft.getMinecraft().objectMouseOver == null) return; - Entity en = Minecraft.getMinecraft().objectMouseOver.entityHit; - if (en == null) return; - - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - if (DungeonActionManager.getSpawnLocation().containsKey(en.getEntityId())) { - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Spawned at " + DungeonActionManager.getSpawnLocation().get(en.getEntityId()), sr.getScaledWidth() / 2, sr.getScaledHeight() / 2, 0xFFFFFFFF); - } - } - } - - @Override - public void drawWorld(float partialTicks) { - if (FeatureRegistry.DEBUG.isEnabled() && (EditingContext.getEditingContext() != null && EditingContext.getEditingContext().getCurrent() instanceof GuiDungeonRoomEdit)) { - for (Map.Entry value : dungeonRoom.getMechanics().entrySet()) { - if (value.getValue() == null) continue; - value.getValue().highlight(new Color(0,255,255,50), value.getKey(), dungeonRoom, partialTicks); - } - } - - - ActionRoute finalSmallest = getBestFit(partialTicks); - path.values().forEach(a -> { - a.onRenderWorld(partialTicks, finalSmallest == a); - }); - } - - private ActionRoute getBestFit(float partialTicks) { - - ActionRoute smallest = null; - double smallestTan = 0.002; - for (ActionRoute value : path.values()) { - BlockPos target; - if (value.getCurrentAction() instanceof ActionMove) { - target = ((ActionMove) value.getCurrentAction()).getTarget().getBlockPos(dungeonRoom); - } else if (value.getCurrentAction() instanceof ActionMoveNearestAir) { - target = ((ActionMoveNearestAir) value.getCurrentAction()).getTarget().getBlockPos(dungeonRoom); - } else if (value.getCurrent() >= 1 && value.getActions().get(value.getCurrent()-1) instanceof ActionMove) { - target = ((ActionMove)value.getActions().get(value.getCurrent()-1)).getTarget().getBlockPos(dungeonRoom); - } else if (value.getCurrent() >= 1 && value.getActions().get(value.getCurrent()-1) instanceof ActionMoveNearestAir) { - target = ((ActionMoveNearestAir)value.getActions().get(value.getCurrent()-1)).getTarget().getBlockPos(dungeonRoom); - } else continue; - - if (value.getActionRouteProperties().getLineRefreshRate() != -1 && value.getActionRouteProperties().isPathfind() && !FeatureRegistry.SECRET_FREEZE_LINES.isEnabled()) continue; - - Entity e = Minecraft.getMinecraft().getRenderViewEntity(); - - double vectorV = VectorUtils.distSquared(e.getLook(partialTicks), e.getPositionEyes(partialTicks), new Vec3(target).addVector(0.5,0.5,0.5)); - - if (vectorV < smallestTan) { - smallest = value; - smallestTan = vectorV; - } - } - return smallest; - } - - @Override - public void chatReceived(IChatComponent chat) { - if (lastChest != null && chat.getFormattedText().equals("ยงrยงcThis chest has already been searched!ยงr")) { - getDungeonRoom().getRoomContext().put("c-"+lastChest.toString(), 2); - lastChest = null; - } - } - - private int stack = 0; - private long secrets2 = 0; - @Override - public void actionbarReceived(IChatComponent chat) { - if (!DungeonsGuide.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; - if (dungeonRoom.getTotalSecrets() == -1) { - DungeonsGuide.sendDebugChat(new ChatComponentText(chat.getFormattedText().replace('ยง', '&') + " - received")); - } - if (!chat.getFormattedText().contains("/")) return; - BlockPos pos = Minecraft.getMinecraft().thePlayer.getPosition(); - DungeonContext context = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext(); - Point pt1 = context.getMapProcessor().worldPointToRoomPoint(pos.add(2, 0, 2)); - Point pt2 = context.getMapProcessor().worldPointToRoomPoint(pos.add(-2, 0, -2)); - if (!pt1.equals(pt2)) { - stack = 0; - secrets2 = -1; - return; - } - BlockPos pos2 = dungeonRoom.getMin().add(5, 0, 5); - - String text = chat.getFormattedText(); - int secretsIndex = text.indexOf("Secrets"); - int secrets = 0; - if (secretsIndex != -1) { - int theindex = 0; - for (int i = secretsIndex; i >= 0; i--) { - if (text.startsWith("ยง7", i)) { - theindex = i; - } - } - String it = text.substring(theindex + 2, secretsIndex - 1); - - secrets = Integer.parseInt(it.split("/")[1]); - } - - if (secrets2 == secrets) stack++; - else { - stack = 0; - secrets2 = secrets; - } - - if (stack == 4 && dungeonRoom.getTotalSecrets() != secrets) { - dungeonRoom.setTotalSecrets(secrets); - if (FeatureRegistry.DUNGEON_INTERMODCOMM.isEnabled()) - Minecraft.getMinecraft().thePlayer.sendChatMessage("/pchat $DG-Comm " + pos2.getX() + "/" + pos2.getZ() + " " + secrets); - } - } - - @Override - public boolean readGlobalChat() { - return false; - } - - @Getter - private Map path = new HashMap<>(); - - public ActionRoute getPath(String id){ - return path.get(id); - } - - public String pathfind(String mechanic, String state, ActionRoute.ActionRouteProperties actionRouteProperties) { - String str; - pathfind(str = UUID.randomUUID().toString(), mechanic, state, actionRouteProperties); - return str; - } - public void pathfind(String id, String mechanic, String state, ActionRoute.ActionRouteProperties actionRouteProperties) { - path.put(id, new ActionRoute(getDungeonRoom(), mechanic, state, actionRouteProperties)); - } - public void cancelAll() { - path.clear(); - } - public void cancel(String id) { - path.remove(id); - } - - @Override - public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { - - } - - @Override - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - if (updateEvent.entityLiving instanceof EntityArmorStand && - updateEvent.entityLiving.getName() != null && - updateEvent.entityLiving.getName().contains("Mimic") && - !dungeonRoom.getContext().isGotMimic()) { - dungeonRoom.getContext().setGotMimic(true); -// Minecraft.getMinecraft().thePlayer.sendChatMessage("/pc $DG-Mimic"); - } - } - - @Override - public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { - if (FeatureRegistry.SECRET_NEXT_KEY.isEnabled() && FeatureRegistry.SECRET_NEXT_KEY.getParameter("key").getValue() == keyInputEvent.getKey()) { - searchForNextTarget(); - } else if (FeatureRegistry.SECRET_CREATE_REFRESH_LINE.getKeybind() == keyInputEvent.getKey() && FeatureRegistry.SECRET_CREATE_REFRESH_LINE.isEnabled()) { - ActionRoute actionRoute = getBestFit(0); - // actually do force refresh because of force freeze pathfind - if (actionRoute.getCurrentAction() instanceof ActionMove) { - ActionMove ac = (ActionMove) actionRoute.getCurrentAction(); - ac.forceRefresh(getDungeonRoom()); - } else if (actionRoute.getCurrentAction() instanceof ActionMoveNearestAir) { - ActionMoveNearestAir ac = (ActionMoveNearestAir) actionRoute.getCurrentAction(); - ac.forceRefresh(getDungeonRoom()); - } else if (actionRoute.getCurrent() >= 1 && actionRoute.getActions().get(actionRoute.getCurrent()-1) instanceof ActionMove) { - ((ActionMove)actionRoute.getActions().get(actionRoute.getCurrent()-1)).forceRefresh(dungeonRoom); - } else if (actionRoute.getCurrent() >= 1 && actionRoute.getActions().get(actionRoute.getCurrent()-1) instanceof ActionMoveNearestAir) { - ((ActionMoveNearestAir)actionRoute.getActions().get(actionRoute.getCurrent()-1)).forceRefresh(dungeonRoom); - } - - if (FeatureRegistry.SECRET_CREATE_REFRESH_LINE.isPathfind() && !actionRoute.getActionRouteProperties().isPathfind()) { - actionRoute.getActionRouteProperties().setPathfind(true); - actionRoute.getActionRouteProperties().setLineRefreshRate(FeatureRegistry.SECRET_CREATE_REFRESH_LINE.getRefreshRate()); - } - } - } - - @Override - public void onInteract(PlayerInteractEntityEvent event) { - path.values().forEach(a -> { - a.onLivingInteract(event); - }); - } - - private boolean last = false; - private BlockPos lastChest; - @Override - public void onInteractBlock(PlayerInteractEvent event) { - path.values().forEach(a -> { - a.onPlayerInteract(event); - }); - - if (event.pos != null) { - IBlockState iBlockState = event.world.getBlockState(event.pos); - if (iBlockState.getBlock() == Blocks.chest || iBlockState.getBlock() == Blocks.trapped_chest) - lastChest = event.pos; - } - - if (event.entityPlayer.getHeldItem() != null && - event.entityPlayer.getHeldItem().getItem() == Items.stick && - FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && - FeatureRegistry.DEBUG.isEnabled()) { - EditingContext ec = EditingContext.getEditingContext(); - if (ec == null) return; - if (!(ec.getCurrent() instanceof GuiDungeonAddSet)) return; - GuiDungeonAddSet gdas = (GuiDungeonAddSet) ec.getCurrent(); - if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - if (last) - gdas.getEnd().setPosInWorld(getDungeonRoom(), event.pos); - else - gdas.getStart().setPosInWorld(getDungeonRoom(), event.pos); - - last = !last; - } - } - } - - @Override - public void onEntityDeath(LivingDeathEvent deathEvent) { - path.values().forEach(a -> { - a.onLivingDeath(deathEvent); - }); - if (EditingContext.getEditingContext() != null && EditingContext.getEditingContext().getRoom() == getDungeonRoom()) { - if (deathEvent.entity instanceof EntityBat) { - for (GuiScreen screen : EditingContext.getEditingContext().getGuiStack()) { - if (screen instanceof GuiDungeonRoomEdit) { - DungeonSecret secret = new DungeonSecret(); - secret.setSecretType(DungeonSecret.SecretType.BAT); - secret.setSecretPoint(new OffsetPoint(dungeonRoom, - DungeonActionManager.getSpawnLocation().get(deathEvent.entity.getEntityId()) - )); - ((GuiDungeonRoomEdit) screen).getSep().createNewMechanic("BAT-"+ UUID.randomUUID(), - secret); - return; - } - } - if (EditingContext.getEditingContext().getCurrent() instanceof GuiDungeonRoomEdit) { - DungeonSecret secret = new DungeonSecret(); - secret.setSecretType(DungeonSecret.SecretType.BAT); - secret.setSecretPoint(new OffsetPoint(dungeonRoom, - DungeonActionManager.getSpawnLocation().get(deathEvent.entity.getEntityId()) - )); - ((GuiDungeonRoomEdit) EditingContext.getEditingContext().getCurrent()).getSep().createNewMechanic("BAT-"+ UUID.randomUUID(), - secret); - } - } - } - } - @Override - public void onBlockUpdate(BlockUpdateEvent blockUpdateEvent) { - for (Tuple updatedBlock : blockUpdateEvent.getUpdatedBlocks()) { - if (updatedBlock.getSecond().equals(NodeProcessorDungeonRoom.preBuilt)) continue; - dungeonRoom.resetBlock(updatedBlock.getFirst()); - } - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public GeneralRoomProcessor createNew(DungeonRoom dungeonRoom) { - GeneralRoomProcessor defaultRoomProcessor = new GeneralRoomProcessor(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java deleted file mode 100755 index f4dee8f4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.boxpuzzle.RoomProcessorBoxSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.icefill.RoomProcessorIcePath2; -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.RoomProcessorWaterPuzzle; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -public class ProcessorFactory { - private static final Map map = new HashMap(); - - public static RoomProcessorGenerator getRoomProcessorGenerator(String processorId) { - return map.get(processorId); - } - - public static void registerRoomProcessor(String processorId, RoomProcessorGenerator generator) { - map.put(processorId, generator); - } - - public static Set getProcessors() { - return map.keySet(); - } - - static { - registerRoomProcessor("default", new GeneralRoomProcessor.Generator()); - registerRoomProcessor("button_5", new RoomProcessorButtonSolver.Generator()); - registerRoomProcessor("puzzle_water_solver", new RoomProcessorWaterPuzzle.Generator()); - registerRoomProcessor("puzzle_teleport_solver", new RoomProcessorTeleportMazeSolver.Generator()); - registerRoomProcessor("puzzle_riddle_solver", new RoomProcessorRiddle.Generator()); - registerRoomProcessor("puzzle_creeper_solver", new RoomProcessorCreeperSolver.Generator()); - registerRoomProcessor("puzzle_tictactoe_solver", new RoomProcessorTicTacToeSolver.Generator()); - - registerRoomProcessor("puzzle_blaze_solver", new RoomProcessorBlazeSolver.Generator()); - - - registerRoomProcessor("puzzle_silverfish", new RoomProcessorIcePath.Generator()); // done - registerRoomProcessor("puzzle_icefill", new RoomProcessorIcePath2.Generator()); - registerRoomProcessor("puzzle_box", new RoomProcessorBoxSolver.Generator()); - registerRoomProcessor("puzzle_trivia", new RoomProcessorTrivia.Generator()); - registerRoomProcessor("puzzle_bombdefuse", new RoomProcessorBombDefuseSolver.Generator()); - - registerRoomProcessor("bossroom", new RoomProcessorRedRoom.Generator()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java deleted file mode 100755 index d340366e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.events.BlockUpdateEvent; -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -public interface RoomProcessor { - void tick(); - void drawScreen(float partialTicks); - void drawWorld(float partialTicks); - void chatReceived(IChatComponent chat); - void actionbarReceived(IChatComponent chat); - - boolean readGlobalChat(); - - void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event); - void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent); - void onEntityDeath(LivingDeathEvent deathEvent); - - void onKeybindPress(KeyBindPressedEvent keyInputEvent); - - void onInteract(PlayerInteractEntityEvent event); - void onInteractBlock(PlayerInteractEvent event); - - void onBlockUpdate(BlockUpdateEvent blockUpdateEvent); -} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java deleted file mode 100755 index dcdb32b8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorBlazeSolver.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.solvers.FeatureSolverBlaze; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.monster.EntityBlaze; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemBow; -import net.minecraft.util.*; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; - -public class RoomProcessorBlazeSolver extends GeneralRoomProcessor { - - private boolean highToLow = false; - - private List entityList = new ArrayList(); - private List blazeList = new ArrayList<>(); - private EntityArmorStand next; - private EntityBlaze nextBlaze, theoneafterit; - public RoomProcessorBlazeSolver(DungeonRoom dungeonRoom) { - super(dungeonRoom); - Object highToLow = dungeonRoom.getDungeonRoomInfo().getProperties().get("order"); - if (highToLow == null) this.highToLow = false; - else this.highToLow = (Boolean) highToLow; - } - - @Override - public void tick() { - super.tick(); - - DungeonRoom dungeonRoom = getDungeonRoom(); - World w = dungeonRoom.getContext().getWorld(); - final BlockPos low = dungeonRoom.getMin(); - final BlockPos high = dungeonRoom.getMax(); - entityList = new ArrayList(w.getEntities(EntityArmorStand.class, input -> { - BlockPos pos = input.getPosition(); - return low.getX() < pos.getX() && pos.getX() < high.getX() - && low.getZ() < pos.getZ() && pos.getZ() < high.getZ() && input.getName().toLowerCase().contains("blaze"); - })); - blazeList = new ArrayList(w.getEntities(EntityBlaze.class, input -> { - BlockPos pos = input.getPosition(); - return low.getX() < pos.getX() && pos.getX() < high.getX() - && low.getZ() < pos.getZ() && pos.getZ() < high.getZ(); - })); - - Comparator comparator = Comparator.comparingInt(a -> { - String name = a.getName(); - String colorGone = TextUtils.stripColor(name); - String health2 = TextUtils.keepIntegerCharactersOnly(colorGone.split("/")[1]); - try { - return Integer.parseInt(health2); - } catch (Exception e) {return -1;} - }); - if (highToLow) { - entityList.sort(comparator.reversed()); - } else { - entityList.sort(comparator); - } - - if (entityList.size() > 0) { - next = entityList.get(0); - nextBlaze = blazeList.stream().min(Comparator.comparingDouble(e -> e.getDistanceSqToEntity(next))).orElse(null); - } else { - next = null; - nextBlaze = null; - } - if (entityList.size() > 1) { - EntityArmorStand thenextone = entityList.get(1); - theoneafterit = blazeList.stream().min(Comparator.comparingDouble(e -> e.getDistanceSqToEntity(thenextone))).orElse(null); - } else { - theoneafterit = null; - } - } - - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_BLAZE.isEnabled()) return; - if (next == null) return; - Vec3 pos = next.getPositionEyes(partialTicks); - RenderUtils.drawTextAtWorld("NEXT", (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, 0xFFFF0000, 0.5f, true, false, partialTicks); - - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - - for (EntityBlaze entity : blazeList) { - GlStateManager.pushMatrix(); - float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks; - double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks; - double y = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks; - double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks; - - - GL11.glEnable(GL11.GL_STENCIL_TEST); - GL11.glClearStencil(0); - GlStateManager.disableDepth(); - GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); - - GL11.glStencilMask(0xFF); - GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); - GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); - - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - - GlStateManager.colorMask(false, false, false, false); - Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, x,y,z,f,partialTicks, true); - GlStateManager.colorMask(true, true, true, true); - - GlStateManager.popMatrix(); - - - GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); - GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); - -// Gui.drawRect(-9999,-9999, 9999, 9999, 0xFFFFFFFF); - - boolean border = true; - - RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-0.8,0, -0.8, 0.8, 2, 0.8), FeatureRegistry.SOLVER_BLAZE.getBlazeColor(), partialTicks, false); - if (entity == theoneafterit) { - RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-0.8,0, -0.8, 0.8, 2, 0.8), FeatureRegistry.SOLVER_BLAZE.getNextUpBlazeColor(), partialTicks, false); - } else if (entity == nextBlaze) - RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-0.8,0, -0.8, 0.8, 2, 0.8), FeatureRegistry.SOLVER_BLAZE.getNextBlazeColor(), partialTicks, false); - - GlStateManager.color(1,1,1,1); - - - if (FeatureRegistry.SOLVER_BLAZE.getParameter("blazeborder").getValue().getAlpha() > 0x10) { - GL11.glStencilFunc(GL11.GL_NOTEQUAL, 3, 0x01); - GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_REPLACE, GL11.GL_REPLACE); - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - GlStateManager.translate(x, y + 0.7, z); - GlStateManager.scale(1.1f, 1.1f, 1.1f); - - GlStateManager.colorMask(false, false, false, false); - Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0, -0.7, 0, f, partialTicks, true); - GlStateManager.colorMask(true, true, true, true); - - GlStateManager.popMatrix(); - - - - GL11.glStencilFunc(GL11.GL_EQUAL, 3, 0xFF); - GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); - - RenderUtils.highlightBox(entity, AxisAlignedBB.fromBounds(-1, 0, -1, 1, 2, 1), FeatureRegistry.SOLVER_BLAZE.getParameter("blazeborder").getValue(), partialTicks, false); - - - } - GL11.glDisable(GL11.GL_STENCIL_TEST); - GlStateManager.enableDepth(); - GlStateManager.popMatrix(); - } - } - - - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorBlazeSolver createNew(DungeonRoom dungeonRoom) { - RoomProcessorBlazeSolver defaultRoomProcessor = new RoomProcessorBlazeSolver(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorButtonSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorButtonSolver.java deleted file mode 100644 index 4faf456c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorButtonSolver.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.BlockPos; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.awt.*; -import java.util.Arrays; - -public class RoomProcessorButtonSolver extends GeneralRoomProcessor { - public RoomProcessorButtonSolver(DungeonRoom dungeonRoom) { - super(dungeonRoom); - - OffsetPointSet ops = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("buttons"); - if (ops == null) { - bugged = true; - return; - } - - buttons = new BlockPos[12]; - woods = new BlockPos[12]; - for (int i = 0; i < ops.getOffsetPointList().size(); i++) { - buttons[i] = ops.getOffsetPointList().get(i).getBlockPos(dungeonRoom); - woods[i] = buttons[i].add(0,-1,0); - } - } - - private boolean bugged; - - private BlockPos[] buttons; - private BlockPos[] woods; - - private long clicked; - private int clickedButton = -1; - - private final int[] result = new int[12]; - - @Override - public void onInteractBlock(PlayerInteractEvent event) { - super.onInteractBlock(event); - if (bugged) return; - - if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return; - for (int i = 0; i < buttons.length; i++) { - if (event.pos.equals(buttons[i])) { - clicked = System.currentTimeMillis(); - clickedButton = i; - return; - } - } - } - - @Override - public void chatReceived(IChatComponent chat) { - super.chatReceived(chat); - if (bugged) return; - - if (clickedButton == -1) return; - if (clicked + 500 < System.currentTimeMillis()) return; - - String msg = chat.getFormattedText(); - if (msg.equals("ยงrยงcThis button doesn't seem to do anything...ยงr")) { - result[clickedButton] = -1; - clickedButton = -1; - } else if (msg.equals("ยงrยงaThis button seems connected to somethingยงr")) { - Arrays.fill(result, -1); - if (clickedButton % 4 != 0) result[clickedButton - 1] = 1; - if (clickedButton % 4 != 3) result[clickedButton + 1] = 1; - clickedButton = -1; - } else if (msg.equals("ยงrยงaClick! you Hear the sound of a door openingยงr")) { - Arrays.fill(result, -1); - result[clickedButton] = 2; - clickedButton = -1; - } else if (msg.equals("ยงrยงaWrong button, looks like the system reset!ยงr")) { - Arrays.fill(result, 0); - clickedButton = -1; - } - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (bugged) return; - if (Minecraft.getMinecraft().thePlayer.getPosition().distanceSq(woods[6]) > 100) return; - - - for (int i = 0; i < woods.length; i++) { - int data = result[i]; - BlockPos pos = woods[i]; - - if (data == 0) { - RenderUtils.highlightBlock(pos, new Color(0, 255, 255, 50), partialTicks, false); - } else if (data == -1) { - RenderUtils.highlightBlock(pos, new Color(255, 0, 0, 50), partialTicks, false); - } else if (data == 1) { - RenderUtils.highlightBlock(pos, new Color(0, 255, 0, 50), partialTicks, false); - } else if (data == 2) { - RenderUtils.highlightBlock(pos, new Color(0, 255, 0, 100), partialTicks, false); - } - } - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorButtonSolver createNew(DungeonRoom dungeonRoom) { - RoomProcessorButtonSolver defaultRoomProcessor = new RoomProcessorButtonSolver(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java deleted file mode 100755 index ed9cadf0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.entity.monster.EntityCreeper; -import net.minecraft.init.Blocks; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class RoomProcessorCreeperSolver extends GeneralRoomProcessor { - - private final List poses = new ArrayList(); - - private final boolean bugged = false; - - public RoomProcessorCreeperSolver(DungeonRoom dungeonRoom) { - super(dungeonRoom); - - findCreeperAndDoPoses(); - } - - private boolean check(AxisAlignedBB axis, Vec3 vec) { - if (vec == null) return false; - return axis.isVecInside(vec); - } - - private void findCreeperAndDoPoses() { - World w = getDungeonRoom().getContext().getWorld(); - List prismarines = new ArrayList(); - final BlockPos low = getDungeonRoom().getMin().add(0,-2,0); - final BlockPos high = getDungeonRoom().getMax().add(0,20,0); - final AxisAlignedBB axis = AxisAlignedBB.fromBounds( - low.getX() + 17, low.getY() + 7, low.getZ() + 17, - low.getX() + 16, low.getY() + 10.5, low.getZ() + 16 - ); - - for (BlockPos pos : BlockPos.getAllInBox(low, high)) { - Block b = w.getBlockState(pos).getBlock(); - if (b == Blocks.prismarine || b == Blocks.sea_lantern) { - for (EnumFacing face:EnumFacing.VALUES) { - if (w.getBlockState(pos.offset(face)).getBlock() == Blocks.air) { - prismarines.add(pos); - break; - } - } - } - } - double offset = 0.1; - - while (prismarines.size() > 1) { - BlockPos first = prismarines.get(0); - BlockPos highestMatch = null; - int highestDist = 0; - label: for (int i = 1; i < prismarines.size(); i++) { - BlockPos second = prismarines.get(i); - - if (second.distanceSq(first) < highestDist) continue; - - Vec3 startLoc = new Vec3(first).addVector(0.5,0.5,0.5); - Vec3 dest = new Vec3(second).addVector(0.5,0.5,0.5); - if (check(axis, startLoc.getIntermediateWithYValue(dest, axis.minY+offset)) || - check(axis, startLoc.getIntermediateWithYValue(dest, axis.maxY-offset)) || - check(axis, startLoc.getIntermediateWithXValue(dest, axis.minX+offset)) || - check(axis, startLoc.getIntermediateWithXValue(dest, axis.maxX-offset)) || - check(axis, startLoc.getIntermediateWithZValue(dest, axis.minZ+offset)) || - check(axis, startLoc.getIntermediateWithZValue(dest, axis.maxZ-offset))) { - highestDist = (int) second.distanceSq(first); - highestMatch = second; - } - - } - - - if (highestMatch == null) { - prismarines.remove(first); - } else { - prismarines.remove(first); - prismarines.remove(highestMatch); - poses.add(new BlockPos[] {first, highestMatch}); - } - } - } - - @Override - public void tick() { - super.tick(); - if (bugged) { - findCreeperAndDoPoses(); - } - } - - private static final Color[] colors = new Color[] {Color.red, Color.orange, Color.green, Color.cyan, Color.blue, Color.pink, Color.yellow, Color.darkGray, Color.lightGray}; - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_CREEPER.isEnabled()) return; - World w = getDungeonRoom().getContext().getWorld(); - for (int i = 0; i < poses.size(); i++) { - BlockPos[] poset = poses.get(i); - Color color = colors[i % colors.length]; - boolean oneIsConnected = w.getChunkFromBlockCoords(poset[0]).getBlock(poset[0]) != Blocks.sea_lantern && - w.getChunkFromBlockCoords(poset[1]).getBlock(poset[1]) != Blocks.sea_lantern; - RenderUtils.drawLine(new Vec3(poset[0].getX() +0.5, poset[0].getY() +0.5, poset[0].getZ()+0.5), - new Vec3(poset[1].getX() +0.5, poset[1].getY() +0.5, poset[1].getZ()+0.5), oneIsConnected ? new Color(0,0,0,50) : color, partialTicks, true); - } - final BlockPos low = getDungeonRoom().getMin(); - final AxisAlignedBB axis = AxisAlignedBB.fromBounds( - low.getX() + 17, low.getY() + 5, low.getZ() + 17, - low.getX() + 16, low.getY() + 8.5, low.getZ() + 16 - ); - RenderUtils.highlightBox(axis, new Color(0x4400FF00, true), partialTicks, false); - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorCreeperSolver createNew(DungeonRoom dungeonRoom) { - RoomProcessorCreeperSolver defaultRoomProcessor = new RoomProcessorCreeperSolver(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorGenerator.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorGenerator.java deleted file mode 100755 index 97ad2d22..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorGenerator.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; - -public interface RoomProcessorGenerator { - T createNew(DungeonRoom dungeonRoom); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java deleted file mode 100755 index 03654a88..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; -import net.minecraft.entity.Entity; -import net.minecraft.entity.monster.EntitySilverfish; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class RoomProcessorIcePath extends GeneralRoomProcessor { - - private int[][] map; - private OffsetPoint[][] map2; - private final Set endNode = new HashSet(); - - private final List solution = new ArrayList(); - - private BlockPos lastSilverfishLoc; - private int sameTick; - - private Entity silverfish; - - private boolean err; - - public RoomProcessorIcePath(DungeonRoom dungeonRoom) { - super(dungeonRoom); - findSilverFishanddoStuff(); - } - - public void findSilverFishanddoStuff() { - final BlockPos low = getDungeonRoom().getMin(); - final BlockPos high = getDungeonRoom().getMax(); - List silverfishs = getDungeonRoom().getContext().getWorld().getEntities(EntitySilverfish.class, new Predicate() { - @Override - public boolean apply(@Nullable EntitySilverfish input) { - if (input.isInvisible()) return false; - BlockPos pos = input.getPosition(); - return low.getX() < pos.getX() && pos.getX() < high.getX() - && low.getZ() < pos.getZ() && pos.getZ() < high.getZ(); - } - }); - - if (!silverfishs.isEmpty()) silverfish = silverfishs.get(0); - if (silverfishs.isEmpty()) { - err = true; - return; - } - try { - buildMap(); - err = false; - } catch (Exception e) { - e.printStackTrace(); - err = true; - return; - } - } - - private void buildMap() { - int width = (Integer) getDungeonRoom().getDungeonRoomInfo().getProperties().get("width"); - int height = (Integer) getDungeonRoom().getDungeonRoomInfo().getProperties().get("height"); - OffsetPointSet ops = (OffsetPointSet) getDungeonRoom().getDungeonRoomInfo().getProperties().get("board"); - OffsetPointSet endNodes = (OffsetPointSet) getDungeonRoom().getDungeonRoomInfo().getProperties().get("endnodes"); - map2 = new OffsetPoint[width][height]; - map = new int[width][height]; - for (int y = 0; y < height; y ++) { - for (int x =0; x < width; x++) { - OffsetPoint op = ops.getOffsetPointList().get(y * width + x); - map2[y][x] = op; - map[y][x] = op.getBlock(getDungeonRoom()) == Blocks.air ? 0 : 1; - } - } - endNode.addAll(endNodes.getOffsetPointList()); - } - - public void tick() { - super.tick(); - if (err || silverfish.isDead) { - findSilverFishanddoStuff(); - if (err) return; - } - if (silverfish.getPosition().equals(lastSilverfishLoc)) { - if (sameTick < 10) { - sameTick ++; - return; - } else if (sameTick == 10) { - sameTick ++; - Point silverfish = getPointOfSilverFishOnMap(this.silverfish.getPosition()); - List tempSol = solve(map, silverfish.x, silverfish.y, new Predicate() { - @Override - public boolean apply(@Nullable Point input) { - return endNode.contains(map2[input.y][input.x]); - } - }); - { - solution.clear(); - for (Point point : tempSol) { - solution.add(map2[point.y][point.x].getBlockPos(getDungeonRoom())); - } - } - - } - } else { - sameTick = 0; - } - - lastSilverfishLoc = silverfish.getPosition(); - } - - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_SILVERFISH.isEnabled()) return; - if (!err) - RenderUtils.drawLines(solution, FeatureRegistry.SOLVER_SILVERFISH.getLineColor(),FeatureRegistry.SOLVER_SILVERFISH.getLineWidth(), partialTicks, true); - } - - public Point getPointOfSilverFishOnMap(BlockPos blockPos) { - for (int y = 0; y < map.length; y ++) { - for (int x = 0; x < map[0].length; x++) { - if (map2[y][x].getBlockPos(getDungeonRoom()).equals(blockPos)) - return new Point(x,y); - } - } - return null; - } - - - // Taken from https://stackoverflow.com/a/55271133 and modified to suit our needs - // Answer by ofekp (https://stackoverflow.com/users/4295037/ofekp) - public static List solve(int[][] board, int startX, int startY, Predicate finishLinePredicate) { - Point startPoint = new Point(startX, startY); - - LinkedList queue = new LinkedList(); - Point[][] boardSearch = new Point[board.length][board[0].length]; - - queue.addLast(new Point(startX, startY)); - boardSearch[startY][startX] = startPoint; - - while (queue.size() != 0) { - Point currPos = queue.pollFirst(); - for (Direction dir : Direction.values()) { - Point nextPos = move(board, boardSearch, currPos, dir); - if (nextPos != null) { - queue.addLast(nextPos); - boardSearch[nextPos.y][nextPos.x] = new Point(currPos.x, currPos.y); - if (finishLinePredicate.apply(nextPos)) { - List route = new ArrayList(); - Point tmp = currPos; - route.add(nextPos); - route.add(currPos); - while (tmp != startPoint) { - tmp = boardSearch[tmp.y][tmp.x]; - route.add(tmp); - } - return route; - } - } - } - } - return Collections.emptyList(); - } - - public static Point move(int[][] board, Point[][] boardSearch, Point currPos, Direction dir) { - int x = currPos.x; - int y = currPos.y; - - int diffX = dir.dx; - int diffY = dir.dy; - - int i = 1; - while (x + i * diffX >= 0 && x + i * diffX < board[0].length - && y + i * diffY >= 0 && y + i * diffY < board.length - && board[y + i * diffY][x + i * diffX] != 1) { - i++; - } - i--; - - if (boardSearch[y + i * diffY][x + i * diffX] != null) { - return null; - } - - return new Point(x + i * diffX, y + i * diffY); - } - - @Getter - @AllArgsConstructor - public enum Direction { - LEFT(-1,0), - RIGHT(1,0), - UP(0,-1), - DOWN(0,1); - - int dx, dy; - } - - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorIcePath createNew(DungeonRoom dungeonRoom) { - RoomProcessorIcePath defaultRoomProcessor = new RoomProcessorIcePath(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRedRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRedRoom.java deleted file mode 100644 index 2ac55ea8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRedRoom.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.features.impl.boss.FeatureWarningOnPortal; -import kr.syeyoung.dungeonsguide.features.text.StyledTextRenderer; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; -import org.lwjgl.opengl.GL11; - -import javax.vecmath.Vector3f; - -public class RoomProcessorRedRoom extends GeneralRoomProcessor { - public RoomProcessorRedRoom(DungeonRoom dungeonRoom) { - super(dungeonRoom); - BlockPos basePt = dungeonRoom.getMin().add(dungeonRoom.getMax()); - this.basePt = new Vec3(basePt.getX() / 2.0f, basePt.getY() / 2.0f, basePt.getZ() / 2.0f); - } - - Vec3 basePt; - int dir = 0; - - @Override - public void tick() { - BlockPos basePt = getDungeonRoom().getMin().add(getDungeonRoom().getMax()); - this.basePt = new Vec3(basePt.getX() / 2.0f, basePt.getY() / 2.0f + 4, basePt.getZ() / 2.0f); - DungeonDoor real = null; - for (DungeonDoor door : getDungeonRoom().getDoors()) { - if (door.getType().isExist()) { - real = door;break; - } - } - if (real != null) { - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), real.getPosition()); - offsetPoint = new OffsetPoint(33- offsetPoint.getX(), offsetPoint.getY(), 33 - offsetPoint.getZ()); - BlockPos opposite =offsetPoint.getBlockPos(getDungeonRoom()); - BlockPos dir = new BlockPos(real.getPosition().subtract(opposite)); - dir = new BlockPos(MathHelper.clamp_int(dir.getX() / 10, -1, 1), 0, MathHelper.clamp_int(dir.getZ() / 10, -1, 1)); - - this.basePt = new Vec3(opposite.add(dir.getX() * 6 + dir.getZ(), 3, dir.getZ() * 6 - dir.getX())); - - if (dir.getX() > 0) this.dir = 270; - else if (dir.getX() < 0) this.dir = 90; - else if (dir.getZ() < 0) this.dir = 0; - else if (dir.getZ() > 0) this.dir = 180; - else this.dir = Integer.MIN_VALUE; - } else { - dir = Integer.MIN_VALUE; - } - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.BOSSFIGHT_WARNING_ON_PORTAL.isEnabled()) return; - - - FeatureWarningOnPortal featureWarningOnPortal = FeatureRegistry.BOSSFIGHT_WARNING_ON_PORTAL; - { - RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); - - Vector3f renderPos = RenderUtils.getRenderPos((float)basePt.xCoord,(float) basePt.yCoord, (float)basePt.zCoord, partialTicks); - - GlStateManager.color(1f, 1f, 1f, 0.5f); - GlStateManager.pushMatrix(); - GlStateManager.translate(renderPos.x, renderPos.y, renderPos.z); - if (dir == Integer.MIN_VALUE) - GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); - else - GlStateManager.rotate(dir, 0.0f, 1.0f, 0.0f); - GlStateManager.scale(-0.05f, -0.05f, 0.05f); - GlStateManager.disableLighting(); - GlStateManager.depthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); - GlStateManager.disableDepth(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - - StyledTextRenderer.drawTextWithStylesAssociated(featureWarningOnPortal.getText(), 0, 0,0, featureWarningOnPortal.getStylesMap(), StyledTextRenderer.Alignment.LEFT); - - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GlStateManager.depthMask(true); - GlStateManager.enableDepth(); - GlStateManager.popMatrix(); - } - } - - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorRedRoom createNew(DungeonRoom dungeonRoom) { - RoomProcessorRedRoom defaultRoomProcessor = new RoomProcessorRedRoom(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java deleted file mode 100755 index 7994e86b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorRiddle.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.init.Blocks; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.util.Arrays; -import java.util.List; -import java.util.regex.Pattern; - -public class RoomProcessorRiddle extends GeneralRoomProcessor { - - public RoomProcessorRiddle(DungeonRoom dungeonRoom) { - super(dungeonRoom); - } - - private static final List patternList = Arrays.asList( - Pattern.compile("My chest doesn't have the reward. We are all telling the truth.*"), - Pattern.compile("The reward isn't in any of our chests.*"), - Pattern.compile("The reward is not in my chest!.*"), - Pattern.compile("At least one of them is lying, and the reward is not in .+'s chest.*"), - Pattern.compile("Both of them are telling the truth. Also,.+has the reward in their chest.*"), - Pattern.compile("My chest has the reward and I'm telling the truth.*") - ); - - @Override - public void chatReceived(IChatComponent chat) { - super.chatReceived(chat); - if (!FeatureRegistry.SOLVER_RIDDLE.isEnabled()) return; - String ch2 = chat.getUnformattedText(); - if (!ch2.startsWith("ยงe[NPC] ")) { - return; - } - String watsaid = TextUtils.stripColor(ch2.split(":")[1]).trim(); - boolean foundMatch = false; - for (Pattern p:patternList) { - if (p.matcher(watsaid).matches()) { - foundMatch = true; - break; - } - } - if (foundMatch) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeRiddle ยง7:: "+ch2.split(":")[0].trim()+" ยงfhas the reward!")); - final String name = TextUtils.stripColor(ch2.split(":")[0]).replace("[NPC] ","").trim(); - final BlockPos low = getDungeonRoom().getMin(); - final BlockPos high = getDungeonRoom().getMax(); - World w = getDungeonRoom().getContext().getWorld(); - List armor = w.getEntities(EntityArmorStand.class, new Predicate() { - @Override - public boolean apply(@Nullable EntityArmorStand input) { - BlockPos pos = input.getPosition(); - return low.getX() < pos.getX() && pos.getX() < high.getX() - && low.getZ() < pos.getZ() && pos.getZ() < high.getZ() && TextUtils.stripColor(input.getName()).equalsIgnoreCase(name); - } - }); - - if (armor != null) { - this.chest = null; - BlockPos pos = armor.get(0).getPosition(); - for (BlockPos allInBox : BlockPos.getAllInBox(pos.add(-1, 0, -1), pos.add(1, 0, 1))) { - Block b = w.getChunkFromBlockCoords(allInBox).getBlock(allInBox); - - if ((b == Blocks.chest || b == Blocks.trapped_chest)&& allInBox.distanceSq(pos) == 1 ) { - this.chest = allInBox; - return; - } - } - } - - } - } - - BlockPos chest; - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_RIDDLE.isEnabled()) return; - if (chest != null) { - RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(chest.getX(), chest.getY(), chest.getZ(), chest.getX()+1, chest.getY() + 1, chest.getZ() + 1), FeatureRegistry.SOLVER_RIDDLE.getTargetColor(), partialTicks, true); - } - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorRiddle createNew(DungeonRoom dungeonRoom) { - RoomProcessorRiddle defaultRoomProcessor = new RoomProcessorRiddle(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java deleted file mode 100755 index a16fc11e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTeleportMazeSolver.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.init.Blocks; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class RoomProcessorTeleportMazeSolver extends GeneralRoomProcessor { - private BlockPos lastPlayerLocation; - - public RoomProcessorTeleportMazeSolver(DungeonRoom dungeonRoom) { - super(dungeonRoom); - yLevel = dungeonRoom.getMin().getY() - 1; - } - - private final List visitedPortals = new ArrayList(); - - private int yLevel = 0; - private double slope1, slope2; - private double posX1, posZ1, posX2, posZ2; - private int times=0 ; - - private double intersectionX, intersectionZ; - private BlockPos intersection; - - @Override - public void tick() { - super.tick(); - - - - World w = getDungeonRoom().getContext().getWorld(); - EntityPlayerSP entityPlayerSP = Minecraft.getMinecraft().thePlayer; - BlockPos pos2 = new BlockPos(Math.floor(entityPlayerSP.posX), Math.floor(entityPlayerSP.posY), Math.floor(entityPlayerSP.posZ)); - Block b = w.getChunkFromBlockCoords(pos2).getBlock(pos2); - Vec3 lookVec = entityPlayerSP.getLookVec(); - - if (times % 4 == 1) { - posX1 = entityPlayerSP.posX; - posZ1 = entityPlayerSP.posZ; - slope1 = lookVec.zCoord / lookVec.xCoord; - times ++; - } else if (times % 4 == 3) { - posX2 = entityPlayerSP.posX; - posZ2 = entityPlayerSP.posZ; - slope2 = lookVec.zCoord / lookVec.xCoord; - - double yInt1 = posZ1 - posX1 * slope1; - double yInt2 = posZ2 - posX2 * slope2; - - intersectionX = (yInt2 - yInt1) / (slope1 - slope2); - intersectionZ = (slope1 * intersectionX + yInt1); - intersection = new BlockPos((int) intersectionX, yLevel, (int) intersectionZ); - times++; - } - - if (b == Blocks.stone_slab || b == Blocks.stone_slab2) { - boolean teleport = false; - if (lastPlayerLocation.distanceSq(pos2) < 3) return; - for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation, pos2)) { - if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.iron_bars) { - teleport = true; - break; - } - } - - if (teleport) { - if (times % 4 == 0) { - times ++; - } else if (times % 4 == 2){ - times++; - } - - for (BlockPos allInBox : BlockPos.getAllInBox(pos2.add(-1, 0, -1), pos2.add(1, 0, 1))) { - if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) { - if (!visitedPortals.contains(allInBox)) - visitedPortals.add(allInBox); - break; - } - } - for (BlockPos allInBox : BlockPos.getAllInBox(lastPlayerLocation.add(-1, -1, -1), lastPlayerLocation.add(1, 1, 1))) { - if (w.getChunkFromBlockCoords(allInBox).getBlock(allInBox) == Blocks.end_portal_frame) { - if (!visitedPortals.contains(allInBox)) - visitedPortals.add(allInBox); - break; - } - } - } - } - - lastPlayerLocation = pos2; - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_TELEPORT.isEnabled()) return; - for (BlockPos bpos:visitedPortals) { - RenderUtils.highlightBoxAColor( AxisAlignedBB.fromBounds(bpos.getX(), bpos.getY(), bpos.getZ(), bpos.getX()+1, bpos.getY() + 1, bpos.getZ() + 1), FeatureRegistry.SOLVER_TELEPORT.getTargetColor2(), partialTicks, true); - } - - if (intersection != null) { - RenderUtils.highlightBoxAColor( AxisAlignedBB.fromBounds(intersection.getX(), intersection.getY(), intersection.getZ(), intersection.getX()+1, intersection.getY() + 1, intersection.getZ() + 1), FeatureRegistry.SOLVER_TELEPORT.getTargetColor(), partialTicks, false); - } - } - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorTeleportMazeSolver createNew(DungeonRoom dungeonRoom) { - RoomProcessorTeleportMazeSolver defaultRoomProcessor = new RoomProcessorTeleportMazeSolver(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java deleted file mode 100755 index 42c178cd..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTicTacToeSolver.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityItemFrame; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemMap; -import net.minecraft.item.ItemStack; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.storage.MapData; - -import java.awt.*; -import java.util.List; - -public class RoomProcessorTicTacToeSolver extends GeneralRoomProcessor { - - private final OffsetPointSet board; - private byte[][] lastBoard; - public RoomProcessorTicTacToeSolver(DungeonRoom dungeonRoom) { - super(dungeonRoom); - - board = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("board"); - } - - // -1 com, 1 pla, 0 emp - private byte[][] buildBoardState() { - byte[][] board = new byte[3][3]; - World w= getDungeonRoom().getContext().getWorld(); - for (int x = 0; x < 3; x++) { - for (int y = 0; y < 3; y++) { - OffsetPoint op = this.board.getOffsetPointList().get(x * 3 + y); - BlockPos bpos = op.getBlockPos(getDungeonRoom()); - Block b = w.getChunkFromBlockCoords(bpos).getBlock(bpos); - if (b == Blocks.stone_button) { - board[y][x] = 0; - } else if (b == Blocks.air){ - AxisAlignedBB abab = AxisAlignedBB.fromBounds(bpos.getX() , bpos.getY(), bpos.getZ(), bpos.getX() +1, bpos.getY() +1, bpos.getZ() +1); - List frames = getDungeonRoom().getContext().getWorld().getEntitiesWithinAABB(EntityItemFrame.class, abab); - if (frames.isEmpty()) board[y][x] = 0; - else { - ItemStack displayedItem = frames.get(0).getDisplayedItem(); - if (displayedItem == null || displayedItem.getItem() == null || !displayedItem.getItem().isMap()) { - board[y][x] = 0; - continue; - } - MapData mapData = ((ItemMap)displayedItem.getItem()).getMapData(displayedItem, w); - byte center = mapData.colors[64 * 128+64]; - if (center == 114) - board[y][x] = -1; - else - board[y][x] = 1; - } - } - } - } - return board; - } - - private byte checkWinner(byte[][] board) { - for (int y = 0; y <3; y++) { - byte potentialWinner = board[y][0]; - if (potentialWinner == 0) continue; - boolean found = false; - for (int x = 0; x < 3; x++) { - if (potentialWinner != board[y][x]) { - found = true; - break; - } - } - if (!found) { - return potentialWinner; - } - } - for (int x = 0; x <3; x++) { - byte potentialWinner = board[0][x]; - if (potentialWinner == 0) continue; - boolean found = false; - for (int y = 0; y < 3; y++) { - if (potentialWinner != board[y][x]) { - found = true; - break; - } - } - if (!found) { - return potentialWinner; - } - } - if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != 0) { - return board[0][0]; - } - if (board[0][2] == board[1][1] && board[1][1] == board[2][0] && board[0][2] != 0) { - return board[0][2]; - } - return 0; - } - - private int chosePos = -1; - private int minimax(byte[][] board, byte player) { - byte winner = checkWinner(board); - if (winner != 0) { - return winner * player; - } - - int move = -1; - int score = -2; - for (int i = 0; i < 9; i++) { - if (board[i % 3][i / 3] == 0) { - byte[][] cloned = new byte[3][]; - for(int k = 0; k < 3; k++) - cloned[k] = board[k].clone(); - - cloned[i % 3][i/3] = player; - int scoreForMove = -minimax(cloned, (byte) -player); - if (scoreForMove > score) { - score = scoreForMove; - move = i; - } - } - } - chosePos = move; - if (move == -1) { - return 0; - } - - return score; - } - - private boolean gameEnded = false; - - @Override - public void tick() { - super.tick(); - if (board == null) return; - if (gameEnded) return; - byte[][] board = buildBoardState(); - if (checkWinner(board) != 0) { - gameEnded = true; - return; - } - if (lastBoard != null) { - boolean yesdoit = false; - label: - for (int y = 0; y < 3; y++) - for (int x = 0; x < 3; x++) - if (board[y][x] != lastBoard[y][x]) { - yesdoit = true; - break label; - } - if (!yesdoit) return; - } - lastBoard = board; - - minimax(board, (byte) 1); - if (chosePos == -1) { - gameEnded = true; - return; - } - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_TICTACTOE.isEnabled()) return; - if (chosePos != -1) { - BlockPos block = board.getOffsetPointList().get(chosePos).getBlockPos(getDungeonRoom()); - boolean whoseturn = false; // false => hype true => me - if (lastBoard != null) { - int ones = 0; - int negativeones = 0; - for (byte[] bytes : lastBoard) { - for (byte aByte : bytes) { - if (aByte == 1) ones++; - else if (aByte == -1) negativeones++; - } - } - whoseturn = ones < negativeones; - } - RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(block.getX(), block.getY(), block.getZ(), block.getX()+1, block.getY() + 1, block.getZ() + 1), - whoseturn ? FeatureRegistry.SOLVER_TICTACTOE.getTargetColor() - : FeatureRegistry.SOLVER_TICTACTOE.getTargetColor2(), partialTicks, true); - } - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorTicTacToeSolver createNew(DungeonRoom dungeonRoom) { - RoomProcessorTicTacToeSolver defaultRoomProcessor = new RoomProcessorTicTacToeSolver(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java deleted file mode 100755 index 8e022679..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor; - -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.SkyblockUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; -import net.minecraft.client.Minecraft; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import org.apache.commons.lang3.math.NumberUtils; -import org.json.JSONObject; - -import java.awt.*; -import java.io.IOException; -import java.util.*; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class RoomProcessorTrivia extends GeneralRoomProcessor { - - public RoomProcessorTrivia(DungeonRoom dungeonRoom) { - super(dungeonRoom); - } - - - private final List questionDialog = new ArrayList(); - private boolean questionDialogStart = false; - - private boolean parseDialog = false; - @Override - public void chatReceived(IChatComponent chat) { - super.chatReceived(chat); - if (!FeatureRegistry.SOLVER_KAHOOT.isEnabled()) return; - String ch2 = chat.getUnformattedText(); - if (parseDialog) { - parseDialog = false; - parseDialog(); - } - if (chat.getFormattedText().contains("ยงrยง6ยงlQuestion ")) { - questionDialogStart = true; - questionDialog.clear(); - } - if (questionDialogStart && (chat.getFormattedText().startsWith("ยงrยงrยงr") || chat.getFormattedText().startsWith("ยงrยงrยงr") || chat.getFormattedText().trim().startsWith("ยงrยง6 "))) { - questionDialog.add(chat.getFormattedText()); - } - - if (chat.getFormattedText().contains("ยงrยง6 โ“’")) { - questionDialogStart = false; - parseDialog = true; - } - } - public static final Pattern anwerPattern = Pattern.compile("ยงrยง6 . ยงa(.+)ยงr"); - private void parseDialog() { - String question = TextUtils.stripColor(questionDialog.get(1)).trim(); - String answerA = getAnswer(questionDialog.get(2)); - String answerB = getAnswer(questionDialog.get(3)); - String answerC = getAnswer(questionDialog.get(4)); - match(question, answerA, answerB, answerC); - - } - String correctAnswer; - - - private String getAnswer(String answerString) { - Matcher matcher = anwerPattern.matcher(answerString.trim()); - if (!matcher.matches()) return ""; - return matcher.group(1); - } - private void match(String question, String a, String b, String c) { - StaticResourceCache.INSTANCE.getResource(StaticResourceCache.TRIVIA_ANSWERS).thenAccept(value -> { - JSONObject answersJSON = new JSONObject(value.getValue()); - - String semi_answers = answersJSON.getString(question.toLowerCase().trim()); - String theRealAnswer; - if (semi_answers == null) theRealAnswer = null; - else { - semi_answers = takeCareOfPlaceHolders(semi_answers); - String[] answers = semi_answers.split(","); - if (match(answers, a)) theRealAnswer = "A"; - else if (match(answers, b)) theRealAnswer = "B"; - else if (match(answers, c)) theRealAnswer = "C"; - else theRealAnswer = semi_answers; - } - if (theRealAnswer == null) - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeTrivia ยง7:: ยงcCouldn't determine the answer! (no question found)")); - else if (theRealAnswer.length() >1) - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeTrivia ยง7:: ยงcCouldn't determine the answer! ("+theRealAnswer+")")); - else - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeTrivia ยง7:: "+theRealAnswer+"ยงf is the correct answer!")); - correctAnswer = theRealAnswer; - }); - } - - private String takeCareOfPlaceHolders(String input) { - String str = input; - if (str.contains("$year")) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยงfuses ยงeInventiveTalentยง7(https://github.com/InventivetalentDev)ยงe's Skyblock Api ยงfto fetch current skyblock year!")); - try { - str = str.replace("$year", SkyblockUtils.getSkyblockYear()+""); - } catch (IOException e) { - str = str.replace("$year", "Couldn't determine current skyblock year :: "+e.getMessage()); - } - } - return str; - } - private boolean match(String[] match, String match2) { - for (String s : match) { - if (NumberUtils.isNumber(s)) { - if (match2.toLowerCase().contains(s)) return true; - } else { - if (match2.equalsIgnoreCase(s)) return true; - } - } - return false; - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_KAHOOT.isEnabled()) return; - if (correctAnswer == null) return; - - OffsetPoint op = (OffsetPoint) getDungeonRoom().getDungeonRoomInfo().getProperties().get(correctAnswer); - if (op != null) { - BlockPos solution = op.getBlockPos(getDungeonRoom()); - RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(solution.getX(), solution.getY(), solution.getZ(), solution.getX()+1, solution.getY() + 1, solution.getZ() + 1), FeatureRegistry.SOLVER_KAHOOT.getTargetColor(), partialTicks, false); - } - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorTrivia createNew(DungeonRoom dungeonRoom) { - RoomProcessorTrivia defaultRoomProcessor = new RoomProcessorTrivia(dungeonRoom); - return defaultRoomProcessor; - } - } - - @Override - public boolean readGlobalChat() { - return true; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java deleted file mode 100644 index 0fa14951..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.DummyDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.arrow.ArrowProcessorMatcher; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.bugged.ImpossibleMatcher; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.color.ColorProcessorMatcher; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper.CreeperProcessorMatcher; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath.GoldenPathProcessorMatcher; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze.MazeProcessorMatcher; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number.NumberProcessorMatcher; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import org.apache.commons.codec.binary.Base64; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class RoomProcessorBombDefuseSolver extends GeneralRoomProcessor { - - @Getter - private final List chambers = new ArrayList(); - @Getter - private OffsetPointSet doors; - - private static final List chamberGenerators = new ArrayList(); - { - chamberGenerators.add(new ArrowProcessorMatcher()); - chamberGenerators.add(new ColorProcessorMatcher()); - chamberGenerators.add(new CreeperProcessorMatcher()); - chamberGenerators.add(new NumberProcessorMatcher()); - chamberGenerators.add(new GoldenPathProcessorMatcher()); - chamberGenerators.add(new MazeProcessorMatcher()); - chamberGenerators.add(new ImpossibleMatcher()); - } - - private boolean bugged = false; - private boolean maze = false; - private boolean impossible = false; - - public RoomProcessorBombDefuseSolver(DungeonRoom dungeonRoom) { - super(dungeonRoom); - if (!FeatureRegistry.SOLVER_BOMBDEFUSE.isEnabled()) { - bugged = true; - return; - } - chambers.add(new ChamberSet( - buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("L1"), 1, true), - buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("R1"), 1, true), null - )); - chambers.add(new ChamberSet( - buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("L2"), 2, true), - buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("R2"), 2, true), null - )); - chambers.add(new ChamberSet( - buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("L3"), 3, true), - buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("R3"), 3, true), null - )); - chambers.add(new ChamberSet( - buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("L4"), 4, true), - buildChamber((OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("R4"), 4, true), null - )); - doors = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("Door"); - if (doors == null) {bugged = true; return;} - for (ChamberSet set:chambers) { - if (set.getLeft().getChamberBlocks() == null) { - bugged = true; - return; - } - if (set.getRight().getChamberBlocks() == null) { - bugged = true; - return; - } - } - - for (ChamberSet set:chambers) { - if (set.getLeft().getChamberBlocks() == null) { - bugged = true; - return; - } - if (set.getRight().getChamberBlocks() == null) { - bugged = true; - return; - } - } - - for (ChamberSet set:chambers) { - for (BombDefuseChamberGenerator bdcg:chamberGenerators) { - if (bdcg.match(set.getLeft(), set.getRight())) { - set.setChamberGen(bdcg); - set.getLeft().setProcessor(bdcg.createLeft(set.getLeft(), this)); - set.getRight().setProcessor(bdcg.createRight(set.getRight(), this)); - if (bdcg instanceof ImpossibleMatcher) impossible=true; - if (bdcg instanceof MazeProcessorMatcher) maze = true; - break; - } - } - if (set.getChamberGen() == null) { - set.setChamberGen(null); - set.getLeft().setProcessor(new DummyDefuseChamberProcessor(this, set.getLeft())); - set.getRight().setProcessor(new DummyDefuseChamberProcessor(this, set.getRight())); - } - } - - OffsetPoint warning1 = (OffsetPoint) dungeonRoom.getDungeonRoomInfo().getProperties().get("Warning"); - if (warning1 != null) warning = warning1.getBlockPos(dungeonRoom); - } - - public BDChamber buildChamber(OffsetPointSet ops, int level, boolean left) { - return new BDChamber(getDungeonRoom(), ops, left, level, null); - } - BlockPos warning; - - - public void communicate(NBTTagCompound compound) { - if (bugged) return; - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream w = new DataOutputStream(baos); - CompressedStreamTools.writeCompressed(compound, w); - w.flush(); - byte[] bytes = baos.toByteArray(); - String str = Base64.encodeBase64String(bytes); - Minecraft.getMinecraft().thePlayer.sendChatMessage("/pc $DG-BD " +str); - - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) - ch.getLeft().getProcessor().onDataRecieve(compound); - if (ch.getRight() != null && ch.getRight().getProcessor() != null) - ch.getRight().getProcessor().onDataRecieve(compound); - } - } catch (IOException e2) { - e2.printStackTrace(); - DungeonsGuide.sendDebugChat(new ChatComponentText("Failed to send Bomb Defuse Chat")); - } - } - - @Override - public void chatReceived(IChatComponent component) { - super.chatReceived(component); - if (bugged) return; - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) - ch.getLeft().getProcessor().chatReceived(component); - if (ch.getRight() != null && ch.getRight().getProcessor() != null) - ch.getRight().getProcessor().chatReceived(component); - } - - if (component.getFormattedText().contains("$DG-BD ")) { - try { - String data = component.getFormattedText().substring(component.getFormattedText().indexOf("$DG-BD")); - String actual = TextUtils.stripColor(data).trim().split(" ")[1]; - byte[] data2 = Base64.decodeBase64(actual); - NBTTagCompound compound = CompressedStreamTools.readCompressed(new ByteArrayInputStream(data2)); - - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) - ch.getLeft().getProcessor().onDataRecieve(compound); - if (ch.getRight() != null && ch.getRight().getProcessor() != null) - ch.getRight().getProcessor().onDataRecieve(compound); - } - } catch (Throwable t) { - t.printStackTrace(); - DungeonsGuide.sendDebugChat(new ChatComponentText("Failed to analyze Bomb Defuse Chat")); - } - } - } - - - @Override - public void tick() { - super.tick(); - if (bugged) return; - BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getLeft().getProcessor().tick(); - } - } - if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getRight().getProcessor().tick(); - } - } - } - } - - - @Override - public void drawScreen(float partialTicks) { - super.drawScreen(partialTicks); - if (bugged) return; - BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); - if (FeatureRegistry.DEBUG.isEnabled()) { - for (ChamberSet ch : chambers) { - if (ch.getChamberGen() == null) continue; - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getLeft().getProcessor().drawScreen(partialTicks); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - String str = "Current: " + ch.getChamberGen().getName() + " Specific: " + ch.getLeft().getProcessor().getName(); - fr.drawString(str, 0, 0, 0xFFFFFFFF); - } - } - if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getRight().getProcessor().drawScreen(partialTicks); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - if (ch.getChamberGen() == null || ch.getRight().getProcessor() == null) continue; - String str = "Current: " + ch.getChamberGen().getName() + " Specific: " + ch.getRight().getProcessor().getName(); - fr.drawString(str, 0, 0, 0xFFFFFFFF); - } - } - } - } - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (bugged) return; - - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos((int)Minecraft.getMinecraft().thePlayer.posX, 68, (int)Minecraft.getMinecraft().thePlayer.posZ)); - boolean found = false; - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - found = true; - ch.getLeft().getProcessor().drawWorld(partialTicks); - } - } - if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - found = true; - ch.getRight().getProcessor().drawWorld(partialTicks); - } - } - } - - if ((maze || impossible) && warning != null && !found) { - if (impossible) { - RenderUtils.drawTextAtWorld("Warning: This Bomb Defuse is bugged and Impossible" , warning.getX()+ 0.5f, warning.getY(), warning.getZ()+ 0.5f, 0xFF00FF00, 0.03F, false, false, partialTicks); - } else { - RenderUtils.drawTextAtWorld("Warning: This Bomb Defuse must be done with 2 people (maze)" , warning.getX()+ 0.5f, warning.getY(), warning.getZ()+ 0.5f, 0xFF00FF00, 0.03F, false, false, partialTicks); - } - } - if (warning != null && !found) { - for (int i = 0; i < 4; i++) { - BombDefuseChamberGenerator bdcg = chambers.get(i).getChamberGen(); - RenderUtils.drawTextAtWorld((i + 1) + ". " + (bdcg == null ? "null" : bdcg.getName()), warning.getX() + 0.5f, warning.getY() - ((i + 1) * 0.3f), warning.getZ() + 0.5f, 0xFF00FF00, 0.03F, false, false, partialTicks); - } - } - } - - @Override - public void actionbarReceived(IChatComponent chat) { - super.actionbarReceived(chat); - if (bugged) return; - - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) - ch.getLeft().getProcessor().actionbarReceived(chat); - if (ch.getRight() != null && ch.getRight().getProcessor() != null) - ch.getRight().getProcessor().actionbarReceived(chat); - } - } - - @Override - public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { - super.onPostGuiRender(event); - if (bugged) return; - - BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getLeft().getProcessor().onPostGuiRender(event); - } - } - if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getRight().getProcessor().onPostGuiRender(event); - } - } - } - } - - @Override - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - super.onEntityUpdate(updateEvent); - if (bugged) return; - - BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getLeft().getProcessor().onEntityUpdate(updateEvent); - } - } - if (ch.getRight() != null && ch.getRight().getProcessor() != null) { -// if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getRight().getProcessor().onEntityUpdate(updateEvent); -// } - } - } - } - - @Override - public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { - super.onKeybindPress(keyInputEvent); - if (bugged) return; - - BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getLeft().getProcessor().onKeybindPress(keyInputEvent); - } - } - if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getRight().getProcessor().onKeybindPress(keyInputEvent); - } - } - } - } - - @Override - public void onInteract(PlayerInteractEntityEvent event) { - super.onInteract(event); - if (bugged) return; - - BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getLeft().getProcessor().onInteract(event); - } - } - if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getRight().getProcessor().onInteract(event); - } - } - } - } - - @Override - public void onInteractBlock(PlayerInteractEvent event) { - super.onInteractBlock(event); - if (bugged) return; - - BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - OffsetPoint offsetPoint = new OffsetPoint(getDungeonRoom(), new BlockPos(player.getX(), 68, player.getZ())); - for (ChamberSet ch:chambers) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) { - if (ch.getLeft().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getLeft().getProcessor().onInteractBlock(event); - } - } - if (ch.getRight() != null && ch.getRight().getProcessor() != null) { - if (ch.getRight().getChamberBlocks().getOffsetPointList().contains(offsetPoint)) { - ch.getRight().getProcessor().onInteractBlock(event); - } - } - } - } - - @Override public boolean readGlobalChat() { return true; } - - @Data - @AllArgsConstructor - public static class ChamberSet { - private BDChamber left; - private BDChamber right; - private BombDefuseChamberGenerator chamberGen; - } - - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorBombDefuseSolver createNew(DungeonRoom dungeonRoom) { - RoomProcessorBombDefuseSolver defaultRoomProcessor = new RoomProcessorBombDefuseSolver(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java deleted file mode 100644 index 8063e53f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BDChamber.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.util.BlockPos; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -@AllArgsConstructor -@Data -public class BDChamber { - private DungeonRoom room; - private OffsetPointSet chamberBlocks; - - private boolean isLeft; - private int level; - - private ChamberProcessor processor; - - // for whatever's sake, 6: z, 9: x. Starts from botoom right, left, then up - - public OffsetPoint getOffsetPoint(int x, int z) { - return chamberBlocks.getOffsetPointList().get(z * 9 + x); - } - - public BlockPos getBlockPos(int x, int y, int z) { - return getOffsetPoint(x,z).getBlockPos(room).add(0,y,0); - } - - public IBlockState getBlock(int x, int y, int z) { - BlockPos pos = getBlockPos(x,y,z); - return room.getContext().getWorld().getBlockState(pos); - } - - public boolean isWithinAbsolute(int x, int y, int z) { - return isWithinAbsolute(new BlockPos(x,68,z)); - } - public boolean isWithinAbsolute(BlockPos pos) { - return chamberBlocks.getOffsetPointList().contains(new OffsetPoint(room, new BlockPos(pos.getX(), 68, pos.getZ()))); - } - - - public T getEntityAt(Class entity, int x, int y, int z) { - final BlockPos pos = getBlockPos(x,y,z); - return getEntityAt(entity, pos); - } - public T getEntityAt(Class entity, final BlockPos pos) { - List entities = room.getContext().getWorld().getEntities(entity, new Predicate() { - @Override - public boolean apply(@Nullable T input) { - return input.getPosition().equals(pos); - } - }); - if (entities.size() == 0) return null; - return entities.get(0); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java deleted file mode 100644 index 26dcf724..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/BombDefuseChamberGenerator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; - -public interface BombDefuseChamberGenerator { - boolean match(BDChamber left, BDChamber right); - - String getName(); - - ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver); - ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver); -} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/ChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/ChamberProcessor.java deleted file mode 100644 index 1c6e39da..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/ChamberProcessor.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers; - -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; -import net.minecraft.nbt.NBTTagCompound; - -public interface ChamberProcessor extends RoomProcessor { - void onDataRecieve(NBTTagCompound compound); - String getName(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java deleted file mode 100644 index 7e6010d5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/DummyDefuseChamberProcessor.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers; - -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; - -public class DummyDefuseChamberProcessor extends GeneralDefuseChamberProcessor { - public DummyDefuseChamberProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - } - - @Override - public String getName() { - return "dummy"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java deleted file mode 100644 index 3f8172d2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/GeneralDefuseChamberProcessor.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers; - -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.events.BlockUpdateEvent; -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import lombok.Getter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.IChatComponent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -@Getter -public abstract class GeneralDefuseChamberProcessor implements ChamberProcessor{ - private final RoomProcessorBombDefuseSolver solver; - private final BDChamber chamber; - - public GeneralDefuseChamberProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - this.solver = solver; - this.chamber = chamber; - } - - - @Override - public void onDataRecieve(NBTTagCompound compound) { - - } - - @Override - public void tick() { - - } - - @Override - public void drawScreen(float partialTicks) { - - } - - @Override - public void drawWorld(float partialTicks) { - - } - - @Override - public void chatReceived(IChatComponent chat) { - - } - - @Override - public void onEntityDeath(LivingDeathEvent deathEvent) { - - } - - @Override - public void actionbarReceived(IChatComponent chat) { - - } - @Override - public void onBlockUpdate(BlockUpdateEvent blockUpdateEvent) { - - } - - @Override - public boolean readGlobalChat() { - return false; - } - - @Override - public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { - - } - - @Override - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - - } - - protected void drawPressKey() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - String str = "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.getParameter("key").getValue()) + " to save and send solution"; - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(str, (sr.getScaledWidth() - fr.getStringWidth(str)) / 2, (sr.getScaledHeight() - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - } - - @Override - public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { - if (keyInputEvent.getKey() == FeatureRegistry.SOLVER_BOMBDEFUSE.getParameter("key").getValue()) { - if (!getChamber().isWithinAbsolute(Minecraft.getMinecraft().thePlayer.getPosition())) { - return; - } - onSendData(); - } - } - - @Override - public void onInteract(PlayerInteractEntityEvent event) { - - } - - @Override - public void onInteractBlock(PlayerInteractEvent event) { - - } - - public void onSendData() {} -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java deleted file mode 100644 index 48429e1d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowLeftProcessor.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.arrow; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.BlockPos; - -import java.util.HashMap; -import java.util.Map; - -public class ArrowLeftProcessor extends GeneralDefuseChamberProcessor { - public ArrowLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - - for (int i = 0; i < 9; i++) { - grid[i] = chamber.getBlockPos(7,1 + (i / 3),1 + (i % 3)); - } - } - - @Override - public String getName() { - return "arrowLeft"; - } - - - private int answer = -1; - private final int[] answers = new int[9]; - private final BlockPos[] grid = new BlockPos[9]; - @Override - public void tick() { - super.tick(); - if (answer != -1) return; - for (int i = 0; i < 9; i++) - answers[i] = match(getChamber().getEntityAt(EntityArmorStand.class, grid[i].add(0, -1, 0))); - - answer = 0; - for (int i =0; i < 9; i++) { - answer = answer * 10 + answers[i]; - } - } - - @Override - public void drawScreen(float partialTicks) { - if (answer == -1) return; - drawPressKey(); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - - if (answer == -1) return; - for (int i = 0; i < 9; i++) { - BlockPos pos = grid[i]; - int direction = answers[i]; - String charac = arrows.get(direction); - - RenderUtils.drawTextAtWorld(charac, pos.getX()+ 0.5f, pos.getY()+ 0.5f, pos.getZ()+ 0.5f, 0xFFFFFFFF, 0.05F, false, false, partialTicks); - } - } - - @Override - public void onSendData() { - if (answer == -1) return; - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("a", (byte) 3); - nbt.setInteger("b", answer); - getSolver().communicate(nbt); - } - - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (3 == compound.getByte("a")) { - answer = compound.getInteger("b"); - for (int i = 8; i >= 0; i--) { - answers[i] = answer % 10; - answer = answer / 10; - } - answer = compound.getInteger("b"); - } - } - - private int match(EntityArmorStand armorStand) { - if (armorStand == null) return -1; - ItemStack item = armorStand.getInventory()[4]; - NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); - String str = ((NBTTagCompound)list.get(0)).getString("Value"); - return !integers.containsKey(str) ? -1 : integers.get(str); - } - - private static final BiMap integers = HashBiMap.create(8); - private static final Map arrows = new HashMap(); - { - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDczZTFmZTBmZmNkNTQ2YzIxYjYzZWFhOTEwYWI1YzkzMTMyYTY0ZTY0NDE3OWZjY2FhMjFkYzhiYzY2MCJ9fX0=", 1); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNThmZTI1MWE0MGU0MTY3ZDM1ZDA4MWMyNzg2OWFjMTUxYWY5NmI2YmQxNmRkMjgzNGQ1ZGM3MjM1ZjQ3NzkxZCJ9fX0=", 2); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTc3ZWM0NGZiNzUwM2RlNmFmZTNiZGQ3ZTU4M2M3YjkzOTc5ZjU5ZjZkNjM0YjZiNmE1YWY3ZjNhMWM1ODUxNSJ9fX0=", 3); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjJmM2EyZGZjZTBjM2RhYjdlZTEwZGIzODVlNTIyOWYxYTM5NTM0YThiYTI2NDYxNzhlMzdjNGZhOTNiIn19fQ==", 4); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGUxY2U5YzBkMzMyMzZmOTkyMWQyMmM0ZWM0YmY1MDkyMzdhZWY2NzZiNWQxZDJiYWNjOTNmNWE4MTk0ODAifX19", 5); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWI3Y2U2ODNkMDg2OGFhNDM3OGFlYjYwY2FhNWVhODA1OTZiY2ZmZGFiNmI1YWYyZDEyNTk1ODM3YTg0ODUzIn19fQ==", 6); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTI2NTFlY2QzNzgwY2Y2ZTQ1MWVjYWNjZGVlNjk3MTVjMDhjYWU3Y2Q0NTA5MDg0NDYyY2RjZDk2M2E2YjMyMiJ9fX0=", 7); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmIwZjZlOGFmNDZhYzZmYWY4ODkxNDE5MWFiNjZmMjYxZDY3MjZhNzk5OWM2MzdjZjJlNDE1OWZlMWZjNDc3In19fQ==", 8); - - arrows.put(0, "?"); - arrows.put(1, "โ†–"); - arrows.put(2, "โ†‘"); - arrows.put(3, "โ†—"); - arrows.put(4, "โ†’"); - arrows.put(5, "โ†˜"); - arrows.put(6, "โ†“"); - arrows.put(7, "โ†™"); - arrows.put(8, "โ†"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java deleted file mode 100644 index 1dcb0e1a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowProcessorMatcher.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.arrow; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; -import net.minecraft.init.Blocks; - -public class ArrowProcessorMatcher implements BombDefuseChamberGenerator { - @Override - public boolean match(BDChamber left, BDChamber right) { - return left.getBlock(8,1,1).getBlock() == Blocks.planks && - left.getBlock(8,1,2).getBlock() == Blocks.planks && - left.getBlock(8,1,3).getBlock() == Blocks.planks && - right.getBlock(0,1,1).getBlock() == Blocks.planks && - right.getBlock(0,1,2).getBlock() == Blocks.planks && - right.getBlock(0,1,3).getBlock() == Blocks.planks; - } - - @Override - public String getName() { - return "arrowMatch"; - } - - @Override - public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return new ArrowLeftProcessor(solver, left); - } - - @Override - public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return new ArrowRightProcessor(solver, right); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java deleted file mode 100644 index 88b94794..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/arrow/ArrowRightProcessor.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.arrow; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.BlockPos; - -import java.util.HashMap; -import java.util.Map; - -public class ArrowRightProcessor extends GeneralDefuseChamberProcessor { - public ArrowRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - - for (int i = 0; i < 9; i++) { - grid[i] = chamber.getBlockPos(1,1 + (i / 3),1 + (2 - (i % 3))); - } - - center = chamber.getBlockPos(4,4,4); - } - - @Override - public String getName() { - return "arrowRight"; - } - - - private int answer = -1; - private final int[] correctAnswers = new int[9]; - private final int[] currentAnswers = new int[9]; - private final BlockPos[] grid = new BlockPos[9]; - private final BlockPos center; - @Override - public void tick() { - super.tick(); - for (int i = 0; i < 9; i++) - currentAnswers[i] = match(getChamber().getEntityAt(EntityArmorStand.class, grid[i].add(0, -1, 0))); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - - RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - - for (int i = 0; i < 9; i++) { - BlockPos pos = grid[i]; - int direction = correctAnswers[i]; - int direction2 = currentAnswers[i]; - String charac = arrows.get(direction); - String car2 = arrows.get(direction2); - - RenderUtils.drawTextAtWorld(car2, pos.getX()+ 0.5f, pos.getY()+ 0.6f, pos.getZ()+ 0.5f, direction == direction2 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(charac, pos.getX()+ 0.5f, pos.getY()+ 0.2f, pos.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); - } - } - - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (3 == compound.getByte("a")) { - answer = compound.getInteger("b"); - for (int i = 8; i >= 0; i--) { - correctAnswers[i] = answer % 10; - answer = answer / 10; - } - answer = compound.getInteger("b"); - } - } - - private int match(EntityArmorStand armorStand) { - if (armorStand == null) return -1; - ItemStack item = armorStand.getInventory()[4]; - NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); - String str = ((NBTTagCompound)list.get(0)).getString("Value"); - return !integers.containsKey(str) ? -1 : integers.get(str); - } - - private static final BiMap integers = HashBiMap.create(8); - private static final Map arrows = new HashMap(); - { - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODY1NDI2YTMzZGY1OGI0NjVmMDYwMWRkOGI5YmVjMzY5MGIyMTkzZDFmOTUwM2MyY2FhYjc4ZjZjMjQzOCJ9fX0=", 1); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzA0MGZlODM2YTZjMmZiZDJjN2E5YzhlYzZiZTUxNzRmZGRmMWFjMjBmNTVlMzY2MTU2ZmE1ZjcxMmUxMCJ9fX0=", 2); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTBlMGE0ZDQ4Y2Q4MjlhNmQ1ODY4OTA5ZDY0M2ZhNGFmZmQzOWU4YWU2Y2FhZjZlYzc5NjA5Y2Y3NjQ5YjFjIn19fQ==", 3); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTliZjMyOTJlMTI2YTEwNWI1NGViYTcxM2FhMWIxNTJkNTQxYTFkODkzODgyOWM1NjM2NGQxNzhlZDIyYmYifX19", 4); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzVjYmRiMjg5OTFhMTZlYjJjNzkzNDc0ZWY3ZDBmNDU4YTVkMTNmZmZjMjgzYzRkNzRkOTI5OTQxYmIxOTg5In19fQ==", 5); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzQzNzM0NmQ4YmRhNzhkNTI1ZDE5ZjU0MGE5NWU0ZTc5ZGFlZGE3OTVjYmM1YTEzMjU2MjM2MzEyY2YifX19", 6); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzU0Y2U4MTU3ZTcxZGNkNWI2YjE2NzRhYzViZDU1NDkwNzAyMDI3YzY3NWU1Y2RjZWFjNTVkMmZiYmQ1YSJ9fX0=", 7); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmQ2OWUwNmU1ZGFkZmQ4NGU1ZjNkMWMyMTA2M2YyNTUzYjJmYTk0NWVlMWQ0ZDcxNTJmZGM1NDI1YmMxMmE5In19fQ==", 8); - - - arrows.put(0, "?"); - arrows.put(1, "โ†–"); - arrows.put(2, "โ†‘"); - arrows.put(3, "โ†—"); - arrows.put(4, "โ†’"); - arrows.put(5, "โ†˜"); - arrows.put(6, "โ†“"); - arrows.put(7, "โ†™"); - arrows.put(8, "โ†"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java deleted file mode 100644 index 4ae397e8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/bugged/ImpossibleMatcher.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.bugged; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; -import net.minecraft.init.Blocks; - -public class ImpossibleMatcher implements BombDefuseChamberGenerator { - @Override - public boolean match(BDChamber left, BDChamber right) { - return left.getBlock(1,1,1).getBlock() == Blocks.barrier; - } - - @Override - public String getName() { - return "buggedMazeMatcher"; - } - - @Override - public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return null; - } - - @Override - public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return null; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorLeftProcessor.java deleted file mode 100644 index f7972d95..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorLeftProcessor.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.color; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; -import org.lwjgl.input.Keyboard; -import org.omg.PortableInterceptor.INACTIVE; - -import java.util.HashMap; -import java.util.Map; - -public class ColorLeftProcessor extends GeneralDefuseChamberProcessor { - public ColorLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - center = chamber.getBlockPos(4,6,4); - b1p = chamber.getBlockPos(1,1,4); - b2p = chamber.getBlockPos(4,1,4); - b3p = chamber.getBlockPos(7,1,4); - } - - private final BlockPos center; - - private Block w1, w2, w3, c1, c2, c3; - private final BlockPos b1p; - private final BlockPos b2p; - private final BlockPos b3p; - private int s1, s2, s3; - private int s1t, s2t, s3t; - private boolean solutionBuilt; - - @Override - public String getName() { - return "colorRight"; - } - - @Override - public void tick() { - super.tick(); - if (solutionBuilt) return; - World w = getChamber().getRoom().getContext().getWorld(); - if ((c1 = w.getBlockState(b1p).getBlock()) == w1 && s1t < 7) { - int semi = match(getChamber().getEntityAt(EntityArmorStand.class,b1p.add(0, 1, 0))); - if (s1 == semi) { - s1t++; - } else { - s1 = semi; - s1t = 0; - } - } - if ((c2 = w.getBlockState(b2p).getBlock()) == w2 && s2t < 7) { - int semi = match(getChamber().getEntityAt(EntityArmorStand.class,b2p.add(0, 2, 0))); - if (s2 == semi) { - s2t++; - } else { - s2 = semi; - s2t = 0; - } - } - if ((c3 =w.getBlockState(b3p).getBlock()) == w3 && s3t < 7) { - int semi = match(getChamber().getEntityAt(EntityArmorStand.class,b3p.add(0, 1, 0))); - if (s3== semi) { - s3t++; - } else { - s3 = semi; - s3t = 0; - } - } - - if (s1t > 5 && s2t > 5 && s3t > 5) { - solutionBuilt = true; - } - } - - @Override - public void drawScreen(float partialTicks) { - super.drawScreen(partialTicks); - if (solutionBuilt) - drawPressKey(); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(w1 == null ? "Request Not Received Yet" : "Building- "+w1.getLocalizedName() +" / "+w2.getLocalizedName() +" / "+w3.getLocalizedName() , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - - RenderUtils.drawTextAtWorld(w1 == null ? "null" : w1.getLocalizedName(), b1p.getX()+ 0.5f, b1p.getY() + 0.2f, b1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(w2 == null ? "null" : w2.getLocalizedName(), b2p.getX()+ 0.5f, b2p.getY() + 0.2f, b2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(w3 == null ? "null" : w3.getLocalizedName(), b3p.getX()+ 0.5f, b3p.getY() + 0.2f, b3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(c1 == null ? "null" : c1.getLocalizedName(), b1p.getX()+ 0.5f, b1p.getY() + 0.6f, b1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(c2 == null ? "null" : c2.getLocalizedName(), b2p.getX()+ 0.5f, b2p.getY() + 0.6f, b2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(c3 == null ? "null" : c3.getLocalizedName(), b3p.getX()+ 0.5f, b3p.getY() + 0.6f, b3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - - if (FeatureRegistry.DEBUG.isEnabled()) { - RenderUtils.drawTextAtWorld(s1 + "", b1p.getX() + 0.5f, b1p.getY() + 2.6f, b1p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(s2 + "", b2p.getX() + 0.5f, b2p.getY() + 3.6f, b2p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(s3 + "", b3p.getX() + 0.5f, b3p.getY() + 2.6f, b3p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - } - - RenderUtils.drawTextAtWorld(colors.get(s1), b1p.getX()+ 0.5f, b1p.getY() + 2.2f, b1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(colors.get(s2), b2p.getX()+ 0.5f, b2p.getY() + 3.2f, b2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(colors.get(s3), b3p.getX()+ 0.5f, b3p.getY() + 2.2f, b3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - - if (FeatureRegistry.DEBUG.isEnabled()) { - RenderUtils.drawTextAtWorld(s1t + "", b1p.getX() + 0.5f, b1p.getY() + 1.5f, b1p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(s2t + "", b2p.getX() + 0.5f, b2p.getY() + 2f, b2p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(s3t + "", b3p.getX() + 0.5f, b3p.getY() + 1.5f, b3p.getZ() + 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - } - } - - @Override - public void onSendData() { - super.onSendData(); - if (!solutionBuilt) return; - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("a", (byte) 7); - int answer = s1 * 10000 + s2 * 100 + s3; - nbt.setInteger("b", answer); - getSolver().communicate(nbt); - } - - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (6 == compound.getByte("a")) { - w1 = Block.getBlockById(compound.getByte("f")); - w2 = Block.getBlockById(compound.getByte("s")); - w3 = Block.getBlockById(compound.getByte("t")); - solutionBuilt = false; - s1 = s2 = s3 = s1t = s2t = s3t =0; - } - } - - private byte match(EntityArmorStand armorStand) { - if (armorStand == null) { - return 0; - } - ItemStack item = armorStand.getInventory()[4]; - NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); - String str = ((NBTTagCompound)list.get(0)).getString("Value"); - return (byte) (!integers.containsKey(str) ? 0 : integers.get(str)); - } - - private static final Map integers = new HashMap(); - private static final BiMap colors = HashBiMap.create(); - static { - colors.put(0, "?"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2YzZTQwNjI5MTE3NGQyNGNkZjBmOTUzZjhhMTc0YTgyYmIzNDg5ZGNlOGY2NzlhNDQzZWYxYWFlMDE2OTA2MSJ9fX0=", 1); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWE4MWZjYjUxYmUyYTlmODliMWFkYzlkODcyMzliYTQyOWQ2MzVmYmUwMWIzN2VjMzI5MTY0ODg3YmY2NjViIn19fQ==", 1); - colors.put(1, "blue"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2FiMDI2M2JkZDc2ZjNlNDE4ZGJhNWJmNDgxYjkyMWNlZDM5N2Q4YjhhMzRhNTU2MWZiN2JlYWE0NmVjZTEifX19", 2); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2ZhNGRkYTZkMTlhMWZlMmQ5ODhkNjVkZWM1MzQyOTUwNTMwODE2NmM5MDY3YjY4YTQ3NzBjYTVjNDM2Y2Y5NCJ9fX0=", 2); - colors.put(2, "black"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDg0Njg0MzQ0YWUwOTg1MjlmYzk0MWFhODRlMTk1YmRjYTM3NDhkNjlhY2ZlZTJiYWMxMzMyMTM1ZWRkOThjIn19fQ==", 3); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTM1ODFjMmY5Y2YzNThkN2VkYzc4ZGQ2ZmQ0YjYyNTc1MDFiYzRlNjQ1NWUzM2ZhMGNhYWUyMDdjZjAzMjFhMiJ9fX0=", 3); - colors.put(3, "green"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTllNjkxN2YyZmI0ZWEwOGU3MTMyZGYzMDk2MWQyYjVjNTIzYWJiYTE5Y2U0M2Y4MzVmYzE0YzU2OGY0In19fQ==", 4); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWRmMjFmNTMyMTIyNTY2YWY4OTNkYTI3ODgwYTFiNjA5NWMzNTcxMmYyOWEzNzhjZmVjYzdmZTJiMTMyOGFiNCJ9fX0=", 4); - colors.put(4, "gray"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODhlZmFkNzRiMjU0ZTU3Yzc5OTc2M2RjZWVlNDUxMWZhMmY4NWFlOWZhNTU2ZWFhOTdkNDViZjY3ZTBiNmIzIn19fQ==", 5); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWZhZGY3NDFhYjc2Y2QzNjIwYWQxNjEzMDAyMDJkN2I1OWEzMzA1MWU1OTY3ZTRiNjE5NGJhYzQwYmIyODBmZiJ9fX0=", 5); - colors.put(5, "cyan"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzJlMzZmNmE2NTRkZTc0NTgzZDgwMzAxNzdhZDZlM2FjNjc1NWQ3NDM1ZDkxMjNlOGViZGZmNzRiMmQ5MGNiIn19fQ==", 6); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjJjYmQ5ZjQzNjE5YWI1Y2IxYjExZjkxY2IwM2U5NTVjNmZjNmM0NThhYmY4OWFiNjEwMzEzNDZhMDkwNjEyZSJ9fX0=", 6); - colors.put(6, "brown"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjFhZjQ2ZmViZDQ1YzBmNGQ4MWU4ZmExYjY2YjI3NWQ4OWUyNzJiMmFkNTVjOTc4NTUzYTk5YzczM2UxZmYifX19", 7); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYzZTY2NDZmMWMwZDQxZmQzYmY1NTg0YTFjZTA0NGY1YzQ2ZDU5ODI1OGRiNDYyMTYxMTc4NTlmNTdhZjE5NyJ9fX0=", 7); - colors.put(7, "light-blue"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDY3NDcwYTBjMThmNjg1MWU5MTQzNTM3MTllNzk1ODc3ZDI5YjMyNTJmN2U2YmQ0YTFiODY1NzY1YmQ3NGZlYiJ9fX0=", 8); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzc0NzJkNjA4ODIxZjQ1YTg4MDUzNzZlYzBjNmZmY2I3ODExNzgyOWVhNWY5NjAwNDFjMmEwOWQxMGUwNGNiNCJ9fX0=", 8); - colors.put(8, "lime"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWJiNDM4NmJjZGE4NGUzNTNjMzFkNzc4ZDNiMTFiY2QyNmZlYTQ5NGRkNjM0OTZiOGE4MmM3Yzc4YTRhZCJ9fX0=", 9); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjk3MDEyZWQ2YTkyYjA1ZWEwZjE5NDk1MDc0ODU0NGUwNzViYWEyODc4MWNhMzczZDFiMjdlMjhjMjY5NTNjIn19fQ==", 9); - colors.put(9, "magenta"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2JmNzc5N2EyNGE2YWY4NzVmNWM4MjcxYzViOGM0MjVlMTlmMzcyYTQxNWUwNTUyZmMyNDc3NjNmMjg1OWQxIn19fQ==", 10); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWRmMmViMjA1YTIzYzExOTZiM2VjZjIxZTY4YzA3NmI2OTZlNzYxNjNhYzhmYzRmYjlmNTMxOGMyYTVlNWIxYSJ9fX0=", 10); - colors.put(10, "orange"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmJlY2ZiMzg3OTkzNmI4OTllNDIwYmZjZDNhNzRmOGExYmY5ZGQ1NGM1OGVjN2ZiOWY4MWQ5YTVkOTg4ZSJ9fX0=", 11); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4ODM2NTBlYTkyOWRiMGVhYmRmNWJjNzU1OTlkOGVmMDBkNzAzNDBjZDFjZTVlMDRhZDk1ZWY4ZWQ4M2I3MyJ9fX0=", 11); - colors.put(11, "pink"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmE5NGNiMjVkZTYyOGNhMzU5YjJmNmVhNWE4ODY4Y2JlMjY1OTVlZWRiMmJmZmI3NTA5NjdhZDFlZTE4NTAifX19", 12); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODllYzVhMzAyMjJkMDY1OWIwZGJlZTg0NGI4ZjUzZWFlNjJmZTk1YjRhMzQ0OGE5ZWY3OTBhN2FlZGIyOTZkOSJ9fX0=", 12); - colors.put(12, "purple"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODZkMzVhOTYzZDU5ODc4OTRiNmJjMjE0ZTMyOGIzOWNkMjM4MjQyNmZmOWM4ZTA4MmIwYjZhNmUwNDRkM2EzIn19fQ==", 13); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjk1M2IxMmEwOTQ2YjYyOWI0YzA4ODlkNDFmZDI2ZWQyNmZiNzI5ZDRkNTE0YjU5NzI3MTI0YzM3YmI3MGQ4ZCJ9fX0=", 13); - colors.put(13, "red"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTk4YmEyYjM3NGNmYzg5NDU0YzFiOGMzMmRiNDU4YTI3MDY3NTQzOWE0OTU0OTZjOTY3NzFjOTg5MTE2MTYyIn19fQ==", 14); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTUyODhkZGM5MTFhNzVmNzdjM2E1ZDMzNjM2NWE4ZjhiMTM5ZmE1MzkzMGI0YjZlZTEzOTg3NWM4MGNlMzY2YyJ9fX0=", 14); - colors.put(14, "light-gray"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2ZhZjRjMjlmMWU3NDA1ZjQ2ODBjNWMyYjAzZWY5Mzg0ZjFhZWNmZTI5ODZhZDUwMTM4YzYwNWZlZmZmMmYxNSJ9fX0=", 15); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4ZGY2MGM1MTA3NGVlZjI1NDRmZjM4Y2VhZDllMTY2NzVhZTQyNTE5MTYxMDUxODBlMWY4Y2UxOTdhYjNiYyJ9fX0=", 15); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTVhZDkzZDU2NTQ2ZjEyZDUzNTZlZmZjYmM2ZWM0Yzg3YmEyNDVkODFlMTY2MmM0YjgzMGY3ZDI5OGU5In19fQ==", 15); - colors.put(15, "white"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDRiMDM3OTRiOWIzZTNiNWQwN2UzYmU2OGI5NmFmODdkZjIxNWMzNzUyZTU0NzM2YzgwZjdkNTBiZDM0MzdhNCJ9fX0=", 16); - colors.put(16, "rainbow"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkxMjdjYjdiZDNhOTg5ZDcyYzJlNWM0MjZlMWNjMTQ0NmI1ZTZkZTc0MTRkNDI3ODNmMmZlNmJhZGIxNzdkNCJ9fX0=", 17); - colors.put(17, "lilac"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkxMjdjYjdiZDNhOTg5ZDcyYzJlNWM0MjZlMWNjMTQ0NmI1ZTZkZTc0MTRkNDI3ODNmMmZlNmJhZGIxNzdkNCJ9fX0=", 18); - colors.put(18, "dark-red"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzM4NmY5YjBiMWQ5ODc5YzNkYTMzYzdhOGNhMjQ0MGMxZTQxMWZlOTNjMjdjOWRiYmZmNTZiZDY5N2JiNzM3NSJ9fX0=", 19); - colors.put(19, "i-rainbow"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjdiYmQwYjI5MTFjOTZiNWQ4N2IyZGY3NjY5MWE1MWI4YjEyYzZmZWZkNTIzMTQ2ZDhhYzVlZjFiOGVlIn19fQ==", 20); - colors.put(20, "yellow"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java deleted file mode 100644 index fdd78a9f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorProcessorMatcher.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.color; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; -import net.minecraft.init.Blocks; - -public class ColorProcessorMatcher implements BombDefuseChamberGenerator { - @Override - public boolean match(BDChamber left, BDChamber right) { - return - right.getBlock(0,1,1).getBlock() == Blocks.stonebrick && - right.getBlock(0,1,2).getBlock() == Blocks.stonebrick && - right.getBlock(0,1,3).getBlock() == Blocks.stonebrick; - } - - @Override - public String getName() { - return "colorMatch"; - } - @Override - public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return new ColorLeftProcessor(solver,left); - } - - @Override - public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return new ColorRightProcessor(solver,right); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java deleted file mode 100644 index d5589cfc..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.color; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.BlockPos; -import org.lwjgl.input.Keyboard; - -import java.util.HashMap; -import java.util.Map; - -public class ColorRightProcessor extends GeneralDefuseChamberProcessor { - public ColorRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - center = chamber.getBlockPos(4,4,4); - b1 = chamber.getBlockPos(1,3,3); - b2 = chamber.getBlockPos(1,3,2); - b3 = chamber.getBlockPos(1,3,1); - } - - private final BlockPos center; - - private final BlockPos b1; - private final BlockPos b2; - private final BlockPos b3; - private byte b1b = 0, b2b = 0, b3b = 0, c1b, c2b, c3b; - private int answer = -1; - - @Override - public String getName() { - return "colorRight"; - } - - @Override - public void tick() { - super.tick(); - c1b = match(getChamber().getEntityAt(EntityArmorStand.class,b1.add(0, -1, 0))); - c2b = match(getChamber().getEntityAt(EntityArmorStand.class,b2.add(0, -1, 0))); - c3b = match(getChamber().getEntityAt(EntityArmorStand.class,b3.add(0, -1, 0))); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(answer == -1 ? "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.getParameter("key").getValue()) +" to request solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld( colors.get((int) c1b), b1.getX()+ 0.5f, b1.getY()+0.6f, b1.getZ()+ 0.5f,c1b == b1b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld( colors.get((int) c2b), b2.getX()+ 0.5f, b2.getY()+0.6f, b2.getZ()+ 0.5f,c2b == b2b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld( colors.get((int) c3b), b3.getX()+ 0.5f, b3.getY()+0.6f, b3.getZ()+ 0.5f,c3b == b3b ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); - - RenderUtils.drawTextAtWorld( colors.get((int) b1b), b1.getX()+ 0.5f, b1.getY()+0.2f, b1.getZ()+ 0.5f,0xFFFFFF00, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld( colors.get((int) b2b), b2.getX()+ 0.5f, b2.getY()+0.2f, b2.getZ()+ 0.5f,0xFFFFFF00, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld( colors.get((int) b3b), b3.getX()+ 0.5f, b3.getY()+0.2f, b3.getZ()+ 0.5f,0xFFFFFF00, 0.03F, false, false, partialTicks); - } - - @Override - public void onSendData() { - super.onSendData(); - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("a", (byte) 6); - nbt.setByte("f", (byte) Block.getIdFromBlock(getChamber().getBlock(0,3,3).getBlock())); - nbt.setByte("s", (byte) Block.getIdFromBlock(getChamber().getBlock(0,3,2).getBlock())); - nbt.setByte("t", (byte) Block.getIdFromBlock(getChamber().getBlock(0,3,1).getBlock())); - getSolver().communicate(nbt); - } - - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (7 == compound.getByte("a")) { - answer = compound.getInteger("b"); - b3b = (byte) (answer / 10000); - b2b = (byte) ((answer % 10000) / 100); - b1b = (byte) (answer % 100); - - } - } - - private byte match(EntityArmorStand armorStand) { - if (armorStand == null) { - return 0; - } - ItemStack item = armorStand.getInventory()[4]; - NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); - String str = ((NBTTagCompound)list.get(0)).getString("Value"); - return (byte) (!integers.containsKey(str) ? 0 : integers.get(str)); - } - - private static final Map integers = new HashMap(); - private static final BiMap colors = HashBiMap.create(); - static { - colors.put(0, "?"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2YzZTQwNjI5MTE3NGQyNGNkZjBmOTUzZjhhMTc0YTgyYmIzNDg5ZGNlOGY2NzlhNDQzZWYxYWFlMDE2OTA2MSJ9fX0=", 1); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWE4MWZjYjUxYmUyYTlmODliMWFkYzlkODcyMzliYTQyOWQ2MzVmYmUwMWIzN2VjMzI5MTY0ODg3YmY2NjViIn19fQ==", 1); - colors.put(1, "blue"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2FiMDI2M2JkZDc2ZjNlNDE4ZGJhNWJmNDgxYjkyMWNlZDM5N2Q4YjhhMzRhNTU2MWZiN2JlYWE0NmVjZTEifX19", 2); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2ZhNGRkYTZkMTlhMWZlMmQ5ODhkNjVkZWM1MzQyOTUwNTMwODE2NmM5MDY3YjY4YTQ3NzBjYTVjNDM2Y2Y5NCJ9fX0=", 2); - colors.put(2, "black"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDg0Njg0MzQ0YWUwOTg1MjlmYzk0MWFhODRlMTk1YmRjYTM3NDhkNjlhY2ZlZTJiYWMxMzMyMTM1ZWRkOThjIn19fQ==", 3); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTM1ODFjMmY5Y2YzNThkN2VkYzc4ZGQ2ZmQ0YjYyNTc1MDFiYzRlNjQ1NWUzM2ZhMGNhYWUyMDdjZjAzMjFhMiJ9fX0=", 3); - colors.put(3, "green"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTllNjkxN2YyZmI0ZWEwOGU3MTMyZGYzMDk2MWQyYjVjNTIzYWJiYTE5Y2U0M2Y4MzVmYzE0YzU2OGY0In19fQ==", 4); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWRmMjFmNTMyMTIyNTY2YWY4OTNkYTI3ODgwYTFiNjA5NWMzNTcxMmYyOWEzNzhjZmVjYzdmZTJiMTMyOGFiNCJ9fX0=", 4); - colors.put(4, "gray"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODhlZmFkNzRiMjU0ZTU3Yzc5OTc2M2RjZWVlNDUxMWZhMmY4NWFlOWZhNTU2ZWFhOTdkNDViZjY3ZTBiNmIzIn19fQ==", 5); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWZhZGY3NDFhYjc2Y2QzNjIwYWQxNjEzMDAyMDJkN2I1OWEzMzA1MWU1OTY3ZTRiNjE5NGJhYzQwYmIyODBmZiJ9fX0=", 5); - colors.put(5, "cyan"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzJlMzZmNmE2NTRkZTc0NTgzZDgwMzAxNzdhZDZlM2FjNjc1NWQ3NDM1ZDkxMjNlOGViZGZmNzRiMmQ5MGNiIn19fQ==", 6); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjJjYmQ5ZjQzNjE5YWI1Y2IxYjExZjkxY2IwM2U5NTVjNmZjNmM0NThhYmY4OWFiNjEwMzEzNDZhMDkwNjEyZSJ9fX0=", 6); - colors.put(6, "brown"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjFhZjQ2ZmViZDQ1YzBmNGQ4MWU4ZmExYjY2YjI3NWQ4OWUyNzJiMmFkNTVjOTc4NTUzYTk5YzczM2UxZmYifX19", 7); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTYzZTY2NDZmMWMwZDQxZmQzYmY1NTg0YTFjZTA0NGY1YzQ2ZDU5ODI1OGRiNDYyMTYxMTc4NTlmNTdhZjE5NyJ9fX0=", 7); - colors.put(7, "light-blue"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDY3NDcwYTBjMThmNjg1MWU5MTQzNTM3MTllNzk1ODc3ZDI5YjMyNTJmN2U2YmQ0YTFiODY1NzY1YmQ3NGZlYiJ9fX0=", 8); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzc0NzJkNjA4ODIxZjQ1YTg4MDUzNzZlYzBjNmZmY2I3ODExNzgyOWVhNWY5NjAwNDFjMmEwOWQxMGUwNGNiNCJ9fX0=", 8); - colors.put(8, "lime"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWJiNDM4NmJjZGE4NGUzNTNjMzFkNzc4ZDNiMTFiY2QyNmZlYTQ5NGRkNjM0OTZiOGE4MmM3Yzc4YTRhZCJ9fX0=", 9); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjk3MDEyZWQ2YTkyYjA1ZWEwZjE5NDk1MDc0ODU0NGUwNzViYWEyODc4MWNhMzczZDFiMjdlMjhjMjY5NTNjIn19fQ==", 9); - colors.put(9, "magenta"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2JmNzc5N2EyNGE2YWY4NzVmNWM4MjcxYzViOGM0MjVlMTlmMzcyYTQxNWUwNTUyZmMyNDc3NjNmMjg1OWQxIn19fQ==", 10); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWRmMmViMjA1YTIzYzExOTZiM2VjZjIxZTY4YzA3NmI2OTZlNzYxNjNhYzhmYzRmYjlmNTMxOGMyYTVlNWIxYSJ9fX0=", 10); - colors.put(10, "orange"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmJlY2ZiMzg3OTkzNmI4OTllNDIwYmZjZDNhNzRmOGExYmY5ZGQ1NGM1OGVjN2ZiOWY4MWQ5YTVkOTg4ZSJ9fX0=", 11); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4ODM2NTBlYTkyOWRiMGVhYmRmNWJjNzU1OTlkOGVmMDBkNzAzNDBjZDFjZTVlMDRhZDk1ZWY4ZWQ4M2I3MyJ9fX0=", 11); - colors.put(11, "pink"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmE5NGNiMjVkZTYyOGNhMzU5YjJmNmVhNWE4ODY4Y2JlMjY1OTVlZWRiMmJmZmI3NTA5NjdhZDFlZTE4NTAifX19", 12); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODllYzVhMzAyMjJkMDY1OWIwZGJlZTg0NGI4ZjUzZWFlNjJmZTk1YjRhMzQ0OGE5ZWY3OTBhN2FlZGIyOTZkOSJ9fX0=", 12); - colors.put(12, "purple"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODZkMzVhOTYzZDU5ODc4OTRiNmJjMjE0ZTMyOGIzOWNkMjM4MjQyNmZmOWM4ZTA4MmIwYjZhNmUwNDRkM2EzIn19fQ==", 13); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjk1M2IxMmEwOTQ2YjYyOWI0YzA4ODlkNDFmZDI2ZWQyNmZiNzI5ZDRkNTE0YjU5NzI3MTI0YzM3YmI3MGQ4ZCJ9fX0=", 13); - colors.put(13, "red"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTk4YmEyYjM3NGNmYzg5NDU0YzFiOGMzMmRiNDU4YTI3MDY3NTQzOWE0OTU0OTZjOTY3NzFjOTg5MTE2MTYyIn19fQ==", 14); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTUyODhkZGM5MTFhNzVmNzdjM2E1ZDMzNjM2NWE4ZjhiMTM5ZmE1MzkzMGI0YjZlZTEzOTg3NWM4MGNlMzY2YyJ9fX0=", 14); - colors.put(14, "light-gray"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2ZhZjRjMjlmMWU3NDA1ZjQ2ODBjNWMyYjAzZWY5Mzg0ZjFhZWNmZTI5ODZhZDUwMTM4YzYwNWZlZmZmMmYxNSJ9fX0=", 15); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4ZGY2MGM1MTA3NGVlZjI1NDRmZjM4Y2VhZDllMTY2NzVhZTQyNTE5MTYxMDUxODBlMWY4Y2UxOTdhYjNiYyJ9fX0=", 15); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTVhZDkzZDU2NTQ2ZjEyZDUzNTZlZmZjYmM2ZWM0Yzg3YmEyNDVkODFlMTY2MmM0YjgzMGY3ZDI5OGU5In19fQ==", 15); - colors.put(15, "white"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDRiMDM3OTRiOWIzZTNiNWQwN2UzYmU2OGI5NmFmODdkZjIxNWMzNzUyZTU0NzM2YzgwZjdkNTBiZDM0MzdhNCJ9fX0=", 16); - colors.put(16, "rainbow"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkxMjdjYjdiZDNhOTg5ZDcyYzJlNWM0MjZlMWNjMTQ0NmI1ZTZkZTc0MTRkNDI3ODNmMmZlNmJhZGIxNzdkNCJ9fX0=", 17); - colors.put(17, "lilac"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkxMjdjYjdiZDNhOTg5ZDcyYzJlNWM0MjZlMWNjMTQ0NmI1ZTZkZTc0MTRkNDI3ODNmMmZlNmJhZGIxNzdkNCJ9fX0=", 18); - colors.put(18, "dark-red"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzM4NmY5YjBiMWQ5ODc5YzNkYTMzYzdhOGNhMjQ0MGMxZTQxMWZlOTNjMjdjOWRiYmZmNTZiZDY5N2JiNzM3NSJ9fX0=", 19); - colors.put(19, "i-rainbow"); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjdiYmQwYjI5MTFjOTZiNWQ4N2IyZGY3NjY5MWE1MWI4YjEyYzZmZWZkNTIzMTQ2ZDhhYzVlZjFiOGVlIn19fQ==", 20); - colors.put(20, "yellow"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java deleted file mode 100644 index 32b48478..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperLeftProcessor.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.BlockPos; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.awt.*; -import java.util.BitSet; - -public class CreeperLeftProcessor extends GeneralDefuseChamberProcessor { - public CreeperLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - - poses = new BlockPos[9]; - for (int i = 0; i < 9; i++) { - poses[i] = chamber.getBlockPos(3+(i%3), 1, 1+(i/3)); - } - } - - @Override - public String getName() { - return "creeperLeft"; - } - - - private int answer = -1; - private final BlockPos[] poses; - @Override - public void tick() { - super.tick(); - if (answer != -1) return; - answer = 0; - for (int i = 0; i < poses.length; i++) { - BlockPos pos = poses[i]; - if (getChamber().getRoom().getContext().getWorld().getBlockState(pos).getBlock() == Blocks.air) { - answer |= (1 << i); - } - } - } - - @Override - public void drawScreen(float partialTicks) { - if (answer == -1) return; - drawPressKey(); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - for (int i = 0; i < 9; i++) { - if (((answer >> i) & 0x01) != 0) { - RenderUtils.highlightBlock(poses[i], new Color(255,0,0,100), partialTicks, false); - } else { - RenderUtils.highlightBlock(poses[i], new Color(0,255,0,100), partialTicks, false); - } - } - } - - @Override - public void onSendData() { - if (answer == -1) return; - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("a", (byte) 2); - nbt.setInteger("b", answer); - getSolver().communicate(nbt); - } - - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (2 == compound.getByte("a")) { - answer = compound.getInteger("b"); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java deleted file mode 100644 index 4b72d364..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperProcessorMatcher.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; -import net.minecraft.init.Blocks; - -public class CreeperProcessorMatcher implements BombDefuseChamberGenerator { - @Override - public boolean match(BDChamber left, BDChamber right) { - int airs = 0; - for (int x = 0; x < 3; x ++) { - for (int y = 0; y < 3; y++) { - if (right.getBlock(3 + x, 1, y + 1).getBlock() != Blocks.stone) return false; - } - } - return true; - } - - @Override - public String getName() { - return "creeperMatch"; - } - @Override - public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return new CreeperLeftProcessor(solver, left); - } - - @Override - public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return new CreeperRightProcessor(solver, right); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java deleted file mode 100644 index 82479c6b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/creeper/CreeperRightProcessor.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.awt.*; - -public class CreeperRightProcessor extends GeneralDefuseChamberProcessor { - public CreeperRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - - poses = new BlockPos[9]; - for (int i = 0; i < 9; i++) { - poses[i] = chamber.getBlockPos(3+(i%3), 1, 1+(i/3)); - } - center = chamber.getBlockPos(4,4,4); - } - - @Override - public String getName() { - return "creeperRight"; - } - - - private int answer = -1; - private final BlockPos[] poses; - private final BlockPos center; - @Override - public void tick() { - super.tick(); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - if (answer != -1) { - for (int i = 0; i < 9; i++) { - if (((answer >> i) & 0x01) == 0) { - RenderUtils.highlightBlock(poses[i], new Color(0,255,0, 50), partialTicks, false); - } - } - } - } - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (2 == compound.getByte("a")) { - answer = compound.getInteger("b"); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java deleted file mode 100644 index f0fd566f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathLeftProcessor.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; - -import javax.vecmath.Vector2f; -import java.awt.*; -import java.util.*; -import java.util.List; - -public class GoldenPathLeftProcessor extends GeneralDefuseChamberProcessor { - public GoldenPathLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - - } - - @Override - public String getName() { - return "goldenPathLeft"; - } - - - // 1 up 2 right 3 down 4 left - private static final Point[] vectors = new Point[] { - new Point(0,1), - new Point(-1,0), - new Point(0, -1), - new Point(1, 0) - }; - - private final LinkedList blocksolution = new LinkedList(); - private String goldenPathsolution; - @Override - public void tick() { - super.tick(); - if (goldenPathsolution != null) return; - - List solution = new ArrayList(); - Set visited = new HashSet(); - BlockPos lastLoc = new BlockPos(4,0,0); - visited.add(lastLoc); - blocksolution.add(getChamber().getBlockPos(4,1,0)); - BlockPos target = new BlockPos(4,0,5); - while (!lastLoc.equals(target)) { - boolean solution2 = false; - for (int i =0; i 8 || target2.getZ() > 5) continue; - - visited.add(target2); - if (getChamber().getBlock(target2.getX(), 0, target2.getZ()).getBlock() == Blocks.hardened_clay - || getChamber().getBlock(target2.getX(), 0, target2.getZ()).getBlock() == Blocks.stained_hardened_clay) { - lastLoc = target2; - - blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); - solution.add(i); - solution2 = true; - break; - } - } - if (!solution2){ - return; - } - } - - goldenPathsolution = ""; - for (Integer i:solution) - goldenPathsolution += i; - } - - @Override - public void drawScreen(float partialTicks) { - if (goldenPathsolution == null) return; - drawPressKey(); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - RenderUtils.drawLines(blocksolution, new AColor(0,0,255,0), 1,partialTicks, false); - } - - @Override - public void onSendData() { - if (goldenPathsolution == null) return; - Minecraft.getMinecraft().thePlayer.sendChatMessage("/pc $DG-BDGP "+goldenPathsolution); - - ChatComponentText text = new ChatComponentText("$DG-BDGP "+goldenPathsolution); - for (RoomProcessorBombDefuseSolver.ChamberSet ch: getSolver().getChambers()) { - if (ch.getLeft() != null && ch.getLeft().getProcessor() != null) - ch.getLeft().getProcessor().chatReceived(text); - if (ch.getRight() != null && ch.getRight().getProcessor() != null) - ch.getRight().getProcessor().chatReceived(text); - } - } - - @Override - public void chatReceived(IChatComponent chat) { - super.chatReceived(chat); - if (chat.getFormattedText().contains("$DG-BDGP ")) { - String data = chat.getFormattedText().substring(chat.getFormattedText().indexOf("$DG-BDGP ")); - String actual = TextUtils.stripColor(data).trim().split(" ")[1].trim(); - - blocksolution.clear(); - BlockPos lastLoc = new BlockPos(4,0,0); - blocksolution.addFirst(getChamber().getBlockPos(4,1,0)); - for (Character c:actual.toCharArray()) { - int dir = Integer.parseInt(c+"") % 4; - lastLoc = lastLoc.add(vectors[dir].x, 0, vectors[dir].y); - blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java deleted file mode 100644 index ce2a6077..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathProcessorMatcher.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper.CreeperLeftProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.creeper.CreeperRightProcessor; -import net.minecraft.init.Blocks; - -public class GoldenPathProcessorMatcher implements BombDefuseChamberGenerator { - @Override - public boolean match(BDChamber left, BDChamber right) { - return left.getBlock(4,0,0).getBlock() == Blocks.hardened_clay - || left.getBlock(4,0,0).getBlock() == Blocks.stained_hardened_clay; - } - - @Override - public String getName() { - return "goldPath"; - } - @Override - public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return new GoldenPathLeftProcessor(solver, left); - } - - @Override - public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return new GoldenPathRightProcessor(solver, right); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java deleted file mode 100644 index 8028609f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/goldenpath/GoldenPathRightProcessor.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.List; -import java.util.*; - -public class GoldenPathRightProcessor extends GeneralDefuseChamberProcessor { - public GoldenPathRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - - center = chamber.getBlockPos(4,4,4); - } - - @Override - public String getName() { - return "goldenPathRight"; - } - - - private final BlockPos center; - // 1 up 2 right 3 down 4 left - private static final Point[] vectors = new Point[] { - new Point(0,1), - new Point(-1,0), - new Point(0, -1), - new Point(1, 0) - }; - - private final LinkedList blocksolution = new LinkedList(); - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(blocksolution.size() == 0 ? "Answer not received yet. Visit left room to obtain solution" : "" , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - - RenderUtils.drawLines(blocksolution, new AColor(0,0,255,0),1, partialTicks, false); - - } - - @Override - public void chatReceived(IChatComponent chat) { - super.chatReceived(chat); - if (chat.getFormattedText().contains("$DG-BDGP ")) { - String data = chat.getFormattedText().substring(chat.getFormattedText().indexOf("$DG-BDGP")); - String actual = TextUtils.stripColor(data).trim().split(" ")[1].trim(); - - blocksolution.clear(); - BlockPos lastLoc = new BlockPos(4,0,0); - blocksolution.addFirst(getChamber().getBlockPos(4,1,0)); - for (Character c:actual.toCharArray()) { - int dir = Integer.parseInt(c+"") % 4; - lastLoc = lastLoc.add(vectors[dir].x, 0, vectors[dir].y); - blocksolution.add(getChamber().getBlockPos(lastLoc.getX(), 1, lastLoc.getZ())); - } - - World w = getChamber().getRoom().getContext().getWorld(); - for (int x = 0; x <9; x++) { - for (int z =0; z < 6; z++) { - BlockPos pos = getChamber().getBlockPos(x,1,z); - if (blocksolution.contains(pos)) { - w.setBlockState(pos, Blocks.light_weighted_pressure_plate.getDefaultState()); - } else { - w.setBlockState(pos, Blocks.wooden_pressure_plate.getDefaultState()); - } - } - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java deleted file mode 100644 index 77c8134b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeLeftProcessor.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze; - -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MovingObjectPosition; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -public class MazeLeftProcessor extends GeneralDefuseChamberProcessor { - public MazeLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - } - - @Override - public String getName() { - return "mazeLeft"; - } - - - @Override - public void drawScreen(float partialTicks) { - if (Minecraft.getMinecraft().objectMouseOver == null ) return; - MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; - if (pos.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return; - - BlockPos block = pos.getBlockPos(); - Block b = getChamber().getRoom().getContext().getWorld().getBlockState(block).getBlock(); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - String str = "Press "+ GameSettings.getKeyDisplayString(FeatureRegistry.SOLVER_BOMBDEFUSE.getParameter("key").getValue()) + " to request open "+b.getLocalizedName(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString(str, (sr.getScaledWidth() - fr.getStringWidth(str)) / 2, (sr.getScaledHeight() - fr.FONT_HEIGHT) / 2, 0xFFFFFFFF); - } - - @Override - public void onSendData() { - if (Minecraft.getMinecraft().objectMouseOver == null ) return; - MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver; - if (pos.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return; - - BlockPos block = pos.getBlockPos(); - Block b = getChamber().getRoom().getContext().getWorld().getBlockState(block).getBlock(); - - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("a", (byte) 5); - nbt.setInteger("b", Block.getIdFromBlock(b)); - getSolver().communicate(nbt); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java deleted file mode 100644 index 9a4bddbd..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeProcessorMatcher.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath.GoldenPathLeftProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.goldenpath.GoldenPathRightProcessor; -import net.minecraft.init.Blocks; - -public class MazeProcessorMatcher implements BombDefuseChamberGenerator { - @Override - public boolean match(BDChamber left, BDChamber right) { - return right.getBlock(1,0,1).getBlock() != Blocks.double_stone_slab && - left.getBlock(1,1,1).getBlock() != Blocks.barrier; - } - - @Override - public String getName() { - return "mazeMatch"; - } - @Override - public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return new MazeLeftProcessor(solver, left); - } - - @Override - public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return new MazeRightProcessor(solver, right); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java deleted file mode 100644 index 0bff75fd..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/maze/MazeRightProcessor.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.maze; - -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.util.MovingObjectPosition; -import org.lwjgl.input.Keyboard; - -import java.awt.*; -import java.util.HashMap; -import java.util.Map; - -public class MazeRightProcessor extends GeneralDefuseChamberProcessor { - public MazeRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - center = chamber.getBlockPos(4,4,4); - - for (int x = 0; x < 9; x++) { - for (int y =0; y< 6; y++) { - Block b = chamber.getBlock(x,0,y).getBlock(); - BlockPos pos = chamber.getBlockPos(x,0,y); - blockToBlockPosMap.put(b, pos); - } - } - } - - private final BlockPos center; - private final Map blockToBlockPosMap = new HashMap(); - @Override - public String getName() { - return "mazeRight"; - } - - - private Block latestRequest = null; - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(latestRequest == null ? "Request not received yet" : "Requested received "+latestRequest.getLocalizedName() , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - BlockPos pos = blockToBlockPosMap.get(latestRequest); - if (pos == null) return; - RenderUtils.highlightBlock(pos, new Color(0,255,0,100), partialTicks, false); - } - - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (5 == compound.getByte("a")) { - int latestRequestid = compound.getInteger("b"); - latestRequest = Block.getBlockById(latestRequestid); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java deleted file mode 100644 index 7cdd4f00..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberLeftProcessor.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import kr.syeyoung.dungeonsguide.Keybinds; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.BlockPos; -import org.lwjgl.input.Keyboard; - -public class NumberLeftProcessor extends GeneralDefuseChamberProcessor { - public NumberLeftProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - - d1p = chamber.getBlockPos(1,1,4); - d2p = chamber.getBlockPos(2,1,4); - d3p = chamber.getBlockPos(6,1,4); - d4p = chamber.getBlockPos(7,1,4); - } - - @Override - public String getName() { - return "numberLeft"; - } - - - private int answer = -1, d1, d2, d3 ,d4; - private final BlockPos d1p; - private final BlockPos d2p; - private final BlockPos d3p; - private final BlockPos d4p; - @Override - public void tick() { - super.tick(); - if (answer != -1) return; - d1 = match(getChamber().getEntityAt(EntityArmorStand.class,d1p)); - d2 = match(getChamber().getEntityAt(EntityArmorStand.class,d2p)); - d3 = match(getChamber().getEntityAt(EntityArmorStand.class,d3p)); - d4 = match(getChamber().getEntityAt(EntityArmorStand.class,d4p)); - if (d1 == -1 || d2 == -1 || d3 == -1 || d4 == -1) return; - - answer = d1 * 1000 + d2 * 100 + d3 * 10 + d4; - } - - @Override - public void drawScreen(float partialTicks) { - if (answer == -1) return; - drawPressKey(); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(d1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.5f, d1p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.5f, d2p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.5f, d3p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.5f, d4p.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - - } - - @Override - public void onSendData() { - if (answer == -1) return; - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setByte("a", (byte) 1); - nbt.setInteger("b", answer); - getSolver().communicate(nbt); - } - - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (1 == compound.getByte("a")) { - answer = compound.getInteger("b"); - d1 = answer / 1000; - d2 = (answer % 1000) / 100; - d3 = (answer % 100) / 10; - d4 = (answer % 10); - answer = d1 * 1000 + d2 * 100 + d3 * 10 + d4; - } - } - - private int match(EntityArmorStand armorStand) { - if (armorStand == null) return -1; - ItemStack item = armorStand.getInventory()[4]; - NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); - String str = ((NBTTagCompound)list.get(0)).getString("Value"); - return !integers.containsKey(str) ? -1 : integers.get(str); - } - - private static final BiMap integers = HashBiMap.create(10); - { - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzFhOTQ2M2ZkM2M0MzNkNWUxZDlmZWM2ZDVkNGIwOWE4M2E5NzBiMGI3NGRkNTQ2Y2U2N2E3MzM0OGNhYWIifX19", 1); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWNiNDE5ZDk4NGQ4Nzk2MzczYzk2NDYyMzNjN2EwMjY2NGJkMmNlM2ExZDM0NzZkZDliMWM1NDYzYjE0ZWJlIn19fQ==", 2); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjhlYmFiNTdiNzYxNGJiMjJhMTE3YmU0M2U4NDhiY2QxNGRhZWNiNTBlOGY1ZDA5MjZlNDg2NGRmZjQ3MCJ9fX0=", 3); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjJiZmNmYjQ4OWRhODY3ZGNlOTZlM2MzYzE3YTNkYjdjNzljYWU4YWMxZjlhNWE4YzhhYzk1ZTRiYTMifX19", 4); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWY0ZWNmMTEwYjBhY2VlNGFmMWRhMzQzZmIxMzZmMWYyYzIxNjg1N2RmZGE2OTYxZGVmZGJlZTdiOTUyOCJ9fX0=", 5); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjMzMWE2YTZmY2Q2OTk1YjYyMDg4ZDM1M2JmYjY4ZDliODlhZTI1ODMyNWNhZjNmMjg4NjQ2NGY1NGE3MzI5In19fQ==", 6); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDRiYTZhYzA3ZDQyMjM3N2E4NTU3OTNmMzZkZWEyZWQyNDAyMjNmNTJmZDE2NDgxODE2MTJlY2QxYTBjZmQ1In19fQ==", 7); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzYxYThhNjQxNDM3YmU5YWVhMjA3MjUzZGQzZjI1NDQwZDk1NGVhMmI1ODY2YzU1MmYzODZiMjlhYzRkMDQ5In19fQ==", 8); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTE5MjhlMWJmZDg2YTliNzkzOTdjNGNiNGI2NWVmOTlhZjQ5YjdkNWY3OTU3YWQ2MmMwYzY5OWE2MjJjZmJlIn19fQ==", 9); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTVhMjI0ODA3NjkzOTc4ZWQ4MzQzNTVmOWU1MTQ1ZjljNTZlZjY4Y2Y2ZjJjOWUxNzM0YTQ2ZTI0NmFhZTEifX19", 0); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java deleted file mode 100644 index 81588328..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberProcessorMatcher.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number; - -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BombDefuseChamberGenerator; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.ChamberProcessor; -import net.minecraft.init.Blocks; - -public class NumberProcessorMatcher implements BombDefuseChamberGenerator { - @Override - public boolean match(BDChamber left, BDChamber right) { - return left.getBlock(1,1,4).getBlock() == Blocks.stone && - left.getBlock(2,1,4).getBlock() == Blocks.stone && - left.getBlock(6,1,4).getBlock() == Blocks.stone && - left.getBlock(7,1,4).getBlock() == Blocks.stone && - right.getBlock(1,1,4).getBlock() == Blocks.stone && - right.getBlock(2,1,4).getBlock() == Blocks.stone && - right.getBlock(6,1,4).getBlock() == Blocks.stone && - right.getBlock(7,1,4).getBlock() == Blocks.stone; - } - - @Override - public String getName() { - return "numberMatch"; - } - @Override - public ChamberProcessor createLeft(BDChamber left, RoomProcessorBombDefuseSolver solver) { - return new NumberLeftProcessor(solver, left); - } - - @Override - public ChamberProcessor createRight(BDChamber right, RoomProcessorBombDefuseSolver solver) { - return new NumberRightProcessor(solver, right); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java deleted file mode 100644 index 949f7621..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/number/NumberRightProcessor.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.number; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.RoomProcessorBombDefuseSolver; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.BDChamber; -import kr.syeyoung.dungeonsguide.roomprocessor.bombdefuse.chambers.GeneralDefuseChamberProcessor; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.BlockPos; - -public class NumberRightProcessor extends GeneralDefuseChamberProcessor { - public NumberRightProcessor(RoomProcessorBombDefuseSolver solver, BDChamber chamber) { - super(solver, chamber); - - d1p = chamber.getBlockPos(1,1,4); - d2p = chamber.getBlockPos(2,1,4); - d3p = chamber.getBlockPos(6,1,4); - d4p = chamber.getBlockPos(7,1,4); - center = chamber.getBlockPos(4,4,4); - } - - @Override - public String getName() { - return "numberRight"; - } - - - private int answer = -1, d1, d2, d3 ,d4, a1, a2, a3, a4; - private final BlockPos d1p; - private final BlockPos d2p; - private final BlockPos d3p; - private final BlockPos d4p; - private final BlockPos center; - @Override - public void tick() { - super.tick(); - a1 = match(getChamber().getEntityAt(EntityArmorStand.class,d1p)); - a2 = match(getChamber().getEntityAt(EntityArmorStand.class,d2p)); - a3 = match(getChamber().getEntityAt(EntityArmorStand.class,d3p)); - a4 = match(getChamber().getEntityAt(EntityArmorStand.class,d4p)); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - RenderUtils.drawTextAtWorld(a1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.6f, d1p.getZ()+ 0.5f, a1 == d1 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(a2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.6f, d2p.getZ()+ 0.5f, a2 == d2 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(a3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.6f, d3p.getZ()+ 0.5f, a3 == d3 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(a4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.6f, d4p.getZ()+ 0.5f, a4 == d4 ? 0xFF00FF00 : 0xFFFF0000, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(answer == -1 ? "Answer not received yet. Visit left room to obtain solution" : ("Solution: "+answer) , center.getX()+ 0.5f, center.getY(), center.getZ()+ 0.5f, 0xFFFFFFFF, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d1+"", d1p.getX()+ 0.5f, d1p.getY()+ 0.2f, d1p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d2+"", d2p.getX()+ 0.5f, d2p.getY()+ 0.2f, d2p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d3+"", d3p.getX()+ 0.5f, d3p.getY()+ 0.2f, d3p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); - RenderUtils.drawTextAtWorld(d4+"", d4p.getX()+ 0.5f, d4p.getY()+ 0.2f, d4p.getZ()+ 0.5f, 0xFFFFFF00, 0.03F, false, false, partialTicks); - } - - @Override - public void onDataRecieve(NBTTagCompound compound) { - if (1 == compound.getByte("a")) { - answer = compound.getInteger("b"); - d1 = answer / 1000; - d2 = (answer % 1000) / 100; - d3 = (answer % 100) / 10; - d4 = (answer % 10); - answer = d4 * 1000 + d3 * 100 + d2 * 10 + d1; - } - } - - private int match(EntityArmorStand armorStand) { - if (armorStand == null) { - return -1; - } - ItemStack item = armorStand.getInventory()[4]; - NBTTagList list = item.getTagCompound().getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", 10); - String str = ((NBTTagCompound)list.get(0)).getString("Value"); - return !integers.containsKey(str) ? -1 : integers.get(str); - } - - private static final BiMap integers = HashBiMap.create(10); - { - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzFiYzJiY2ZiMmJkMzc1OWU2YjFlODZmYzdhNzk1ODVlMTEyN2RkMzU3ZmMyMDI4OTNmOWRlMjQxYmM5ZTUzMCJ9fX0=", 1); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGNkOWVlZWU4ODM0Njg4ODFkODM4NDhhNDZiZjMwMTI0ODVjMjNmNzU3NTNiOGZiZTg0ODczNDE0MTk4NDcifX19", 2); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWQ0ZWFlMTM5MzM4NjBhNmRmNWU4ZTk1NTY5M2I5NWE4YzNiMTVjMzZiOGI1ODc1MzJhYzA5OTZiYzM3ZTUifX19", 3); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDJlNzhmYjIyNDI0MjMyZGMyN2I4MWZiY2I0N2ZkMjRjMWFjZjc2MDk4NzUzZjJkOWMyODU5ODI4N2RiNSJ9fX0=", 4); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmQ1N2UzYmM4OGE2NTczMGUzMWExNGUzZjQxZTAzOGE1ZWNmMDg5MWE2YzI0MzY0M2I4ZTU0NzZhZTIifX19", 5); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzM0YjM2ZGU3ZDY3OWI4YmJjNzI1NDk5YWRhZWYyNGRjNTE4ZjVhZTIzZTcxNjk4MWUxZGNjNmIyNzIwYWIifX19", 6); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmRiNmViMjVkMWZhYWJlMzBjZjQ0NGRjNjMzYjU4MzI0NzVlMzgwOTZiN2UyNDAyYTNlYzQ3NmRkN2I5In19fQ==", 7); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTkxOTQ5NzNhM2YxN2JkYTk5NzhlZDYyNzMzODM5OTcyMjI3NzRiNDU0Mzg2YzgzMTljMDRmMWY0Zjc0YzJiNSJ9fX0=", 8); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTY3Y2FmNzU5MWIzOGUxMjVhODAxN2Q1OGNmYzY0MzNiZmFmODRjZDQ5OWQ3OTRmNDFkMTBiZmYyZTViODQwIn19fQ==", 9); - integers.put("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMGViZTdlNTIxNTE2OWE2OTlhY2M2Y2VmYTdiNzNmZGIxMDhkYjg3YmI2ZGFlMjg0OWZiZTI0NzE0YjI3In19fQ==", 0); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java deleted file mode 100644 index a889f3b5..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; - -import java.util.List; - -public interface BossfightProcessor extends RoomProcessor { - List getPhases(); - String getCurrentPhase(); - List getNextPhases(); - - List getHealths(); - - String getBossName(); -} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorBonzo.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorBonzo.java deleted file mode 100644 index 249cc3fe..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorBonzo.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraftforge.event.entity.living.LivingEvent; - -import java.util.ArrayList; -import java.util.List; - -public class BossfightProcessorBonzo extends GeneralBossfightProcessor { - public BossfightProcessorBonzo() { - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("start") - .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Gratz for making it this far, but Iโ€™m basically unbeatable.ยงr") - .nextPhase("fight-1").build() - ); - - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("fight-1") - .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: I can summon lots of undead! Check this out.ยงr") - .nextPhase("first-defeat").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("first-defeat") - .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Oh I'm dead!ยงr").signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Hoho, looks like you killed me!ยงr") - .nextPhase("fight-2").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("fight-2") - .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Sikeยงr").signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: I can revive myself and become much stronger!ยงr") - .nextPhase("final-defeat").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("final-defeat") - .signatureMsg("ยงrยงc[BOSS] Bonzo ยงrยงf: Alright, maybe I'm just weak after all..ยงr").build() - ); - } - - - @Override - public List getHealths() { - List healths = new ArrayList(); - long health = 0; - if (bonzoStand != null) { - String name = TextUtils.stripColor(bonzoStand.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Bonzo", (int) health,250000 , this.getCurrentPhase().startsWith("fight-"))); - return healths; - } - - @Override - public String getBossName() { - return "Bonzo"; - } - - private EntityArmorStand bonzoStand; - @Override - // ยงe๏ดพ ยงcยงlBonzoยงr ยงe71kยงcโค ยงe๏ดฟ - // ยงe๏ดพ ยงcยงlBonzoยงr ยงa250kยงcโค ยงe๏ดฟ - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - if (updateEvent.entityLiving.getName().startsWith("ยงe๏ดพ ยงcยงlBonzoยงr ") && updateEvent.entityLiving instanceof EntityArmorStand) { - bonzoStand = (EntityArmorStand) updateEvent.entityLiving; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorLivid.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorLivid.java deleted file mode 100644 index ace0fd67..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorLivid.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import lombok.Getter; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraftforge.event.entity.living.LivingEvent; - -import java.util.*; - -@Getter -public class BossfightProcessorLivid extends GeneralBossfightProcessor { - private String realLividName; - private String prefix; - private EntityOtherPlayerMP realLivid; - - private final Set knownLivids = new HashSet(); - - private boolean isMasterMode; - - public BossfightProcessorLivid(boolean isMasterMode) { - addPhase(PhaseData.builder().phase("start").build()); - this.isMasterMode = isMasterMode; - } - private static final Map lividColorPrefix = new HashMap() {{ - put("Vendetta", "ยงf"); - put("Crossed", "ยงd"); - put("Hockey", "ยงc"); - put("Doctor", "ยง7"); - put("Frog", "ยง2"); - put("Smile", "ยงa"); - put("Scream", "ยง1"); - put("Purple", "ยง5"); - put("Arcade", "ยงe"); - }}; - @Override - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - if (updateEvent.entityLiving.getName().endsWith("Livid") && updateEvent.entityLiving instanceof EntityOtherPlayerMP) { - if (!knownLivids.contains(updateEvent.entityLiving.getName())) { - knownLivids.add(updateEvent.entityLiving.getName()); - realLividName = updateEvent.entityLiving.getName(); - realLivid = (EntityOtherPlayerMP) updateEvent.entityLiving; - prefix = lividColorPrefix.get(realLividName.split(" ")[0]); - } else if (realLividName.equalsIgnoreCase(updateEvent.entityLiving.getName())) { - realLivid = (EntityOtherPlayerMP) updateEvent.entityLiving; - } - } else if (updateEvent.entityLiving.getName().startsWith(prefix+"๏ดพ ") && updateEvent.entityLiving instanceof EntityArmorStand) { - lividStand = (EntityArmorStand) updateEvent.entityLiving; - } - } - private EntityArmorStand lividStand; - - @Override - public List getHealths() { - List healths = new ArrayList(); - long health = 0; - if (lividStand != null) { - try { - String name = TextUtils.stripColor(lividStand.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } catch (Exception e) {e.printStackTrace();} - } - healths.add(new HealthData(realLividName == null ? "unknown" : realLividName, (int) health,isMasterMode ? 600000000 : 7000000 , true)); - return healths; - } - - @Override - public String getBossName() { - return realLividName == null ? "Livid" : realLividName; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorNecron.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorNecron.java deleted file mode 100644 index 92718c15..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorNecron.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.entity.boss.BossStatus; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraftforge.event.entity.living.LivingEvent; - -import java.util.ArrayList; -import java.util.List; - -public class BossfightProcessorNecron extends GeneralBossfightProcessor { - // \A7 to ยง - public BossfightProcessorNecron() { - addPhase(PhaseData.builder() - .phase("crystals") - .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcFinally, I heard so much about you. The Eye likes you very much.ยงr") - .nextPhase("laser-attack").nextPhase("lost").build() - ); - addPhase(PhaseData.builder() - .phase("laser-attack") - .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcYou tricked me!ยงr") - .nextPhase("fight-1").nextPhase("lost").build() - ); - addPhase(PhaseData.builder() - .phase("fight-1") - .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcFINE! LET'S MOVE TO SOMEWHERE ELSE!!ยงr") - .nextPhase("terminals").nextPhase("lost").build() - ); - addPhase(PhaseData.builder() - .phase("terminals") - .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcCRAP!! IT BROKE THE FLOOR!ยงr") - .nextPhase("fight-2").nextPhase("lost").build() - ); - addPhase(PhaseData.builder() - .phase("fight-2") - .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcTHAT'S IT YOU HAVE DONE IT!ยงr") - .nextPhase("won").nextPhase("lost").build() - ); - addPhase(PhaseData.builder() - .phase("won") - .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcAll this, for nothing...ยงr").build() - ); - addPhase(PhaseData.builder() - .phase("lost") - .signatureMsg("ยงrยง4[BOSS] Necronยงrยงc: ยงrยงcFINALLY! This took way too long.ยงr").build() - ); - } - - - @Override - public List getHealths() { - List healths = new ArrayList(); - int maxHealth = 1_000_000_000; - healths.add(new HealthData("Necron", (int) (BossStatus.healthScale * maxHealth),maxHealth , this.getCurrentPhase().startsWith("fight-"))); - return healths; - } - - @Override - public String getBossName() { - return "Necron"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorProf.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorProf.java deleted file mode 100644 index d1ccd300..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorProf.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraftforge.event.entity.living.LivingEvent; - -import java.util.ArrayList; -import java.util.List; - -public class BossfightProcessorProf extends GeneralBossfightProcessor { - public BossfightProcessorProf() { - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("start") - .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: I was burdened with terrible news recently...ยงr") - .nextPhase("fight-1").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("fight-1") - .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: I'll show you real power!ยงr") - .nextPhase("first-defeat").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("first-defeat") - .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: Oh? You found my Guardians one weakness?ยงr") - .nextPhase("fight-2").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("fight-2") - .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: This time I'll be your opponent!ยงr") - .nextPhase("second-defeat").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("second-defeat") - .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: I see. You have forced me to use my ultimate technique.ยงr") - .nextPhase("fight-3").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("fight-3") - .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: The process is irreversible, but I'll be stronger than a Wither now!ยงr") - .nextPhase("final-defeat").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("final-defeat") - .signatureMsg("ยงrยงc[BOSS] The Professorยงrยงf: What?! My Guardian power is unbeatable!ยงr").build() - ); - } - - @Override - public List getHealths() { - List healths = new ArrayList(); - { - long health = 0; - if (profStand != null) { - String name = TextUtils.stripColor(profStand.getName()); - String healthPart = name.split(" ")[3]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("The Professor", (int) health, 3000000, this.getCurrentPhase().startsWith("fight-") && !this.getCurrentPhase().equals("fight-1"))); - } - if (!getCurrentPhase().equals("second-defeat") && !getCurrentPhase().equals("fight-3") && !getCurrentPhase().equals("final-defeat")) { - { - long health = 0; - if (healthyGuard != null) { - String name = TextUtils.stripColor(healthyGuard.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Healthy Guardian", (int) health, 1000000, this.getCurrentPhase().equals("fight-1"))); - } - { - long health = 0; - if (chaosGuard != null) { - String name = TextUtils.stripColor(chaosGuard.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Chaos Guardian", (int) health, 1000000, this.getCurrentPhase().equals("fight-1"))); - } - { - long health = 0; - if (laserGuard != null) { - String name = TextUtils.stripColor(laserGuard.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Laser Guardian", (int) health, 1000000, this.getCurrentPhase().equals("fight-1"))); - } - { - long health = 0; - if (reinforcedGuard != null) { - String name = TextUtils.stripColor(reinforcedGuard.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Reinforced Guardian", (int) health, 1000000, this.getCurrentPhase().equals("fight-1"))); - } - } - return healths; - } - - @Override - public String getBossName() { - return "The Professor"; - } - - private EntityArmorStand profStand; - private EntityArmorStand laserGuard; - private EntityArmorStand chaosGuard; - private EntityArmorStand reinforcedGuard; - private EntityArmorStand healthyGuard; - @Override - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - if (updateEvent.entityLiving instanceof EntityArmorStand) { - if (updateEvent.entityLiving.getName().startsWith("ยงe๏ดพ ยงcยงlThe Professorยงr ")) - profStand = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยงcHealthy Guardian ")) - healthyGuard = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยงcChaos Guardian ")) - chaosGuard = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยงcLaser Guardian ")) - laserGuard = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยงcReinforced Guardian ")) - reinforcedGuard = (EntityArmorStand) updateEvent.entityLiving; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorSadan.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorSadan.java deleted file mode 100644 index 0de8795f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorSadan.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraftforge.event.entity.living.LivingEvent; - -import java.util.ArrayList; -import java.util.List; - -public class BossfightProcessorSadan extends GeneralBossfightProcessor { - public BossfightProcessorSadan() { - addPhase(PhaseData.builder() - .phase("start") - .signatureMsg("So you made it all the way ยงrยงfhere...andยงrยงf you wish to defy me? Sadan?!ยงr") - .nextPhase("fight-1").build() - ); - addPhase(PhaseData.builder() - .phase("fight-1") - .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: I am the bridge between this realm and the world below! You shall not pass!ยงr") - .nextPhase("first-defeat").build() - ); - addPhase(PhaseData.builder() - .phase("first-defeat") - .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: ENOUGH!ยงr") - .nextPhase("fight-2").build() - ); - addPhase(PhaseData.builder() - .phase("fight-2") - .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: My giants! Unleashed!ยงr") - .nextPhase("second-defeat").build() - ); - addPhase(PhaseData.builder() - .phase("second-defeat") - .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: You did it. I understand now, you have earned my respect.ยงr") - .nextPhase("fight-3").build() - ); - addPhase(PhaseData.builder() - .phase("fight-3") - .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: I'm sorry but I need to concentrate. I wish it didn't have to come to this.ยงr") - .nextPhase("final-defeat").build() - ); - addPhase(PhaseData.builder() - .phase("final-defeat") - .signatureMsg("ยงrยงc[BOSS] Sadan ยงrยงf: NOOOOOOOOO!!! THIS IS IMPOSSIBLE!!ยงr").build() - ); - } - - @Override - public List getHealths() { - List healths = new ArrayList(); - { - long health = 0; - if (sadanStand != null) { - String name = TextUtils.stripColor(sadanStand.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Sadan", (int) health, 40000000, this.getCurrentPhase().equals("fight-3"))); - } - if (getCurrentPhase().equals("fight-2")) { - { - long health = 0; - if (diamondGiant != null) { - String name = TextUtils.stripColor(diamondGiant.getName()); - String healthPart = name.split(" ")[3]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("The Diamond Giant", (int) health, 25000000, this.getCurrentPhase().startsWith("fight-"))); - } - { - long health = 0; - if (bigfootGiant != null) { - String name = TextUtils.stripColor(bigfootGiant.getName()); - String healthPart = name.split(" ")[1]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Bigfoot", (int) health, 25000000, this.getCurrentPhase().startsWith("fight-"))); - } - { - long health = 0; - if (laserGiant != null) { - String name = TextUtils.stripColor(laserGiant.getName()); - String healthPart = name.split(" ")[1]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("L.A.S.R.", (int) health, 25000000, this.getCurrentPhase().startsWith("fight-"))); - } - { - long health = 0; - if (boulderGiant != null) { - String name = TextUtils.stripColor(boulderGiant.getName()); - String healthPart = name.split(" ")[3]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Jolly Pink Giant", (int) health, 25000000, this.getCurrentPhase().startsWith("fight-"))); - } - } - return healths; - } - - @Override - public String getBossName() { - return "Sadan"; - } - - private EntityArmorStand sadanStand; - private EntityArmorStand diamondGiant; - private EntityArmorStand laserGiant; - private EntityArmorStand bigfootGiant; - private EntityArmorStand boulderGiant; - @Override - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - if (updateEvent.entityLiving instanceof EntityArmorStand) { - if (updateEvent.entityLiving.getName().startsWith("ยงe๏ดพ ยงcยงlSadanยงr ")) - sadanStand = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยงcยงdยงlJolly Pink Giant ")) - boulderGiant = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยงcยง4ยงlL.A.S.R. ")) - laserGiant = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยงcยง3ยงlThe Diamond Giant ")) - diamondGiant = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยงcยงcยงlBigfoot ")) - bigfootGiant = (EntityArmorStand) updateEvent.entityLiving; - } - } -} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorScarf.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorScarf.java deleted file mode 100644 index 2100d002..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorScarf.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraftforge.event.entity.living.LivingEvent; - -import java.util.ArrayList; -import java.util.List; - -public class BossfightProcessorScarf extends GeneralBossfightProcessor { - public BossfightProcessorScarf() { - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("start") - .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: This is where the journey ends for you, Adventurers.ยงr") - .nextPhase("fight-1").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("fight-1") - .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: ARISE, MY CREATIONS!ยงr") - .nextPhase("first-defeat").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("first-defeat") - .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: Those toys are not strong enough I see.ยงr") - .nextPhase("fight-2").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("fight-2") - .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: Did you forget? I was taught by the best! Let's dance.ยงr") - .nextPhase("final-defeat").build() - ); - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("final-defeat") - .signatureMsg("ยงrยงc[BOSS] Scarf ยงrยงf: Whatever...ยงr").build() - ); - } - - @Override - public List getHealths() { - List healths = new ArrayList(); - { - long health = 0; - if (scarfStand != null) { - String name = TextUtils.stripColor(scarfStand.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Scarf", (int) health, 1000000, this.getCurrentPhase().equals("fight-2"))); - } - if (!getCurrentPhase().equals("start") && !getCurrentPhase().equals("final-defeat")) { - { - long health = 0; - if (priestStand != null) { - String name = TextUtils.stripColor(priestStand.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Undead Priest", (int) health, 600000, this.getCurrentPhase().startsWith("fight-"))); - } - { - long health = 0; - if (berserkStand != null) { - String name = TextUtils.stripColor(berserkStand.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Undead Warrior", (int) health, 500000, this.getCurrentPhase().startsWith("fight-"))); - } - { - long health = 0; - if (mageStand != null) { - String name = TextUtils.stripColor(mageStand.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Undead Mage", (int) health, 400000, this.getCurrentPhase().startsWith("fight-"))); - } - { - long health = 0; - if (archerStand != null) { - String name = TextUtils.stripColor(archerStand.getName()); - String healthPart = name.split(" ")[2]; - health = TextUtils.reverseFormat(healthPart.substring(0, healthPart.length() - 1)); - } - healths.add(new HealthData("Undead Archer", (int) health, 400000, this.getCurrentPhase().startsWith("fight-"))); - } - } - return healths; - } - - @Override - public String getBossName() { - return "Scarf"; - } - - private EntityArmorStand scarfStand; - private EntityArmorStand priestStand; - private EntityArmorStand mageStand; - private EntityArmorStand berserkStand; - private EntityArmorStand archerStand; - @Override - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - if (updateEvent.entityLiving instanceof EntityArmorStand) { - if (updateEvent.entityLiving.getName().startsWith("ยงe๏ดพ ยงcยงlScarfยงr ")) - scarfStand = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยง6ยง4ยงlUndead Archer ")) - archerStand = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยง6ยง4ยงlUndead Mage ")) - mageStand = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยง6ยง4ยงlUndead Priest ")) - priestStand = (EntityArmorStand) updateEvent.entityLiving; - else if (updateEvent.entityLiving.getName().startsWith("ยง6ยง4ยงlUndead Warrior ")) - berserkStand = (EntityArmorStand) updateEvent.entityLiving; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorThorn.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorThorn.java deleted file mode 100644 index ce76b270..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorThorn.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.entity.boss.BossStatus; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class BossfightProcessorThorn extends GeneralBossfightProcessor { - - - public BossfightProcessorThorn() { - addPhase(GeneralBossfightProcessor.PhaseData.builder() - .phase("fight").build() - ); - - w= DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext().getWorld(); - } - private final Set progressBar = new HashSet(); - private final World w; - - private int ticksPassed = 0; - - @Override - public void tick() { - ticksPassed ++; - if (ticksPassed == 20) { - progressBar.clear(); - for (int x = -30; x <= 30; x++) { - for (int y = -30; y <= 30; y++) { - BlockPos newPos = new BlockPos(5 + x, 77, 5 + y); - Block b = w.getBlockState(newPos).getBlock(); - if ((b == Blocks.coal_block || b == Blocks.sea_lantern) && w.getBlockState(newPos.add(0, 1, 0)).getBlock() != Blocks.carpet) - progressBar.add(newPos); - } - } - } - } - - @Override - public List getHealths() { - List healths = new ArrayList(); - healths.add(new HealthData("Thorn", Math.round(BossStatus.healthScale * 4),4, true)); - return healths; - } - - @Override - public String getBossName() { - return "Thorn"; - } - - public double calculatePercentage() { - int total = progressBar.size(), lit = 0; - if (total == 0) return 0; - for (BlockPos pos : progressBar) { - if (w.getBlockState(pos).getBlock() == Blocks.sea_lantern ) lit++; - } - - return lit / (double)total; - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.DEBUG.isEnabled()) return; - try { - BlockPos pos = new BlockPos(205,77, 205); - RenderUtils.highlightBlock(pos, new Color(0, 255, 255, 50), partialTicks, false); - for (BlockPos pos2 : progressBar) { - RenderUtils.highlightBlock(pos2, w.getBlockState(pos2).getBlock() == Blocks.sea_lantern ? - new Color(0, 255, 0, 50) : new Color(255,0,0, 50), partialTicks, false); - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java deleted file mode 100644 index e8ed8981..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import kr.syeyoung.dungeonsguide.events.BlockUpdateEvent; -import kr.syeyoung.dungeonsguide.events.KeyBindPressedEvent; -import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; -import lombok.*; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.World; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; - -import java.util.*; - -public abstract class GeneralBossfightProcessor implements BossfightProcessor { - private final Map phases = new HashMap(); - private PhaseData currentPhase = null; - - @Getter - @Setter - private String name; - - private World world; - - public void addPhase(PhaseData phaseData) { - if (phaseData == null) return; - if (currentPhase == null) currentPhase = phaseData; - phases.put(phaseData.getPhase(), phaseData); - } - - @Override - public List getPhases() { - List phases = new ArrayList(); - for (PhaseData pd:this.phases.values()) - phases.add(pd.getPhase()); - return phases; - } - - @Override - public List getNextPhases() { - if (currentPhase == null) return Collections.emptyList(); - List phases = new ArrayList(this.currentPhase.getNextPhases()); - return phases; - } - - - @Override - public String getCurrentPhase() { - return currentPhase == null ? "unknown" : currentPhase.getPhase(); - } - - @Override - public void chatReceived(IChatComponent chat) { - if (currentPhase == null) return; - - for (String nextPhase : currentPhase.getNextPhases()) { - PhaseData phaseData = phases.get(nextPhase); - if (phaseData == null) continue; - if (phaseData.signatureMsgs.contains(chat.getFormattedText().replace(" ", ""))) { - currentPhase = phaseData; - onPhaseChange(); - return; - } - } - } - - @Override - public void actionbarReceived(IChatComponent chat) {} - - @Override - public void tick() {} - - @Override - public void drawScreen(float partialTicks) {} - - @Override - public void drawWorld(float partialTicks) {} - - @Override - public boolean readGlobalChat() {return true;} - - @Override - public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { - - } - - @Override - public void onEntityUpdate(LivingEvent.LivingUpdateEvent updateEvent) { - - } - - @Override - public void onInteract(PlayerInteractEntityEvent event) { - - } - - @Override - public void onKeybindPress(KeyBindPressedEvent keyInputEvent) { - - } - - @Override - public void onInteractBlock(PlayerInteractEvent event) { - - } - @Override - public void onEntityDeath(LivingDeathEvent deathEvent) { - - } - @Override - public void onBlockUpdate(BlockUpdateEvent blockUpdateEvent) { - - } - - public void onPhaseChange() {} - - @Data - @Builder - public static class PhaseData { - private PhaseData(String phase, Set signatureMsgs, Set nextPhase) { - this.phase = phase; - this.nextPhases = new HashSet<>(nextPhase); - this.signatureMsgs = new HashSet<>(); - for (String signatureMsg : signatureMsgs) { - this.signatureMsgs.add(signatureMsg.replace(" ", "")); - } - } - - private String phase; - @Singular - private Set signatureMsgs; - @Singular - private Set nextPhases; - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/HealthData.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/HealthData.java deleted file mode 100644 index 065ab15f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/HealthData.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class HealthData { - private String name; - private int health; - private int maxHealth; - private boolean attackable; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/BoxPuzzleSolvingThread.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/BoxPuzzleSolvingThread.java deleted file mode 100755 index 41cb633d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/BoxPuzzleSolvingThread.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.boxpuzzle; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; - -import java.awt.*; -import java.util.*; -import java.util.List; - -@Getter -@Setter -public class BoxPuzzleSolvingThread extends Thread { - private byte[][] data; - private int playerX; - private int playerY; - private Runnable callback; - - - public BoxPuzzleSolvingThread(byte[][] data, int playerX, int playerY, Runnable onDone) { - this.data = data; - this.playerX = playerX; - this.playerY = playerY; - this.callback = onDone; - } - - Route solution = null; - - private boolean solved = false; - - @Override - public void run() { - solved = false; - solution = solve(data,playerX,playerY, 20); - solved = true; - callback.run(); - } - - - public static String stateString(byte[][] array) { - StringBuilder sb = new StringBuilder(); - for (int y = 0; y < array.length; y++) - for(int x = 0; x < array[y].length; x++) - sb.append(array[y][x]); - - return sb.toString(); - } - - - private static final List directions = Arrays.asList(new Point(-1,0), new Point(1,0), new Point(0,1), new Point(0,-1)); - private static Route solve(byte[][] boardStart, int playerX, int playerY, int maxRecursion) { // result:: playerY == 0 - Queue routes = new LinkedList(); - Set globalStatesBeen = new HashSet(); - - Route r = new Route(); - r.currentState = boardStart; - routes.add(r); - - while (!routes.isEmpty()) { - Route route = routes.poll(); - - if (routes.size() > 3000000) return null; - - String stateId = stateString(route.currentState); - if (maxRecursion < route.boxMoves.size()) continue; - if (globalStatesBeen.contains(stateId)) continue; - - Queue points = new LinkedList(); - Set reached= new HashSet(); - List possibleBoxMoves = new ArrayList(); - points.add(new Point(playerX, playerY)); - - while (!points.isEmpty()) { - Point pt = points.poll(); - if (pt.y == 0) { - return route; - } - if (reached.contains(pt)) continue; - reached.add(pt); - for (Point dir:directions) { - int resX= pt.x + dir.x; - int resY = pt.y + dir.y; - if (resX < 0 || resY < 0 || resX >= route.currentState[0].length || resY >= route.currentState.length) { - continue; - } - if (route.currentState[resY][resX] > 0) { - possibleBoxMoves.add(new BoxMove(resX, resY, dir.x, dir.y)); - continue; - } - points.add(new Point(resX, resY)); - } - } - - globalStatesBeen.add(stateId); - for (BoxMove possibleBoxMove : possibleBoxMoves) { - byte[][] copied = new byte[route.currentState.length][]; - for (int y = 0; y < copied.length; y++) - copied[y] = route.currentState[y].clone(); - - if (push(copied, possibleBoxMove.x, possibleBoxMove.y, possibleBoxMove.dx, possibleBoxMove.dy)){ - String stateId2 = stateString(copied); - if (globalStatesBeen.contains(stateId2)) continue; - - Route route2 = new Route(); - route2.boxMoves = new ArrayList(route.boxMoves); - route2.boxMoves.add(possibleBoxMove); - route2.currentState = copied; - - routes.add(route2); - } - } - } - - - return null; - } - - - public static boolean push(byte[][] board, int x,int y,int dx,int dy) { - if (board[y][x] != 1) return false; - int resultingX= x + dx; - int resultingY = y +dy; - if (resultingX < 0 || resultingY < 0 || resultingX >= board[0].length || resultingY >= board.length) return false; - if (board[resultingY][resultingX] == 1 || resultingY == 6) return false; - - board[resultingY][resultingX] = 1; - board[y][x] = 0; - return true; - } - - public static class BoxMove { - int x; - int y; - int dx; - int dy; - - public BoxMove(int x, int y, int dx, int dy) { - this.x = x; - this.y = y; - this.dx = dx; - this.dy = dy; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public int getDx() { - return dx; - } - - public int getDy() { - return dy; - } - } - - public static class Route { - List boxMoves = new LinkedList(); - byte[][] currentState; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java deleted file mode 100755 index bf81bf72..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/boxpuzzle/RoomProcessorBoxSolver.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.boxpuzzle; - -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Blocks; -import net.minecraft.util.*; -import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import java.awt.*; -import java.util.*; -import java.util.List; - -public class RoomProcessorBoxSolver extends GeneralRoomProcessor { - - - private BlockPos[][] poses = new BlockPos[7][7]; - private boolean bugged= true; - - private BoxPuzzleSolvingThread puzzleSolvingThread; - - public RoomProcessorBoxSolver(DungeonRoom dungeonRoom) { - super(dungeonRoom); - - OffsetPointSet ops = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("board"); - try { - if (ops != null) { - for (int y = 0; y < 7; y++) { - for (int x = 0; x < 7; x++) { - poses[y][x] = ops.getOffsetPointList().get(y * 7 + x).getBlockPos(dungeonRoom); - } - } - bugged = false; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private byte[][] buildCurrentState() { - World w = getDungeonRoom().getContext().getWorld(); - byte[][] board = new byte[poses.length][poses[0].length]; - for (int y = 0; y < poses.length; y++) { - for (int x = 0; x < poses[0].length; x++) { - if (y == 6) { - board[y][x] = -1; - continue; - } - BlockPos pos = poses[y][x]; - Block b = w.getChunkFromBlockCoords(pos).getBlock(pos); - if (b == Blocks.air) - board[y][x] = 0; - else - board[y][x] = 1; - } - } - return board; - } - - private boolean calcReq = true; - - private boolean calcDone= false; - private boolean calcDone2 = false; - private int step = 0; - private byte[][] lastState; - - @Override - public void tick() { - super.tick(); - if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; - if (bugged) return; - byte[][] currboard = buildCurrentState(); - if (puzzleSolvingThread == null) { - calcDone = false; - puzzleSolvingThread = new BoxPuzzleSolvingThread(currboard, 0, 6, new Runnable() { - @Override - public void run() { - calcDone = true; - calcDone2 = true; - } - }); - puzzleSolvingThread.start(); - } - if (calcReq) { - OffsetPointSet ops = (OffsetPointSet) getDungeonRoom().getDungeonRoomInfo().getProperties().get("board"); - if (ops != null) { - poses = new BlockPos[7][7]; - for (int y = 0; y < 7; y++) { - for (int x = 0; x < 7; x++) { - poses[y][x] = ops.getOffsetPointList().get(y * 7 + x).getBlockPos(getDungeonRoom()); - } - } - bugged = false; - } - - calcDone = false; - if (puzzleSolvingThread != null) - puzzleSolvingThread.stop(); - puzzleSolvingThread = new BoxPuzzleSolvingThread(currboard, 0, 6, new Runnable() { - @Override - public void run() { - calcDone = true; - calcDone2 = true; - } - }); - puzzleSolvingThread.start(); - calcReq = false; - } - - boolean pathFindReq = false; - if (calcDone2) { - BoxPuzzleSolvingThread.Route semi_solution = puzzleSolvingThread.solution; - if (semi_solution == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeBox Solver ยง7:: ยงcCouldn't find solution involving less than 20 box moves within 3m concurrent possibility")); - step = 0; - calcDone2 = false; - pathFindReq = true; - totalPath = new LinkedList(); - totalPushedBlocks = new LinkedList(); - solution = new LinkedList(); - return; - } else{ - solution = semi_solution.boxMoves; - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide ยง7:: ยงeBox Solver ยง7:: Solution Found!")); - } - step = 0; - lastState = currboard; - calcDone2 = false; - pathFindReq = true; - - calcTotalPath(); - } - - if (lastState == null) return; - boolean moved = false; - label: - for (int y = 0 ; y < currboard.length; y++) { - for (int x = 0; x < currboard[y].length; x++) { - if (lastState[y][x] != currboard[y][x]) { - moved = true; - lastState = currboard; - break label; - } - } - } - - if (moved) { - step++; - } - - Point player = getPlayerPos(currboard); - boolean currYState = Minecraft.getMinecraft().thePlayer.getPosition().getY() < 68; - if (((currYState && !player.equals(lastPlayer)) || (currYState != yState) || (moved) || pathFindReq) && solution != null) { - Point target = null; - if (step < solution.size()) { - BoxPuzzleSolvingThread.BoxMove boxMove = solution.get(step); - target = new Point(boxMove.x - boxMove.dx, boxMove.y - boxMove.dy); - } - List semi_pathFound = pathfind(currboard, player, target); - pathFound = new LinkedList(); - for (Point point : semi_pathFound) { - pathFound.add(poses[point.y][point.x].add(0,-1,0)); - } - - lastPlayer = player; - yState = currYState; - } - - } - - public void calcTotalPath() { - Point player = new Point(0,6); - totalPath = new LinkedList(); - totalPushedBlocks = new LinkedList(); - byte[][] currboard = buildCurrentState(); - for (int i = 0; i <= solution.size(); i++) { - Point target = null; - BoxPuzzleSolvingThread.BoxMove boxMove = null; - if (i < solution.size()) { - boxMove = solution.get(i); - target = new Point(boxMove.x - boxMove.dx, boxMove.y - boxMove.dy); - } - List semi_pathFound = pathfind(currboard, player, target); - for (int i1 = semi_pathFound.size() - 1; i1 >= 0; i1--) { - Point point = semi_pathFound.get(i1); - totalPath.add(poses[point.y][point.x].add(0, -1, 0)); - } - - player = target; - if (boxMove != null) { - BoxPuzzleSolvingThread.push(currboard, boxMove.x, boxMove.y, boxMove.dx, boxMove.dy); - int fromX = boxMove.x - boxMove.dx; - int fromY = boxMove.y - boxMove.dy; - - BlockPos pos = poses[fromY][fromX]; - BlockPos pos2 = poses[boxMove.y][boxMove.x]; - BlockPos dir = pos.subtract(pos2); - dir = new BlockPos(MathHelper.clamp_int(dir.getX(), -1,1), 0, MathHelper.clamp_double(dir.getZ(), -1, 1)); - - BlockPos highlight = pos2.add(dir); - totalPushedBlocks.add(highlight); - } - } - } - - private boolean yState = true; - public Point getPlayerPos(byte[][] map) { - BlockPos playerPos = Minecraft.getMinecraft().thePlayer.getPosition(); - int minDir = Integer.MAX_VALUE; - Point pt = null; - for (int y = 0; y < poses.length; y++) { - for (int x = 0; x < poses[0].length; x++) { - if (map[y][x] == 1) continue; - int dir = (int) poses[y][x].distanceSq(playerPos); - if (dir < minDir) { - minDir = dir; - pt = new Point(x,y); - } - } - } - return pt; - } - - private List solution; - private List pathFound; - private List totalPath; - private List totalPushedBlocks; - private Point lastPlayer; - - private static final java.util.List directions = Arrays.asList(new Point(-1,0), new Point(1,0), new Point(0,1), new Point(0,-1)); - public List pathfind(byte[][] map, Point start, Point target2) { - int[][] distances = new int[map.length][map[0].length]; - - Queue evalulate = new LinkedList(); - evalulate.add(start); - Point target = null; - while (!evalulate.isEmpty()) { - Point p = evalulate.poll(); - if (p.equals(target2) || (target2 == null &&p.y == 0)) { - target = p; - break; - } - int max = 0; - for (Point dir:directions) { - int resX= p.x + dir.x; - int resY = p.y + dir.y; - if (resX < 0 || resY < 0 || resX >= distances[0].length || resY >= distances.length) { - continue; - } - - if (max < distances[resY][resX]) { - max = distances[resY][resX]; - } - if (distances[resY][resX] == 0 && (map[resY][resX] == 0 ||map[resY][resX] == -1)) { - evalulate.add(new Point(resX, resY)); - } - } - distances[p.y][p.x] = max + 1; - } - if (target == null) return Collections.emptyList(); - - List route = new LinkedList(); - while(!target.equals(start)) { - route.add(target); - int min = Integer.MAX_VALUE; - Point minPoint = null; - for (Point dir:directions) { - int resX= target.x + dir.x; - int resY = target.y + dir.y; - if (resX < 0 || resY < 0 || resX >= distances[0].length || resY >= distances.length) { - continue; - } - - if (min > distances[resY][resX] && distances[resY][resX] != 0) { - min = distances[resY][resX]; - minPoint = new Point(resX, resY); - } - } - target = minPoint; - } - route.add(start); - return route; - } - - @Override - public void chatReceived(IChatComponent chat) { - if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; - if (chat.getFormattedText().toLowerCase().contains("recalc")) { - if (calcDone) { - calcReq = true; - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide :::: Recalculating Route...")); - } else { - calcReq = true; - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("ยงeDungeons Guide :::: Currently Calculating Route...")); - } - } - } - - @Override - public void drawScreen(float partialTicks) { - super.drawScreen(partialTicks); - if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; - if (FeatureRegistry.SOLVER_BOX.disableText()) return; - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fr.drawString("Type \"recalc\" in chat to recalculate the solution", 0, 0, 0xFFFFFFFF); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_BOX.isEnabled()) return; - if (bugged) return; - if (!calcDone) return; - if (solution == null) return; - if (Minecraft.getMinecraft().thePlayer.getPosition().getY() < 68) { - if (step < solution.size()) { - BoxPuzzleSolvingThread.BoxMove boxMove = solution.get(step); - int fromX = boxMove.x - boxMove.dx; - int fromY = boxMove.y - boxMove.dy; - - BlockPos pos = poses[fromY][fromX]; - BlockPos pos2 = poses[boxMove.y][boxMove.x]; - BlockPos dir = pos.subtract(pos2); - dir = new BlockPos(MathHelper.clamp_int(dir.getX(), -1, 1), 0, MathHelper.clamp_double(dir.getZ(), -1, 1)); - - BlockPos highlight = pos2.add(dir); - AColor color = FeatureRegistry.SOLVER_BOX.getTargetColor().multiplyAlpha(MathHelper.clamp_double(Minecraft.getMinecraft().thePlayer.getPosition().distanceSq(highlight), 100, 255) / 255); - RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(highlight.getX(), highlight.getY(), highlight.getZ(), highlight.getX()+1, highlight.getY() + 1, highlight.getZ() + 1), color, partialTicks, false); - } - - if (pathFound != null) { - RenderUtils.drawLines(pathFound, FeatureRegistry.SOLVER_BOX.getLineColor(),FeatureRegistry.SOLVER_BOX.getLineWidth(), partialTicks, true); - } - } else { - if (totalPath != null) { - RenderUtils.drawLines(totalPath, FeatureRegistry.SOLVER_BOX.getLineColor(),FeatureRegistry.SOLVER_BOX.getLineWidth(), partialTicks, false); - } - if (totalPushedBlocks != null) { - for (int i = 0; i < totalPushedBlocks.size(); i++) { - BlockPos pos = totalPushedBlocks.get(i); - RenderUtils.highlightBoxAColor(AxisAlignedBB.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1, pos.getY() + 1, pos.getZ() + 1), FeatureRegistry.SOLVER_BOX.getTargetColor(), partialTicks, false); - RenderUtils.drawTextAtWorld("#"+i, pos.getX()+0.5f, pos.getY() +0.5f, pos.getZ() + 0.5f, i != step ? - RenderUtils.getColorAt(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SOLVER_BOX.getTextColor2()) : RenderUtils.getColorAt(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SOLVER_BOX.getTextColor()), 0.1f, false, false, partialTicks); - } - } - } - - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorBoxSolver createNew(DungeonRoom dungeonRoom) { - RoomProcessorBoxSolver defaultRoomProcessor = new RoomProcessorBoxSolver(dungeonRoom); - return defaultRoomProcessor; - } - } - - - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java deleted file mode 100755 index c31ba753..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.icefill; - -import kr.syeyoung.dungeonsguide.config.Config; -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; - -import java.awt.*; -import java.util.Queue; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.CopyOnWriteArrayList; - -public class RoomProcessorIcePath2 extends GeneralRoomProcessor { - private final List> solution = new CopyOnWriteArrayList>(); - - private final Queue messageQueue = new ConcurrentLinkedQueue(); - - public RoomProcessorIcePath2(DungeonRoom dungeonRoom) { - - super(dungeonRoom); - - String levels = (String) dungeonRoom.getDungeonRoomInfo().getProperties().get("levels"); - if (levels == null) { - return; - } - - for (final String s : levels.split(",")) { - try { - OffsetPointSet level = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get(s + "-board"); - String data = (String) dungeonRoom.getDungeonRoomInfo().getProperties().get(s + "-level"); - final int width = Integer.parseInt(data.split(":")[0]); - final int height = Integer.parseInt(data.split(":")[1]); - final int startX = Integer.parseInt(data.split(":")[2]); - final int startY = Integer.parseInt(data.split(":")[3]); - final int endX = Integer.parseInt(data.split(":")[4]); - final int endY = Integer.parseInt(data.split(":")[5]); - - final int[][] map = new int[height][width]; - final BlockPos[][] map2 = new BlockPos[height][width]; - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - map2[y][x] = level.getOffsetPointList().get(y * width + x).getBlockPos(dungeonRoom); - map[y][x] = level.getOffsetPointList().get(y * width + x).getBlock(dungeonRoom) == Blocks.air ? 0 : 1; - } - } - - new Thread() { - public void run() { - List hamiltonianPath = findFirstHamiltonianPath(map, startX, startY, endX, endY); - if (hamiltonianPath == null) { - messageQueue.add("ยงeDungeons Guide ยง7:: ยงeIcePath ยง7:: ยงcCouldn't find solution for floor "+s); - return; - } - hamiltonianPath.add(0,new Point(startX, startY)); - List poses = new LinkedList(); - for (int i = 0; i < hamiltonianPath.size(); i++) { - Point p = hamiltonianPath.get(i); - poses.add(map2[p.y][p.x]); - } - solution.add(poses); - } - }.start(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - public void tick() { - super.tick(); - if (!FeatureRegistry.SOLVER_ICEPATH.isEnabled()) return; - while (!messageQueue.isEmpty()){ - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(messageQueue.poll())); - } - } - - @Override - public void drawWorld(float partialTicks) { - if (!FeatureRegistry.SOLVER_ICEPATH.isEnabled()) return; - for (List solution:this.solution) - RenderUtils.drawLines(solution, FeatureRegistry.SOLVER_ICEPATH.getLineColor(),FeatureRegistry.SOLVER_ICEPATH.getLineWidth(), partialTicks, true); - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorIcePath2 createNew(DungeonRoom dungeonRoom) { - RoomProcessorIcePath2 defaultRoomProcessor = new RoomProcessorIcePath2(dungeonRoom); - return defaultRoomProcessor; - } - } - - private static List findFirstHamiltonianPath(int[][] map, int startX, int startY, int endX, int endY) { - int emptySpace =0; - for (int y = 0; y < map.length; y++) - for (int x = 0; x < map[y].length; x++) - if (map[y][x] == 0) emptySpace++; - - map[startY][startX] = 2; - - return findHamiltonianPath(map, startX, startY, endX, endY, 0, emptySpace-1); - } - - - private static final List directions = Arrays.asList(new Point(0,-1), new Point(-1,0), new Point(1,0), new Point(0,1)); - private static LinkedList findHamiltonianPath(int[][] map, int startX, int startY, int endX, int endY, int depth, int reqDepth) { - if (endX == startX && endY == startY) { - if (depth != reqDepth) return null; - LinkedList path = new LinkedList(); - path.add(new Point(startX, startY)); - return path; - } - - for (Point p : directions) { - int y = p.y +startY,x=p.x + startX; - if (y <0 || y >= map.length || x <0 || x >= map[0].length || map[y][x] != 0) continue; - - int[][] copiedMap = new int[map.length][map[0].length]; - for (int y2 = 0; y2 < copiedMap.length; y2++) - copiedMap[y2] = map[y2].clone(); - copiedMap[y][x] = 2; - - LinkedList potentialRoute = findHamiltonianPath(copiedMap, x,y,endX,endY, depth +1, reqDepth); - if (potentialRoute != null) { - potentialRoute.addFirst(new Point(x,y)); - return potentialRoute; - } - } - return null; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverState.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverState.java deleted file mode 100755 index 54bfe3c8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverState.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class LeverState { - private String blockId; - private boolean requiredState; - - public LeverState invert() { - return new LeverState(blockId, !requiredState); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverStateContradict.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverStateContradict.java deleted file mode 100755 index c9d5642e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/LeverStateContradict.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; - -public class LeverStateContradict extends LeverState { - public LeverStateContradict() { - super("contradict", true); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java deleted file mode 100755 index bc278f1f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/RoomProcessorWaterPuzzle.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.roomprocessor.GeneralRoomProcessor; -import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.util.BlockPos; - -import java.awt.*; -import java.util.List; - -public class RoomProcessorWaterPuzzle extends GeneralRoomProcessor { - - private boolean argumentsFulfilled = false; - - private WaterBoard waterBoard; - private final OffsetPointSet doorsClosed; - private final OffsetPointSet levers; - private final OffsetPointSet frontBoard; - private final OffsetPointSet backBoard; - private final OffsetPoint water_lever; - - public RoomProcessorWaterPuzzle(DungeonRoom dungeonRoom) { - super(dungeonRoom); - frontBoard = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("front"); - backBoard = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("back"); - levers = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("levers"); - doorsClosed = (OffsetPointSet) dungeonRoom.getDungeonRoomInfo().getProperties().get("doors"); - water_lever = (OffsetPoint) dungeonRoom.getDungeonRoomInfo().getProperties().get("water-lever"); - - if (frontBoard == null || backBoard == null || levers == null || doorsClosed == null ||water_lever == null) { - argumentsFulfilled = false; - } else { - argumentsFulfilled = true; - - try { - waterBoard = new WaterBoard(this, frontBoard, backBoard, levers, doorsClosed, water_lever); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - public void tick() { - super.tick(); - if (!FeatureRegistry.SOLVER_WATERPUZZLE.isEnabled()) return; - if (!argumentsFulfilled) return; - try { - waterBoard.tick(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void drawScreen(float partialTicks) { - super.drawScreen(partialTicks); - } - - @Override - public void drawWorld(float partialTicks) { - super.drawWorld(partialTicks); - if (!FeatureRegistry.SOLVER_WATERPUZZLE.isEnabled()) return; - if (!argumentsFulfilled) return; - if (waterBoard == null) return; - - Route route = waterBoard.getCurrentRoute(); - if (route != null) { - int j = 1; - for (int i = 0; i < route.getConditionList().size(); i++) { - LeverState condition = route.getConditionList().get(i); - if (condition == null) continue; - SwitchData switchData = waterBoard.getValidSwitches().get(condition.getBlockId()); - if (switchData.getCurrentState(getDungeonRoom().getContext().getWorld()) != condition.isRequiredState()) { - - RenderUtils.highlightBlock(switchData.getSwitchLoc(), new Color(0,255,0,50), partialTicks, true); - RenderUtils.drawTextAtWorld("#"+j,switchData.getSwitchLoc().getX(), switchData.getSwitchLoc().getY()+1, switchData.getSwitchLoc().getZ(), 0xFF000000,0.1f, false, false, partialTicks); - RenderUtils.drawTextAtWorld(condition.isRequiredState() ? "on":"off",switchData.getSwitchLoc().getX(), switchData.getSwitchLoc().getY(), switchData.getSwitchLoc().getZ(), 0xFF000000,0.1f, false, false, partialTicks); - j++; - } - } - for (WaterNode node : route.getNodes()) { - RenderUtils.highlightBlock(node.getBlockPos(), new Color(0,255,255,50), partialTicks, true); - } - } - List targets = waterBoard.getTarget(); - if (targets != null) { - for (BlockPos target : targets) { - RenderUtils.highlightBlock(target, new Color(0,255,255,100), partialTicks, true); - } - RenderUtils.highlightBlock(waterBoard.getToggleableMap().get("mainStream").getBlockPos(), new Color(0,255,0,255), partialTicks, true); - } - } - - public static class Generator implements RoomProcessorGenerator { - @Override - public RoomProcessorWaterPuzzle createNew(DungeonRoom dungeonRoom) { - RoomProcessorWaterPuzzle defaultRoomProcessor = new RoomProcessorWaterPuzzle(dungeonRoom); - return defaultRoomProcessor; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java deleted file mode 100755 index 8a2ca544..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/Route.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; - -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes.WaterNodeEnd; -import lombok.Data; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -@Data -public class Route implements Cloneable, Comparable { - private Set nodes = new LinkedHashSet(); - private List conditionList = new ArrayList(); - private Set endingNodes = new HashSet(); - - - private int matches = 0; - private int stateFlops = 0; - private int notMatches = 0; - - public double calculateCost() { - return (1.0/matches) * 50 + stateFlops * 20 + notMatches * 10000; - } - - @Override - protected Route clone() { - Route r = new Route(); - r.getNodes().addAll(nodes); - r.getConditionList().addAll(conditionList); - r.getEndingNodes().addAll(endingNodes); - return r; - } - - @Override - public int compareTo(@NotNull Object o) { - if (o instanceof Route) { - double var0 = calculateCost(); - double var1 = ((Route)o).calculateCost(); - return Double.compare(var0, var1); - } - return 0; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/SwitchData.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/SwitchData.java deleted file mode 100755 index df28846d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/SwitchData.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; - -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes.WaterNodeStart; -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes.WaterNodeToggleable; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -@Data -@AllArgsConstructor -public class SwitchData { - private WaterBoard waterBoard; - - private BlockPos switchLoc; - private BlockPos blockLoc; - - private String blockId; - - public boolean getCurrentState(World w) { - WaterNode waterNode = waterBoard.getToggleableMap().get(blockId); - if (waterNode instanceof WaterNodeStart) - return ((WaterNodeStart) waterNode).isTriggered(w); - else if (waterNode instanceof WaterNodeToggleable) - return ((WaterNodeToggleable) waterNode).isTriggered(w); - return false; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java deleted file mode 100755 index c2d1a187..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterBoard.java +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes.*; -import lombok.Getter; -import net.minecraft.block.Block; -import net.minecraft.block.BlockLever; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Tuple; -import net.minecraft.world.World; - -import java.util.*; -import java.util.List; - -public class WaterBoard { - @Getter - WaterNode[][] board; - RoomProcessorWaterPuzzle waterPuzzle; - - private final OffsetPointSet frontPlate; - private final OffsetPointSet backPlate; - private final OffsetPointSet levers; - private final OffsetPointSet doors; - private final OffsetPoint lever; - - @Getter - private final List switchData = new ArrayList(); - @Getter - private final Map validSwitches = new HashMap(); - - private WaterNodeStart waterNodeStart; - private final Map waterNodeEndMap = new HashMap(); - - @Getter - private final Map toggleableMap = new HashMap(); - - @Getter - private Set reqOpen = new HashSet(); - @Getter - private Route currentRoute; - @Getter - private List target; - @Getter - private List target2; - - public WaterBoard(RoomProcessorWaterPuzzle roomProcessorWaterPuzzle, OffsetPointSet frontPlate, OffsetPointSet backPlate, OffsetPointSet levers, OffsetPointSet doors, OffsetPoint leverMain) { - this.waterPuzzle = roomProcessorWaterPuzzle; - this.frontPlate = frontPlate; - this.backPlate = backPlate; - this.levers = levers; - this.doors = doors; - this.lever = leverMain; - - buildLeverStates(); - buildNodes(); - } - - private void buildLeverStates(){ - for (OffsetPoint offsetPoint : levers.getOffsetPointList()) { - if (offsetPoint.getBlock(waterPuzzle.getDungeonRoom()) == Blocks.lever){ - BlockPos pos = offsetPoint.getBlockPos(waterPuzzle.getDungeonRoom()); - World w= waterPuzzle.getDungeonRoom().getContext().getWorld(); - BlockLever.EnumOrientation enumOrientation = w.getBlockState(pos).getValue(BlockLever.FACING); - EnumFacing enumFacing = enumOrientation.getFacing(); - BlockPos newPos = pos.add(-enumFacing.getDirectionVec().getX(),0,-enumFacing.getDirectionVec().getZ()); - - int id = Block.getIdFromBlock(w.getChunkFromBlockCoords(newPos).getBlock(newPos)); - int data = w.getChunkFromBlockCoords(newPos).getBlockMetadata(newPos); - - SwitchData sw; - switchData.add(sw = new SwitchData(this, pos,newPos,id+":"+data)); - validSwitches.put(id+":"+data, sw); - } - } - SwitchData sw; - switchData.add(sw = new SwitchData(this, lever.getBlockPos(waterPuzzle.getDungeonRoom()),lever.getBlockPos(waterPuzzle.getDungeonRoom()).add(0,-1,0),"mainStream")); - validSwitches.put("mainStream", sw); - } - - public void tick() { - Set doorsToOpen = new HashSet(); - for (OffsetPoint offsetPoint : doors.getOffsetPointList()) { - Block b =offsetPoint.getBlock(waterPuzzle.getDungeonRoom()); - if (b != Blocks.air) { - doorsToOpen.add(Block.getIdFromBlock(b)+":"+offsetPoint.getData(waterPuzzle.getDungeonRoom())); - } - } -// if (!(reqOpen.containsAll(doorsToOpen) && doorsToOpen.containsAll(reqOpen))) { - reqOpen = doorsToOpen; - if (doorsToOpen.size() != 0) { - Set ends = new HashSet(); - for (String s : doorsToOpen) { - ends.add(waterNodeEndMap.get(s)); - } - currentRoute = getBestRoute(ends); -// { -// -// Set currentState = new HashSet(); -// World w = waterPuzzle.getDungeonRoom().getContext().getWorld(); -// for (SwitchData switchDatum : this.switchData) { -// currentState.add(new LeverState(switchDatum.getBlockId(), switchDatum.getCurrentState(w))); -// } -// currentRoute = simulate(currentState); -// } - - target = new ArrayList(); - target2 = new ArrayList(); - if (currentRoute != null) { - for (WaterNodeEnd endingNode : currentRoute.getEndingNodes()) { - target.add(endingNode.getBlockPos()); - target2.add(endingNode.getResultId()); - } - } - } -// } - } - - public Route getBestRoute(Set potentialEnds) { - int totalStates = (int) Math.pow(2, validSwitches.size() - 1); - List switchData = new ArrayList(); - Set currentState = new HashSet(); - World w = waterPuzzle.getDungeonRoom().getContext().getWorld(); - for (SwitchData switchDatum : this.switchData) { - if (!switchDatum.getBlockId().equals("mainStream")) { - switchData.add(switchDatum); - } - currentState.add(new LeverState(switchDatum.getBlockId(), switchDatum.getCurrentState(w))); - } - PriorityQueue routes = new PriorityQueue(); - - for (int i = 0; i < totalStates; i++) { - Set states = new HashSet(); - for (int i1 = 0; i1 < switchData.size(); i1++) { - states.add(new LeverState(switchData.get(i1).getBlockId(), ((i >> i1) & 0x1) > 0)); - } - states.add(new LeverState("mainStream", true)); - - Route r = simulate(states); - - for (LeverState leverState : currentState) { - if (!states.contains(leverState)) - r.setStateFlops(r.getStateFlops() + 1); - } - for (WaterNodeEnd potentialEnd : r.getEndingNodes()) { - if (potentialEnds.contains(potentialEnd)) { - r.setMatches(r.getMatches() + 1); - } else { - r.setNotMatches(r.getNotMatches() + 1); - } - } - if (r.getMatches() > 0) - routes.add(r); - } - - - return routes.peek(); - } - - public Route simulate(Set leverStates) { - leverStates.add(null); - Route r = new Route(); - final Queue toGoDownTo = new LinkedList(); - Set searched = new HashSet(); - Set waterBlockingStates = new HashSet(); - World w = waterPuzzle.getDungeonRoom().getContext().getWorld(); -// toGoDownTo.add(getNodeAt(waterNodeStart.getX(), waterNodeStart.getY() + 1)); - { - Queue> toGo = new LinkedList<>(); - toGo.add(new Tuple<>(waterNodeStart, true)); - toGoDownTo.add(getNodeAt(waterNodeStart.getX(), waterNodeStart.getY() + 1)); - Set visited = new HashSet<>(); - while (!toGo.isEmpty()) { - Tuple waterNode = toGo.poll(); - if (waterNode.getFirst() == null) continue; - if (visited.contains(waterNode.getFirst())) continue; - if (!waterNode.getFirst().canWaterGoThrough()) continue; - if (waterNode.getFirst() instanceof WaterNodeEnd) continue; - visited.add(waterNode.getFirst()); - - boolean water = waterNode.getFirst().isWaterFilled(w); - if (water && !waterNode.getSecond()) { - toGoDownTo.add(getNodeAt(waterNode.getFirst().getX(), waterNode.getFirst().getY())); - } - - int x = waterNode.getFirst().getX(), y = waterNode.getFirst().getY(); - toGo.add(new Tuple<>(getNodeAt(x+1, y), water)); - toGo.add(new Tuple<>(getNodeAt(x-1, y), water)); - toGo.add(new Tuple<>(getNodeAt(x, y+1), water)); - } - } - while (!toGoDownTo.isEmpty()) { - WaterNode asd = toGoDownTo.poll(); - if (asd == null) continue; - if (searched.contains(asd)) continue; - searched.add(asd); - - if (asd instanceof WaterNodeEnd) { - if (!asd.isWaterFilled(w)) - r.getEndingNodes().add((WaterNodeEnd) asd); - continue; - } - - r.getNodes().add(asd); - - if (asd.isWaterFilled(w) && ( - (getNodeAt(asd.getX() + 1, asd.getY()) != null && getNodeAt(asd.getX() + 1, asd.getY()).isWaterFilled(w)) - || (getNodeAt(asd.getX() - 1, asd.getY()) != null && getNodeAt(asd.getX() - 1, asd.getY()).isWaterFilled(w)))) { - boolean followWater = getNodeAt(asd.getX() - 1, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() - 1, asd.getY()).getCondition()) - && getNodeAt(asd.getX() - 2, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() - 2, asd.getY()).getCondition()); - for (int i = asd.getX(); i < asd.getX() + 8; i++) { - WaterNode nodehere = getNodeAt(i, asd.getY()); - if (nodehere == null) break; - if (followWater && !nodehere.isWaterFilled(w)) break; - if (!nodehere.canWaterGoThrough()) break; - if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break; - if (nodehere.getCondition() != null && leverStates.contains(nodehere.getCondition().invert()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition().invert()); - WaterNode down = getNodeAt(i, asd.getY() + 1); - if (i != asd.getX()) - followWater = nodehere.isWaterFilled(w) && (down == null || (down.canWaterGoThrough() && leverStates.contains(down.getCondition()))); - r.getNodes().add(nodehere); - if (down != null && down.canWaterGoThrough() && down.getCondition() != null && leverStates.contains(down.getCondition().invert())) { - waterBlockingStates.add(down.getCondition().invert()); - } - if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) { - toGoDownTo.add(down); - if (!followWater) break; - } - } - followWater = getNodeAt(asd.getX() +1, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() + 1, asd.getY()).getCondition()) - && getNodeAt(asd.getX() +2, asd.getY()) != null && leverStates.contains(getNodeAt(asd.getX() + 2, asd.getY()).getCondition()); - for (int i = asd.getX(); i > asd.getX() - 8; i--) { - WaterNode nodehere = getNodeAt(i, asd.getY()); - if (nodehere == null) break; - if (followWater && !nodehere.isWaterFilled(w)) break; - if (!nodehere.canWaterGoThrough()) break; - if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break; - if (nodehere.getCondition() != null && leverStates.contains(nodehere.getCondition().invert()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition().invert()); - WaterNode down = getNodeAt(i, asd.getY() + 1); - if (i != asd.getX()) - followWater = nodehere.isWaterFilled(w) && (down == null || (down.canWaterGoThrough() && leverStates.contains(down.getCondition()))); - r.getNodes().add(nodehere); - if (down != null && down.canWaterGoThrough() && down.getCondition() != null && leverStates.contains(down.getCondition().invert())) { - waterBlockingStates.add(down.getCondition().invert()); - } - if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) { - toGoDownTo.add(down); - if (!followWater) break; - } - } - } else { - int minDistToDropRight = 9999; - for (int i = asd.getX(); i < asd.getX() + 8; i++) { - WaterNode nodehere = getNodeAt(i, asd.getY()); - if (nodehere == null) break; - if (!nodehere.canWaterGoThrough()) break; - if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break; - WaterNode down = getNodeAt(i, asd.getY() + 1); - if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())))) { - int dist = i - asd.getX(); - if (dist < minDistToDropRight) - minDistToDropRight = dist; - break; - } - } - int minDistToDropLeft = 9999; - for (int i = asd.getX(); i > asd.getX() - 8; i--) { - WaterNode nodehere = getNodeAt(i, asd.getY()); - if (nodehere == null) break; - if (!nodehere.canWaterGoThrough()) break; - if (!leverStates.contains(nodehere.getCondition()) && !nodehere.isWaterFilled(w)) break; - WaterNode down = getNodeAt(i, asd.getY() + 1); - if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())))) { - int dist = asd.getX() - i; - if (dist < minDistToDropLeft) - minDistToDropLeft = dist; - break; - } - } - - int min = Math.min(minDistToDropRight, minDistToDropLeft); - if (min == 9999) continue; - if (minDistToDropRight == min) { - for (int i = asd.getX(); i <= asd.getX() + minDistToDropRight; i++) { - WaterNode nodehere = getNodeAt(i, asd.getY()); - if (nodehere.getCondition() != null && leverStates.contains(nodehere.getCondition().invert()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition().invert()); - r.getNodes().add(nodehere); - WaterNode down = getNodeAt(i, asd.getY() + 1); - if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) { - toGoDownTo.add(down); - } - if (down != null && down.canWaterGoThrough() && down.getCondition() != null && leverStates.contains(down.getCondition().invert())) { - waterBlockingStates.add(down.getCondition().invert()); - } - } - } - if (minDistToDropLeft == min) { - for (int i = asd.getX(); i >= asd.getX() - minDistToDropLeft; i--) { - WaterNode nodehere = getNodeAt(i, asd.getY()); - if (nodehere.getCondition() != null && leverStates.contains(nodehere.getCondition().invert()) && nodehere.isWaterFilled(w)) waterBlockingStates.add(nodehere.getCondition().invert()); - r.getNodes().add(nodehere); - WaterNode down = getNodeAt(i, asd.getY() + 1); - if (down != null && ((down.canWaterGoThrough() && leverStates.contains(down.getCondition())) || down.isWaterFilled(w))) { - toGoDownTo.add(down); - } - if (down != null && down.canWaterGoThrough() && down.getCondition() != null && leverStates.contains(down.getCondition().invert())) { - waterBlockingStates.add(down.getCondition().invert()); - } - } - } - } - } - ArrayList state = new ArrayList(waterBlockingStates); - state.remove(null); - Collections.sort(state, new Comparator() { - @Override - public int compare(LeverState leverState, LeverState t1) { - int var0 = toggleableMap.get(leverState.getBlockId()).getY(); - int var1 = toggleableMap.get(t1.getBlockId()).getY(); - return var0 < var1 ? -1 : (var0 == var1 ? 0 : 1); - } - }); - LinkedList states = new LinkedList(state); - for (LeverState ls : leverStates) { - if (!states.contains(ls)) { - states.add(ls); - } - } - states.remove(null); - - - r.setConditionList(states); - return r; - } - - - public WaterNode getNodeAt(int x, int y) { - if (x < 0 || y < 0) return null; - if (x >= board[0].length || y >= board.length) return null; - return board[y][x]; - } - - private void buildNodes() { - List frontPoints = frontPlate.getOffsetPointList(); - List backPoints = backPlate.getOffsetPointList(); - - board = new WaterNode[25][19]; - for (int x = 0; x < 19; x++) { - for (int y = 0; y < 25; y++) { - OffsetPoint front = frontPoints.get(x *25 +y); - OffsetPoint back = backPoints.get(x * 25 +y); - int frontId = Block.getIdFromBlock(front.getBlock(waterPuzzle.getDungeonRoom())); - int backId = Block.getIdFromBlock(back.getBlock(waterPuzzle.getDungeonRoom())); - int frontData = front.getData(waterPuzzle.getDungeonRoom()); - int backData = back.getData(waterPuzzle.getDungeonRoom()); - WaterNode node; - if (validSwitches.containsKey(backId +":"+backData)) { - String resId = backId + ":"+backData; - node = new WaterNodeToggleable(resId, isSwitchActive(validSwitches.get(resId)), front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); - - toggleableMap.put(resId, node); - } else if (validSwitches.containsKey(frontId +":"+frontData)) { - String resId = frontId +":"+frontData; - node = new WaterNodeToggleable(resId, !isSwitchActive(validSwitches.get(resId)), front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); - - toggleableMap.put(resId, node); - } else if (frontId == 0 || frontId == 8 || frontId == 9) { - if (y == 24) { - OffsetPoint pos; - if (x != 0) { - pos = frontPoints.get((x-1)*25+y); - } else { - pos = frontPoints.get((x+1) * 25 +y); - } - - int id = Block.getIdFromBlock(pos.getBlock(waterPuzzle.getDungeonRoom())); - int data= pos.getData(waterPuzzle.getDungeonRoom()); - node = new WaterNodeEnd(id+":"+data, front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); - waterNodeEndMap.put(id+":"+data, (WaterNodeEnd) node); - } else if (y == 2 && x == 9) { - waterNodeStart = (WaterNodeStart) (node = new WaterNodeStart(front.getBlockPos(waterPuzzle.getDungeonRoom()), - frontId != 0 ^ isSwitchActive(validSwitches.get("mainStream")),x,y)); - } else { - node = new WaterNodeAir(front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); - } - } else { - node = new WaterNodeWall(front.getBlockPos(waterPuzzle.getDungeonRoom()),x,y); - } - board[y][x] =node; - } - } - toggleableMap.put("mainStream", waterNodeStart); - } - - private boolean isSwitchActive(SwitchData switchData) { - BlockPos switch2 = switchData.getSwitchLoc(); - World w= waterPuzzle.getDungeonRoom().getContext().getWorld(); - boolean bool = w.getBlockState(switch2).getValue(BlockLever.POWERED); - return bool; - } - - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java deleted file mode 100755 index 69011818..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/WaterNode.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; - -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -public interface WaterNode { - boolean canWaterGoThrough(); - - // condition for water go - LeverState getCondition(); - - boolean isWaterFilled(World w); - - BlockPos getBlockPos(); - - int getX(); - int getY(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java deleted file mode 100755 index 28d57349..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeAir.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes; - -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState; -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -@Data -@AllArgsConstructor -public class WaterNodeAir implements WaterNode { - BlockPos blockPos; - @Override - public boolean canWaterGoThrough() { - return true; - } - - @Override - public LeverState getCondition() { - return null; - } - - @Override - public boolean isWaterFilled(World w) { - Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); - return b == Blocks.water || b == Blocks.flowing_water; - } - - public BlockPos getBlockPos() { - return blockPos; - } - - private int x,y; - - public String toString() { - return "A"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java deleted file mode 100755 index 54efdb09..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeEnd.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes; - -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState; -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -@Data -@AllArgsConstructor -public class WaterNodeEnd implements WaterNode { - private String resultId; - BlockPos blockPos; - - @Override - public boolean canWaterGoThrough() { - return true; - } - - @Override - public LeverState getCondition() { - return null; - } - - @Override - public boolean isWaterFilled(World w) { - Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); - return b == Blocks.water || b == Blocks.flowing_water; - } - - public BlockPos getBlockPos() { - return blockPos; - } - private int x,y; - - public String toString() { - return "E"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java deleted file mode 100755 index 9c02c057..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeStart.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes; - -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState; -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -@Data -@AllArgsConstructor -public class WaterNodeStart implements WaterNode { - - private BlockPos blockPos; - private boolean isReversed; - - @Override - public boolean canWaterGoThrough() { - return true; - } - - @Override - public LeverState getCondition() { - return new LeverState("mainStream", !isReversed); - } - - @Override - public boolean isWaterFilled(World w) { - Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); - return b == Blocks.water || b == Blocks.flowing_water; - } - - public boolean isTriggered(World w) { - return isWaterFilled(w); - } - - - public BlockPos getBlockPos() { - return blockPos; - } - private int x,y; - - public String toString() { - return "S"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java deleted file mode 100755 index 9cbd6f9b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeToggleable.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes; - -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState; -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -@Data -@AllArgsConstructor -public class WaterNodeToggleable implements WaterNode { - private String blockId; - private boolean invert; - - BlockPos blockPos; - - @Override - public boolean canWaterGoThrough() { - return true; - } - - @Override - public LeverState getCondition() { - return new LeverState(blockId, invert); - } - - - @Override - public boolean isWaterFilled(World w) { - Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); - return b == Blocks.water || b == Blocks.flowing_water; - } - private int x,y; - - public boolean isTriggered(World w) { - Block b= w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); - - return !(b == Blocks.air || b == Blocks.water || b == Blocks.flowing_water) ^ invert; - } - - - public BlockPos getBlockPos() { - return blockPos; - } - - - public String toString() { - return "T:"+blockId+(invert ? ":Y":":N"); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java deleted file mode 100755 index 8fc6241b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/nodes/WaterNodeWall.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes; - -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.LeverState; -import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.WaterNode; -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -@Data -@AllArgsConstructor -public class WaterNodeWall implements WaterNode { - - BlockPos blockPos; - @Override - public boolean canWaterGoThrough() { - return false; - } - - @Override - public LeverState getCondition() { - return null; - } - - - @Override - public boolean isWaterFilled(World w) { - Block b = w.getChunkFromBlockCoords(blockPos).getBlock(blockPos); - return b == Blocks.water || b == Blocks.flowing_water; - } - - private int x,y; - - public BlockPos getBlockPos() { - return blockPos; - } - - - public String toString() { - return "W"; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordActivity.java b/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordActivity.java deleted file mode 100644 index f25022f2..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordActivity.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.rpc; - -import kr.syeyoung.dungeonsguide.gamesdk.GameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordActivity; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordActivityType; -import lombok.Data; - -@Data -public class JDiscordActivity { - private EDiscordActivityType activityType; - private long applicationId; - private String name, state, details; - private long start, end; - private String largeImage, largeText, smallImage, smallText; - private String partyId; - private int partyCurr, partyMax; - private String matchSecret, joinSecret, spectateSecret; - private boolean instance; - - public static JDiscordActivity fromJNA(DiscordActivity discordActivity) { - if (discordActivity == null) return null; - JDiscordActivity jDiscordActivity = new JDiscordActivity(); - jDiscordActivity.activityType = discordActivity.activityType; - jDiscordActivity.applicationId = discordActivity.applicationId.longValue(); - jDiscordActivity.name = GameSDK.readString(discordActivity.name); - jDiscordActivity.state = GameSDK.readString(discordActivity.state); - jDiscordActivity.details = GameSDK.readString(discordActivity.details); - if (discordActivity.assets != null) { - jDiscordActivity.largeImage = GameSDK.readString(discordActivity.assets.large_image); - jDiscordActivity.largeText = GameSDK.readString(discordActivity.assets.large_text); - jDiscordActivity.smallImage = GameSDK.readString(discordActivity.assets.small_image); - jDiscordActivity.smallText = GameSDK.readString(discordActivity.assets.small_text); - } - if (discordActivity.timestamps != null) { - jDiscordActivity.start = discordActivity.timestamps.start.longValue(); - jDiscordActivity.end = discordActivity.timestamps.end.longValue(); - } - if (discordActivity.secrets != null) { - jDiscordActivity.matchSecret= GameSDK.readString(discordActivity.secrets.match); - jDiscordActivity.joinSecret = GameSDK.readString(discordActivity.secrets.join); - jDiscordActivity.spectateSecret = GameSDK.readString(discordActivity.secrets.spectate); - } - if (discordActivity.party != null) { - jDiscordActivity.partyId = GameSDK.readString(discordActivity.party.id); - if (discordActivity.party.discordActivityParty != null) { - jDiscordActivity.partyCurr = discordActivity.party.discordActivityParty.current_size.intValue(); - jDiscordActivity.partyMax = discordActivity.party.discordActivityParty.max_size.intValue(); - } - } - jDiscordActivity.instance = discordActivity.instance; - - return jDiscordActivity; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordRelation.java b/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordRelation.java deleted file mode 100644 index 3086c936..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordRelation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.rpc; - -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordRelationship; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordRelationshipType; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.EDiscordStatus; -import lombok.Data; - -@Data -public class JDiscordRelation { - private EDiscordRelationshipType discordRelationshipType; - private EDiscordStatus status; - private JDiscordActivity discordActivity; - private JDiscordUser discordUser; - - public static JDiscordRelation fromJNA(DiscordRelationship relationship) { - JDiscordRelation jDiscordRelation = new JDiscordRelation(); - jDiscordRelation.discordUser = JDiscordUser.fromJNA(relationship.user); - jDiscordRelation.discordActivity = JDiscordActivity.fromJNA(relationship.presence.activity); - jDiscordRelation.status = relationship.presence.status; - jDiscordRelation.discordRelationshipType = relationship.type; - return jDiscordRelation; - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordUser.java b/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordUser.java deleted file mode 100644 index 635ac405..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/rpc/JDiscordUser.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.rpc; - -import kr.syeyoung.dungeonsguide.gamesdk.GameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.DiscordUser; -import lombok.Data; - -@Data -public class JDiscordUser { - private long id; - private String username, discriminator, avatar; - private boolean bot; - - public static JDiscordUser fromJNA(DiscordUser discordUser) { - JDiscordUser jDiscordUser = new JDiscordUser(); - jDiscordUser.id = discordUser.id.longValue(); - jDiscordUser.username = GameSDK.readString(discordUser.username); - jDiscordUser.discriminator = GameSDK.readString(discordUser.discriminator); - jDiscordUser.avatar = GameSDK.readString(discordUser.avatar); - jDiscordUser.bot = discordUser.bot; - return jDiscordUser; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/rpc/RichPresenceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/rpc/RichPresenceManager.java deleted file mode 100644 index 5ff9852b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/rpc/RichPresenceManager.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.rpc; - -import com.sun.jna.Pointer; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.PointerByReference; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.chat.PartyContext; -import kr.syeyoung.dungeonsguide.chat.PartyManager; -import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.events.DiscordUserJoinRequestEvent; -import kr.syeyoung.dungeonsguide.events.DiscordUserUpdateEvent; -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import kr.syeyoung.dungeonsguide.gamesdk.GameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.NativeGameSDK; -import kr.syeyoung.dungeonsguide.gamesdk.jna.datastruct.*; -import kr.syeyoung.dungeonsguide.gamesdk.jna.enumuration.*; -import kr.syeyoung.dungeonsguide.gamesdk.jna.interfacestruct.*; -import kr.syeyoung.dungeonsguide.gamesdk.jna.typedef.*; -import lombok.Getter; -import net.minecraftforge.common.MinecraftForge; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -public class RichPresenceManager implements Runnable { - public static RichPresenceManager INSTANCE = new RichPresenceManager(); - private Thread t = new Thread(this); - - public RichPresenceManager() { - t.start(); - } - @Getter - private NativeGameSDK nativeGameSDK; - @Getter - private IDiscordCore iDiscordCore; - private IDiscordActivityManager activityManager; - private IDiscordRelationshipManager relationshipManager; - private IDiscordActivityEvents.ByReference callbacks; - private IDiscordRelationshipEvents.ByReference relation_callbacks; - - @Getter - private Map relationMap = new HashMap<>(); - - private boolean ready = false; - - @Getter - private int lastSetupCode = -99999; - public int setup() { - ready = false; - if (iDiscordCore != null) { - iDiscordCore.Destroy.destroy(iDiscordCore); - iDiscordCore = null; - activityManager = null; callbacks = null; relation_callbacks = null; relationMap.clear(); - } - - nativeGameSDK = GameSDK.getNativeGameSDK(); - if (nativeGameSDK == null) return -9999; - DiscordCreateParams discordCreateParams = new DiscordCreateParams(); - discordCreateParams.flags = new UInt64(EDiscordCreateFlags.DiscordCreateFlags_NoRequireDiscord.getValue()); - discordCreateParams.client_id = new DiscordClientID(816298079732498473L); - - callbacks = new IDiscordActivityEvents.ByReference(); - callbacks.OnActivityInvite = (eventData, type, user, activity) -> { - try { - MinecraftForge.EVENT_BUS.post(new DiscordUserJoinRequestEvent(user, true)); - } catch (Throwable t) { - t.printStackTrace(); - } - System.out.println("Received Join Request from "+user.id.longValue()+" ("+GameSDK.readString(user.username)+")"); - }; - callbacks.OnActivityJoin = (eventData, secret) -> { - PartyManager.INSTANCE.joinWithToken(secret); - System.out.println("Trying to join with token "+secret); - }; - callbacks.OnActivityJoinRequest = (eventData, user) -> { - try { - MinecraftForge.EVENT_BUS.post(new DiscordUserJoinRequestEvent(user, false)); - } catch (Throwable t) { - t.printStackTrace(); - } - System.out.println("Received Join Request from "+user.id.longValue()+" - "+GameSDK.readString(user.username)); - }; - callbacks.OnActivitySpectate = (eventData, secret) -> { - }; - callbacks.write(); - - relation_callbacks = new IDiscordRelationshipEvents.ByReference(); - relation_callbacks.OnRefresh = (p) -> { - try { - ready = true; - IDiscordRelationshipManager iDiscordRelationshipManager = iDiscordCore.GetRelationshipManager.getRelationshipManager(iDiscordCore); - iDiscordRelationshipManager.Filter.filter(iDiscordRelationshipManager, Pointer.NULL, (d, relation) -> true); - IntByReference intByReference = new IntByReference(); - iDiscordRelationshipManager.Count.count(iDiscordRelationshipManager, intByReference); - int count = intByReference.getValue(); - relationMap.clear(); - for (int i = 0; i < count; i++) { - DiscordRelationship discordRelationship = new DiscordRelationship(); - iDiscordRelationshipManager.GetAt.getAt(iDiscordRelationshipManager, new UInt32(i), discordRelationship); - - JDiscordRelation jDiscordRelation = JDiscordRelation.fromJNA(discordRelationship); - relationMap.put(jDiscordRelation.getDiscordUser().getId(), jDiscordRelation); - } - } catch (Throwable e) {e.printStackTrace();} - }; - relation_callbacks.OnRelationshipUpdate = (p, rel) -> { - try { - JDiscordRelation jDiscordRelation = JDiscordRelation.fromJNA(rel); - JDiscordRelation prev = relationMap.put(jDiscordRelation.getDiscordUser().getId(), jDiscordRelation); - MinecraftForge.EVENT_BUS.post(new DiscordUserUpdateEvent(prev, jDiscordRelation)); - } catch (Throwable t) { - t.printStackTrace(); - } - }; - relation_callbacks.write(); - - discordCreateParams.activity_events = callbacks; - discordCreateParams.relationship_events = relation_callbacks; // 96 - - PointerByReference pointerByReference = new PointerByReference(); - discordCreateParams.write(); - - EDiscordResult eDiscordResult = nativeGameSDK.DiscordCreate(new DiscordVersion(NativeGameSDK.DISCORD_VERSION), discordCreateParams, pointerByReference); - if (eDiscordResult != EDiscordResult.DiscordResult_Ok) return eDiscordResult.getValue(); - if (pointerByReference.getValue() == Pointer.NULL) return -9998; - iDiscordCore = new IDiscordCore(pointerByReference.getValue()); - - iDiscordCore.SetLogHook.setLogHook(iDiscordCore, EDiscordLogLevel.DiscordLogLevel_Debug, Pointer.NULL, new IDiscordCore.LogHook() { - @Override - public void hook(Pointer hookData, EDiscordLogLevel level, String message) { - System.out.println(message+" - "+level+" - "+hookData); - } - }); - - activityManager = iDiscordCore.GetActivityManager.getActivityManager(iDiscordCore); - relationshipManager = iDiscordCore.GetRelationshipManager.getRelationshipManager(iDiscordCore); - - return eDiscordResult.getValue(); - } - - private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); - - public void respond(DiscordSnowflake userID, EDiscordActivityJoinRequestReply reply) { - if (activityManager == null) return; - activityManager.SendRequestReply.sendRequestReply(activityManager, userID, reply, Pointer.NULL, (callbackData, result) -> { - System.out.println("Discord Returned "+result+" For Replying "+reply+" To "+userID.longValue()+"L"); - }); - } - - public void accept(DiscordSnowflake userID) { - if (activityManager == null) return; - activityManager.AcceptInvite.acceptInvite(activityManager, userID, Pointer.NULL, (callbackData, result) -> { - System.out.println("Discord Returned "+result+" For Accepting invite from "+userID.longValue()+"L"); - }); - } - public void updatePresence() { - if (!skyblockStatus.isOnHypixel() || !FeatureRegistry.DISCORD_RICHPRESENCE.isEnabled() || (!skyblockStatus.isOnSkyblock() && FeatureRegistry.DISCORD_RICHPRESENCE.getParameter("disablenotskyblock").getValue())) { - activityManager.ClearActivity.clearActivity(activityManager, Pointer.NULL, (callbackData, result) -> { - }); - } else { - String name = skyblockStatus.getDungeonName() == null ? "" : skyblockStatus.getDungeonName(); - if (!skyblockStatus.isOnSkyblock()) name ="Somewhere on Hypixel"; - if (name.trim().equals("Your Island")) name = "Private Island"; - - DiscordActivity latestDiscordActivity = new DiscordActivity(); - latestDiscordActivity.assets = new DiscordActivityAssets(); - latestDiscordActivity.secrets = new DiscordActivitySecrets(); - latestDiscordActivity.party = new DiscordActivityParty(); - latestDiscordActivity.party.discordActivityParty = new DiscordPartySize(); - latestDiscordActivity.timestamps = new DiscordActivityTimestamps(); - GameSDK.writeString(latestDiscordActivity.assets.large_image, "mort"); - GameSDK.writeString(latestDiscordActivity.assets.large_text, "mort"); - GameSDK.writeString(latestDiscordActivity.state, name); - - GameSDK.writeString(latestDiscordActivity.party.id, Optional.ofNullable( PartyManager.INSTANCE.getPartyContext()).map(PartyContext::getPartyID).orElse("")); - latestDiscordActivity.party.discordActivityParty.current_size = new Int32(Optional.ofNullable(PartyManager.INSTANCE.getPartyContext()).map(PartyContext::getPartyRawMembers).map(Set::size).orElse(1)); - latestDiscordActivity.party.discordActivityParty.max_size = new Int32(PartyManager.INSTANCE.getMaxParty()); - - if (skyblockStatus.getContext() != null) { - DungeonContext dungeonContext = skyblockStatus.getContext(); - long init = dungeonContext.getInit(); - latestDiscordActivity.timestamps.start = new DiscordTimestamp(init); - - if (dungeonContext.getBossfightProcessor() != null) { - GameSDK.writeString(latestDiscordActivity.details, "Fighting "+dungeonContext.getBossfightProcessor().getBossName()+": "+dungeonContext.getBossfightProcessor().getCurrentPhase()); - } else { - GameSDK.writeString(latestDiscordActivity.details, "Clearing Rooms"); - } - } else { - latestDiscordActivity.timestamps.start = new DiscordTimestamp(0); - GameSDK.writeString(latestDiscordActivity.details, "Dungeons Guide"); - } - if (PartyManager.INSTANCE.getAskToJoinSecret() != null) { - GameSDK.writeString(latestDiscordActivity.secrets.join, PartyManager.INSTANCE.getAskToJoinSecret()); - } else { - GameSDK.writeString(latestDiscordActivity.secrets.join, ""); - } - activityManager.UpdateActivity.updateActivity(activityManager, latestDiscordActivity, Pointer.NULL, (callbackData, result) -> { - }); - } - } - - @Override - public void run() { - boolean setup = true; - int counter = 0; - while(!Thread.interrupted()) { - try { - if (iDiscordCore == null || setup) { - long lastSetup = lastSetupCode; - lastSetupCode = setup(); - if (lastSetup != lastSetupCode) - System.out.println("Discord returned "+lastSetupCode+" for setup "+EDiscordResult.fromValue(lastSetupCode)); - setup = lastSetupCode != EDiscordResult.DiscordResult_Ok.getValue(); - counter = 0; - } else { - EDiscordResult eDiscordResult = iDiscordCore.RunCallbacks.runCallbacks(iDiscordCore); - if (eDiscordResult != EDiscordResult.DiscordResult_Ok) { - setup = true; - } else if (ready){ - if (counter == 0) - updatePresence(); - if (++counter == 15) counter = 0; - } - } - Thread.sleep(16L); - } catch (Exception e) {e.printStackTrace();} - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/CloseListener.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/CloseListener.java deleted file mode 100644 index fdb177a3..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/CloseListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.stomp; - -public interface CloseListener { - void onClose(int code, String reason, boolean remote); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompClient.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompClient.java deleted file mode 100644 index 7226c1d6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompClient.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.stomp; - -import lombok.Getter; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.handshake.ServerHandshake; -import org.java_websocket.server.DefaultSSLWebSocketServerFactory; -import sun.security.ssl.SSLSocketFactoryImpl; - -import javax.net.ssl.*; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.Socket; -import java.net.URI; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -public class StompClient extends WebSocketClient implements StompInterface { - public StompClient(URI serverUri, final String token, CloseListener closeListener) throws Exception { - super(serverUri); - this.closeListener = closeListener; - addHeader("Authorization", token); - - System.out.println("connecting websocket"); - if (!connectBlocking()) { - throw new RuntimeException("Can't connect to ws"); - } - System.out.println("connected, stomp handshake"); - while(this.stompClientStatus == StompClientStatus.CONNECTING); - System.out.println("fully connected"); - } - private final CloseListener closeListener; - - @Getter - private volatile StompClientStatus stompClientStatus = StompClientStatus.CONNECTING; - - @Getter - private StompPayload errorPayload; - - private ScheduledFuture heartbeat = null; - - private static final ScheduledExecutorService ex = Executors.newScheduledThreadPool(1); - - @Override - public void onOpen(ServerHandshake handshakedata) { - send(new StompPayload().method(StompHeader.CONNECT) - .header("accept-version","1.2") - .header("heart-beat", "30000,30000") - .header("host",uri.getHost()).getBuilt() - ); - } - - @Override - public void onMessage(String message) { - try { - StompPayload payload = StompPayload.parse(message); - if (payload.method() == StompHeader.CONNECTED) { - stompClientStatus = StompClientStatus.CONNECTED; - - String heartbeat = payload.headers().get("heart-beat"); - if (heartbeat != null) { -// int sx = Integer.parseInt(heartbeat.split(",")[0]); -// int sy = Integer.parseInt(heartbeat.split(",")[1]); -// -// if (sy == 0) return; - int heartbeatMS = 30000; - this.heartbeat = ex.scheduleAtFixedRate(() -> { - send("\n"); - }, heartbeatMS-1000, heartbeatMS-1000, TimeUnit.MILLISECONDS); - } - - } else if (payload.method() == StompHeader.ERROR) { - errorPayload = payload; - stompClientStatus = StompClientStatus.ERROR; - this.close(); - } else if (payload.method() == StompHeader.MESSAGE) { - // mesage - StompSubscription stompSubscription = stompSubscriptionMap.get(Integer.parseInt(payload.headers().get("subscription"))); - try { - stompSubscription.getStompMessageHandler().handle(this, payload); - if (stompSubscription.getAckMode() != StompSubscription.AckMode.AUTO) { - send(new StompPayload().method(StompHeader.ACK) - .header("id",payload.headers().get("ack")).getBuilt() - ); - } - } catch (Exception e) { - e.printStackTrace(); - if (stompSubscription.getAckMode() != StompSubscription.AckMode.AUTO) { - send(new StompPayload().method(StompHeader.NACK) - .header("id",payload.headers().get("ack")).getBuilt() - ); - } - } - } else if (payload.method() == StompHeader.RECEIPT) { - String receipt_id = payload.headers().get("receipt-id"); - StompPayload payload1 = receiptMap.remove(Integer.parseInt(receipt_id)); - if (payload1.method() == StompHeader.DISCONNECT) { - stompClientStatus = StompClientStatus.DISCONNECTED; - close(); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void onClose(int code, String reason, boolean remote) { - if (heartbeat != null) heartbeat.cancel(true); - closeListener.onClose(code, reason, remote); - } - - @Override - public void onError(Exception ex) { - ex.printStackTrace(); - } - - private final Map stompSubscriptionMap = new HashMap(); - private final Map receiptMap = new HashMap(); - - private int idIncrement = 0; - - @Override - public void send(StompPayload payload) { - if (stompClientStatus != StompClientStatus.CONNECTED) throw new IllegalStateException("not connected"); - payload.method(StompHeader.SEND); - if (payload.headers().get("receipt") != null) - receiptMap.put(Integer.parseInt(payload.headers().get("receipt")), payload); - send(payload.getBuilt()); - } - - @Override - public void subscribe(StompSubscription stompSubscription) { - if (stompClientStatus != StompClientStatus.CONNECTED) throw new IllegalStateException("not connected"); - stompSubscription.setId(++idIncrement); - - send(new StompPayload().method(StompHeader.SUBSCRIBE) - .header("id",String.valueOf(stompSubscription.getId())) - .header("destination", stompSubscription.getDestination()) - .header("ack", stompSubscription.getAckMode().getValue()).getBuilt() - ); - - stompSubscriptionMap.put(stompSubscription.getId(), stompSubscription); - } - - @Override - public void unsubscribe(StompSubscription stompSubscription) { - if (stompClientStatus != StompClientStatus.CONNECTED) throw new IllegalStateException("not connected"); - send(new StompPayload().method(StompHeader.UNSUBSCRIBE) - .header("id",String.valueOf(stompSubscription.getId())).getBuilt() - ); - stompSubscriptionMap.remove(stompSubscription.getId()); - } - - @Override - public void disconnect() { - if (stompClientStatus != StompClientStatus.CONNECTED) throw new IllegalStateException("not connected"); - StompPayload stompPayload; - stompClientStatus =StompClientStatus.DISCONNECTING; - send((stompPayload = new StompPayload().method(StompHeader.DISCONNECT) - .header("receipt", String.valueOf(++idIncrement))) - .getBuilt() - ); - receiptMap.put(idIncrement, stompPayload); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompClientStatus.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompClientStatus.java deleted file mode 100644 index ef3f907c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompClientStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.stomp; - -public enum StompClientStatus { - CONNECTING, CONNECTED, ERROR, DISCONNECTING, DISCONNECTED -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompHeader.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompHeader.java deleted file mode 100644 index f0b7a06b..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompHeader.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.stomp; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; - -public enum StompHeader { - SEND, SUBSCRIBE, UNSUBSCRIBE, BEGIN, COMMIT, ABORT, ACK, NACK, DISCONNECT, CONNECT, STOMP, CONNECTED, MESSAGE, RECEIPT, ERROR -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompInterface.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompInterface.java deleted file mode 100644 index 8244fd58..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompInterface.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.stomp; - -public interface StompInterface { - void send(StompPayload payload); - void subscribe(StompSubscription stompSubscription); - void unsubscribe(StompSubscription stompSubscription); - void disconnect(); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompMessageHandler.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompMessageHandler.java deleted file mode 100644 index 8b3efd77..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompMessageHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.stomp; - -public interface StompMessageHandler { - void handle(StompInterface stompInterface, StompPayload stompPayload); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java deleted file mode 100644 index 27b1cdc9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.stomp; - -import kr.syeyoung.dungeonsguide.features.FeatureRegistry; -import lombok.Data; -import lombok.Singular; -import lombok.experimental.Accessors; - -import java.util.*; - -@Data -@Accessors(chain = true, fluent = true) -public class StompPayload { - private StompHeader method; - private Map headers = new HashMap(); - private String payload; - - public StompPayload header(String key, String value) { - headers.put(key, value); - return this; - } - - public String getBuilt() { - StringBuilder sb = new StringBuilder(); - sb.append(method.name()); - sb.append("\n"); - for (Map.Entry stringStringEntry : headers.entrySet()) { - sb.append(stringStringEntry.getKey()); - sb.append(":"); - sb.append(stringStringEntry.getValue()); - sb.append("\n"); - if (stringStringEntry.getKey().contains(":")) throw new IllegalStateException("Illegal Character : inside headers"); - if (stringStringEntry.getValue().contains(":")) throw new IllegalStateException("Illegal Character : inside headers"); - } - sb.append("\n"); - if (payload != null) - sb.append(payload); - sb.append((char) 0); - if (FeatureRegistry.DEBUG.isEnabled()) System.out.println("Sending.. "+sb.toString()); - return sb.toString(); - } - - public static StompPayload parse(String payload) { - if (FeatureRegistry.DEBUG.isEnabled()) System.out.println("Receving.. "+payload); - - Scanner scanner = new Scanner(payload); - StompPayload stompPayload = new StompPayload(); - stompPayload.method = StompHeader.valueOf(scanner.nextLine()); - String line = ""; - while (!(line = scanner.nextLine()).isEmpty()) { - int index = line.indexOf(":"); - if (index == -1) throw new IllegalArgumentException("No : found in headers section"); - String name = line.substring(0, index); - String value; - if (index == line.length() - 1) - value = ""; - else - value = line.substring(index+1); - stompPayload.headers.put(name, value); - } - - List lines = new ArrayList(); - while (scanner.hasNextLine() && !(line = scanner.nextLine()).equals("\0")) { - lines.add(line); - } - stompPayload.payload = String.join("\n", lines); - return stompPayload; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompSubscription.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompSubscription.java deleted file mode 100644 index 790ba344..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompSubscription.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.stomp; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.Getter; - -@Data -@Builder -public class StompSubscription { - private int id; - private String destination; - private StompMessageHandler stompMessageHandler; - private AckMode ackMode; - - @AllArgsConstructor - public enum AckMode { - AUTO("auto"), CLIENT("client"), CLIENT_INDIVIDUAL("client-individual"); - - @Getter - private final String value; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/url/DGConnection.java b/src/main/java/kr/syeyoung/dungeonsguide/url/DGConnection.java index 725abab9..6e9520ef 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/url/DGConnection.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/url/DGConnection.java @@ -18,18 +18,20 @@ package kr.syeyoung.dungeonsguide.url; -import kr.syeyoung.dungeonsguide.Authenticator; +import kr.syeyoung.dungeonsguide.auth.ResourceManager; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.net.URLConnection; public class DGConnection extends URLConnection { - private final Authenticator authenticator; - protected DGConnection(URL url, Authenticator a) { + + protected DGConnection(URL url) { super(url); connected = false; - this.authenticator = a; } @Override @@ -37,10 +39,10 @@ public class DGConnection extends URLConnection { } @Override public InputStream getInputStream() throws IOException { - if (authenticator != null) { + if (ResourceManager.getInstance().getResources() != null) { String path = url.getPath().substring(1); - if (!authenticator.getResources().containsKey(path)) throw new FileNotFoundException(); - return new ByteArrayInputStream(authenticator.getResources().get(path)); + if (!ResourceManager.getInstance().getResources().containsKey(path)) throw new FileNotFoundException(); + return new ByteArrayInputStream(ResourceManager.getInstance().getResources().get(path)); } throw new FileNotFoundException(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandler.java b/src/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandler.java index bc6fa10d..f740848f 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandler.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandler.java @@ -18,7 +18,6 @@ package kr.syeyoung.dungeonsguide.url; -import kr.syeyoung.dungeonsguide.Authenticator; import lombok.AllArgsConstructor; import java.io.IOException; @@ -28,9 +27,8 @@ import java.net.URLStreamHandler; @AllArgsConstructor public class DGStreamHandler extends URLStreamHandler { - private final Authenticator auth; @Override protected URLConnection openConnection(URL url) throws IOException { - return new DGConnection(url, this.auth); + return new DGConnection(url); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandlerFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandlerFactory.java index 9f574a86..00b1e5f2 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandlerFactory.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandlerFactory.java @@ -18,7 +18,6 @@ package kr.syeyoung.dungeonsguide.url; -import kr.syeyoung.dungeonsguide.Authenticator; import lombok.AllArgsConstructor; import java.net.URLStreamHandler; @@ -26,11 +25,10 @@ import java.net.URLStreamHandlerFactory; @AllArgsConstructor public class DGStreamHandlerFactory implements URLStreamHandlerFactory { - private final Authenticator auth; @Override public URLStreamHandler createURLStreamHandler(String protocol) { if ("z".equals(protocol)) { - return new DGStreamHandler(this.auth); + return new DGStreamHandler(); } return null; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/AhUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/AhUtils.java deleted file mode 100644 index 049f8a0d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/AhUtils.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -import java.security.*; -import java.security.cert.CertificateException; -import java.util.HashMap; -import java.util.Map; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.DungeonsGuide; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import java.util.Timer; -import java.util.TimerTask; - -public class AhUtils { - public static volatile Map auctions = new HashMap(); - - public static Timer timer = new Timer(); - - public static int totalAuctions = 0; - - public static void registerTimer() { - timer.schedule(new TimerTask() { - public void run() { - try { - AhUtils.loadAuctions(); - } catch (CertificateException | NoSuchAlgorithmException | InvalidKeyException | InvalidAlgorithmParameterException | NoSuchPaddingException | BadPaddingException | KeyStoreException | IllegalBlockSizeException | KeyManagementException e) { - e.printStackTrace(); - } - } - }, 0L, 1800000L); - } - - public static void loadAuctions() throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchPaddingException, BadPaddingException, KeyStoreException, IllegalBlockSizeException, KeyManagementException { - try { - - Map semi_auctions = new HashMap(); - JsonElement object = DungeonsGuide.getDungeonsGuide().getAuthenticator().getJsonSecured("https://dungeons.guide/resource/keys"); - for (JsonElement element : object.getAsJsonArray()) { - JsonObject object1 = element.getAsJsonObject(); - AuctionData auctionData = new AuctionData(object1.get("id").getAsString()); - auctionData.lowestBin = object1.get("lowestBin").getAsInt(); - auctionData.sellPrice = object1.get("sellPrice").getAsInt(); - auctionData.buyPrice = object1.get("buyPrice").getAsInt(); - semi_auctions.put(auctionData.id, auctionData); - } - auctions = semi_auctions; - } catch (Throwable e) { - e.printStackTrace(); - } - } - - public static class AuctionData { - public String id; - - public long lowestBin = -1; - - public int sellPrice = -1; - - public int buyPrice = -1; - - public AuctionData(String id) { - this.id = id; - } - } -} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java deleted file mode 100755 index 8b84da13..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -public class ArrayUtils { - public static int[][] rotateCounterClockwise(int[][] arr) { - int[][] res = new int[arr[0].length][arr.length]; - for(int y=0; y. - */ - -package kr.syeyoung.dungeonsguide.utils; - -import com.sun.org.apache.xpath.internal.operations.Bool; -import net.minecraft.client.renderer.GlStateManager; - -import java.lang.reflect.Field; -import java.util.*; - -public class GlStateUtils { - public static Map dumpStates() { - Map primitiveDump = new LinkedHashMap<>(); - try { - recursivelyDump(primitiveDump, "GlStateManager", null, GlStateManager.class); - } catch (IllegalAccessException e) { - e.printStackTrace(); - primitiveDump.put("$ERROR", true); - } - return primitiveDump; - } - - public static void printDump(Map dump) { - for (Map.Entry stringObjectEntry : dump.entrySet()) { - System.out.println(stringObjectEntry+": "+stringObjectEntry.getValue()); - } - } - - public static void compareDump(Map dump1, Map dump2) { - Set set = new HashSet<>(); - set.addAll(dump1.keySet()); - set.addAll(dump2.keySet()); - - for (String s : set) { - Object obj1 = dump1.get(s); - Object obj2 = dump2.get(s); - if (!Objects.equals(obj1, obj2)) System.out.println(s+": Prev {"+obj1+"} New {"+obj2+"}"); - } - } - - public static void recursivelyDump(Map primitiveDump, String objPath, Object obj, Class clazz) throws IllegalAccessException { - primitiveDump.put(objPath+".$class", clazz.getName()); - for (Field declaredField : clazz.getDeclaredFields()) { - declaredField.setAccessible(true); - Object fieldData = declaredField.get(obj); - if (fieldData.getClass().getName().startsWith("java.lang")) { - primitiveDump.put(objPath+"."+declaredField.getName(), fieldData); - } else { - recursivelyDump(primitiveDump, objPath+"."+declaredField.getName(), fieldData, fieldData.getClass()); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/MapUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/MapUtils.java deleted file mode 100755 index 8fb90ec1..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/MapUtils.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -import lombok.Getter; -import net.minecraft.block.material.MapColor; -import org.w3c.dom.css.Rect; - -import javax.vecmath.Vector2d; -import java.awt.*; -import java.awt.image.BufferedImage; - -public class MapUtils { - - private static Color[] colorMasks = new Color[128 * 128]; - @Getter - private static byte[] colors; - - public static void clearMap() { - colorMasks = new Color[128 * 128]; - colors = null; - } - - public static void record(byte[] colors, int x, int y, Color c) { - MapUtils.colors = colors; - colorMasks[y *128 +x] = c; - } - - public static byte getMapColorAt(byte[] colors, int x, int y) { - if (y <0 || y>= 128 || x < 0 || x >= 128) return 0; - return colors[y * 128 +x]; - } - - public static BufferedImage getImage() { - BufferedImage bufferedImage = new BufferedImage(128, 128,BufferedImage.TYPE_INT_ARGB); - if (colors == null) return bufferedImage; - Graphics graphics = bufferedImage.getGraphics(); - for (int y = 0; y < 128; y++) { - for (int x = 0; x <128; x++) { - bufferedImage.setRGB(x,y, getRGBColorAt(colors, x, y)); - if (colorMasks[y * 128 + x] != null) { - graphics.setColor(colorMasks[y *128 +x]); - graphics.drawLine(x,y,x,y); - } - } - } - return bufferedImage; - } - - public static int getRGBColorAt(byte[] colors, int x, int y) { - if (y <0 || y>= 128 || x < 0 || x >= 128) return 0; - int i = y * 128 +x; - int j = colors[i] & 255; - - int theColor; - if (j / 4 == 0) - { - theColor = (i + i / 128 & 1) * 8 + 16 << 24; - } - else - { - theColor = MapColor.mapColorArray[j / 4].getMapColor(j & 3); - } - - return theColor; - } - - public static Point findFirstColorWithIn(byte[] colors, byte color, Rectangle dimension) { - boolean found = true; - for (int y = dimension.y; y < (dimension.y + dimension.height);y++) { - for (int x = dimension.x; x < (dimension.x + dimension.width); x ++) { - if (getMapColorAt(colors, x ,y) == color && found) { - record(colors, x, y, new Color(255, 0, 0, 40)); - return new Point(x,y); - } - found = getMapColorAt(colors, x,y) == 0; - } - } - return null; - } - - public static Point findFirstColorWithInNegate(byte[] colors, byte color, Rectangle dimension) { - for (int y = dimension.y; y < (dimension.y + dimension.height);y++) { - for (int x = dimension.x; x < (dimension.x + dimension.width); x ++) { - if (getMapColorAt(colors, x ,y) != color) { - record(colors, x, y, new Color(255, 0, 0, 40)); - return new Point(x,y); - } - } - } - return null; - } - - public static int getWidthOfColorAt(byte[] colors, byte color, Point point) { - for (int x = point.x; x < 128; x++) { - record(colors, x, point.y, new Color(0, 255, 0, 40)); - if (getMapColorAt(colors, x, point.y) != color) return x - point.x; - } - return 128 - point.x; - } - public static int getHeightOfColorAt(byte[] colors, byte color, Point point) { - for (int y = point.y; y < 128; y++) { - record(colors, point.x, y, new Color(0, 255, 0, 40)); - if (getMapColorAt(colors, point.x,y) != color) return y - point.y; - } - return 128 - point.y; - } - - public static int getLengthOfColorExtending(byte[] colors, byte color, Point basePoint, Vector2d vector2d) { - for (int i = 0; i < 128; i++) { - int x = (int) (basePoint.x + vector2d.x * i); - int y = (int) (basePoint.y + vector2d.y * i); - record(colors, x, y, new Color(0, 0, 255, 40)); - if (getMapColorAt(colors, x,y) != color) return i; - } - return -1; - } - - - public static boolean matches(byte[] colors, byte[] stencil, int targetColor, int x, int y) { - for (int i = y; i < y + stencil.length; i++) { - for (int j = x; j < x + 8; j++) { - boolean current = getMapColorAt(colors, j, i) == targetColor; - boolean expected = ((stencil[i - y] >> (7-(j-x))) & 0x1) == 1; - if (current != expected) return false; - } - } - return true; - } - - public static int readDigit(byte[] colors, int x, int y) { - for (int i = 0; i < NUMBER_STENCIL.length; i++) { - if (matches(colors, NUMBER_STENCIL[i],34, x, y)) return i; - } - return -1; - } - public static int readNumber(byte[] colors, int x, int y, int gap) { - int number = 0; - for (int i = x; i < 128; i += gap) { - int digit = readDigit(colors, i, y); - if (digit != -1) number = number * 10 + digit; - } - return number; - } - - private static final byte[][] NUMBER_STENCIL = { - {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, - {0x0, 0x1E, 0x1E, 0x1E, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x77, 0x77, 0x7, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x7F, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x7, 0x7, 0x1F, 0x1F, 0x7, 0x7, 0x7F, 0x7F, 0x7F, 0x0}, - {0x0, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x7F, 0x7F, 0x7F, 0xE, 0xE, 0xE, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x7, 0x77, 0x77, 0x7F, 0x7F, 0x7F, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x0}, - {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x3E, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, - {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x7, 0x7F, 0x7F, 0x7F, 0x0} - }; - - - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java deleted file mode 100755 index 18f09cb0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ /dev/null @@ -1,1377 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.util.*; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import javax.vecmath.Vector3f; -import java.awt.*; -import java.util.List; - -public class RenderUtils { - public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); - private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png"); - - /** - * Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0 - * And modified to fit out need. - * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE - * @author Moulberry - */ - public static void renderBeaconBeam(double x, double y, double z, AColor aColor, float partialTicks) { - Entity player = Minecraft.getMinecraft().thePlayer; - double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; - double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; - double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; -//because of the way 3D rendering is done, all coordinates are relative to the camera. This "resets" the "0,0,0" position to the location that is (0,0,0) in the world. - - - GlStateManager.pushMatrix(); - GlStateManager.translate(-playerX, -playerY, -playerZ); - int height = 300; - int bottomOffset = 0; - int topOffset = bottomOffset + height; - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - - Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GlStateManager.disableLighting(); - GlStateManager.disableDepth(); - GlStateManager.enableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - - double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double)partialTicks; - double d1 = MathHelper.func_181162_h(-time * 0.2D - (double)MathHelper.floor_double(-time * 0.1D)); - - int c = getColorAt(x,y,z, aColor); - float alpha = ((c >> 24) & 0xFF) / 255.0f; - - float r = ((c >> 16) & 0xFF) / 255f; - float g = ((c >> 8) & 0xFF) / 255f; - float b = (c & 0xFF) / 255f; - double d2 = time * 0.025D * -1.5D; - double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D; - double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D; - double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D; - double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D; - double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D; - double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D; - double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D; - double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D; - double d14 = -1.0D + d1; - double d15 = (double)(height) * 2.5D + d14; - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); - tessellator.draw(); - - double d12 = -1.0D + d1; - double d13 = height + d12; - - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - tessellator.draw(); - - GlStateManager.enableDepth(); - - GlStateManager.popMatrix(); - } - - - public static void drawTexturedRect(float x, float y, float width, float height, int filter) { - drawTexturedRect(x, y, width, height, 0.0F, 1.0F, 0.0F, 1.0F, filter); - } - private static float zLevel = 0; - public static int scrollY = 0; - public static boolean allowScrolling; - public static int scrollX = 0; - - public static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) - { - float f = (float)(startColor >> 24 & 255) / 255.0F; - float f1 = (float)(startColor >> 16 & 255) / 255.0F; - float f2 = (float)(startColor >> 8 & 255) / 255.0F; - float f3 = (float)(startColor & 255) / 255.0F; - float f4 = (float)(endColor >> 24 & 255) / 255.0F; - float f5 = (float)(endColor >> 16 & 255) / 255.0F; - float f6 = (float)(endColor >> 8 & 255) / 255.0F; - float f7 = (float)(endColor & 255) / 255.0F; - GlStateManager.disableTexture2D(); - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.shadeModel(7425); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldrenderer.pos((double)right, (double)top, (double)0).color(f1, f2, f3, f).endVertex(); - worldrenderer.pos((double)left, (double)top, (double)0).color(f1, f2, f3, f).endVertex(); - worldrenderer.pos((double)left, (double)bottom, (double)0).color(f5, f6, f7, f4).endVertex(); - worldrenderer.pos((double)right, (double)bottom, (double)0).color(f5, f6, f7, f4).endVertex(); - tessellator.draw(); - GlStateManager.shadeModel(7424); - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - } - - public static void drawRect(int left, int top, int right, int bottom, AColor color) - { - if (left < right) - { - int i = left; - left = right; - right = i; - } - - if (top < bottom) - { - int j = top; - top = bottom; - bottom = j; - } - - float f3 = (float)(color.getRGB() >> 24 & 255) / 255.0F; - float f = (float)(color.getRGB() >> 16 & 255) / 255.0F; - float f1 = (float)(color.getRGB() >> 8 & 255) / 255.0F; - float f2 = (float)(color.getRGB() & 255) / 255.0F; - if (!color.isChroma() && f3 == 0) return; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - if (!color.isChroma()) { - GlStateManager.color(f, f1, f2, f3); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - worldrenderer.pos(left, bottom, 0.0D).endVertex(); - worldrenderer.pos(right, bottom, 0.0D).endVertex(); - worldrenderer.pos(right, top, 0.0D).endVertex(); - worldrenderer.pos(left, top, 0.0D).endVertex(); - } else { - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - color(worldrenderer.pos(left, bottom, 0.0D), getColorAt(left, bottom, color)).endVertex(); - color(worldrenderer.pos(right, bottom, 0.0D), getColorAt(right, bottom, color)).endVertex(); - color(worldrenderer.pos(right, top, 0.0D), getColorAt(right, top, color)).endVertex(); - color(worldrenderer.pos(left, top, 0.0D), getColorAt(left, top, color)).endVertex(); - } - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - - - public static void drawRoundedRectangle(int x, int y, int width, int height, int radius, double delta, int color) { - GlStateManager.pushMatrix(); - GlStateManager.translate(width/2.0+x, height/2.0+y, 0); - Tessellator t = Tessellator.getInstance(); - GlStateManager.disableTexture2D(); - RenderUtils.GL_SETCOLOR(color); - WorldRenderer wr = t.getWorldRenderer(); - wr.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION); - for (double i = 0.1; i < Math.PI*2; i+= delta) { - double cos = MathHelper.cos((float) i); - double sin = MathHelper.sin((float) i); - if (cos * MathHelper.cos((float) (i + delta)) <= 0) { - wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius),0).endVertex(); - wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? -1 : 1) * (height/2.0 - radius),0).endVertex(); - } else if (sin * MathHelper.sin((float) (i+delta)) <= 0) { - wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); - wr.pos(sin * radius + (sin > 0 ? -1 : 1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); - } else { - wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); - } - } - t.draw(); - GlStateManager.popMatrix(); - } - - public static void GL_SETCOLOR(int color) { - float f3 = (float)(color >> 24 & 255) / 255.0F; - float f = (float)(color >> 16 & 255) / 255.0F; - float f1 = (float)(color >> 8 & 255) / 255.0F; - float f2 = (float)(color & 255) / 255.0F; - GlStateManager.color(f, f1, f2, f3); - } - - public static int blendTwoColors(int background, int newColor) { - float alpha = ((newColor >> 24) & 0xFF) /255.0f; - int r1 = (background >> 16) & 0xFF, r2 = (newColor >> 16) & 0xFF; - int g1 = (background >> 8) & 0xFF, g2 = (newColor >> 8) & 0xFF; - int b1 = (background) & 0xFF, b2 = (newColor) & 0xFF; - - int rr = (int) (r1 + (r2-r1) * alpha) & 0xFF; - int rg = (int) (g1 + (g2-g1) * alpha) & 0xFF; - int rb = (int) (b1 + (b2-b1) * alpha) & 0xFF; - return 0xFF000000 | ((rr << 16) & 0xFF0000) | ((rg << 8) & 0xFF00) | (rb & 0xFF); - } - - public static int blendAlpha(int origColor, float alphaPerc) { - return blendTwoColors(origColor, (int)(alphaPerc*255) << 24 | 0xFFFFFF); - } - - public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { - GlStateManager.enableTexture2D(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); - GL11.glTexParameteri(3553, 10241, filter); - GL11.glTexParameteri(3553, 10240, filter); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); - worldrenderer.pos(x + width, y + height, 0.0D).tex(uMax, vMax).endVertex(); - worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); - worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); - tessellator.draw(); - GL11.glTexParameteri(3553, 10241, 9728); - GL11.glTexParameteri(3553, 10240, 9728); - GlStateManager.disableBlend(); - } - public static void renderBar(float x, float y, float xSize, float completed) { - Minecraft.getMinecraft().getTextureManager().bindTexture(icons); - completed = (float)Math.round(completed / 0.05F) * 0.05F; - float notcompleted = 1.0F - completed; - int displayNum = 0; - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - float width = 0.0F; - if (completed < 0.5F && (displayNum == 1 || displayNum == 0)) { - width = (0.5F - completed) * xSize; - drawTexturedRect(x + xSize * completed, y, width, 5.0F, xSize * completed / 256.0F, xSize / 2.0F / 256.0F, 0.2890625F, 0.30859375F, 9728); - } - - if (completed < 1.0F && (displayNum == 2 || displayNum == 0)) { - width = Math.min(xSize * notcompleted, xSize / 2.0F); - drawTexturedRect(x + xSize / 2.0F + Math.max(xSize * (completed - 0.5F), 0.0F), y, width, 5.0F, (182.0F - xSize / 2.0F + Math.max(xSize * (completed - 0.5F), 0.0F)) / 256.0F, 0.7109375F, 0.2890625F, 0.30859375F, 9728); - } - - if (completed > 0.0F && (displayNum == 3 || displayNum == 0)) { - width = Math.min(xSize * completed, xSize / 2.0F); - drawTexturedRect(x, y, width, 5.0F, 0.0F, width / 256.0F, 0.30859375F, 0.328125F, 9728); - } - - if (completed > 0.5F && (displayNum == 4 || displayNum == 0)) { - width = Math.min(xSize * (completed - 0.5F), xSize / 2.0F); - drawTexturedRect(x + xSize / 2.0F, y, width, 5.0F, (182.0F - xSize / 2.0F) / 256.0F, (182.0F - xSize / 2.0F + width) / 256.0F, 0.30859375F, 0.328125F, 9728); - } - - } - - public static void drawUnfilledBox(int left, int top, int right, int bottom, int color, boolean chroma) - { - if (left < right) - { - int i = left; - left = right; - right = i; - } - - if (top < bottom) - { - int j = top; - top = bottom; - bottom = j; - } - - float f3 = (float)(color >> 24 & 255) / 255.0F; - float f = (float)(color >> 16 & 255) / 255.0F; - float f1 = (float)(color >> 8 & 255) / 255.0F; - float f2 = (float)(color & 255) / 255.0F; - if (!chroma && f3 == 0) return; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - if (!chroma) { - GlStateManager.color(f, f1, f2, f3); - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); - worldrenderer.pos(left, bottom, 0.0D).endVertex(); - worldrenderer.pos(right, bottom, 0.0D).endVertex(); - worldrenderer.pos(right, top, 0.0D).endVertex(); - worldrenderer.pos(left, top, 0.0D).endVertex(); - } else { - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR); - float blah = (System.currentTimeMillis() / 10) % 360; - GlStateManager.shadeModel(GL11.GL_SMOOTH); - color(worldrenderer.pos(left, bottom, 0.0D), Color.HSBtoRGB((((blah + 20) % 360) / 360.0f), 1, 1)).endVertex(); - color(worldrenderer.pos(right, bottom, 0.0D), Color.HSBtoRGB((((blah + 40) % 360) / 360.0f), 1, 1)).endVertex(); - color(worldrenderer.pos(right, top, 0.0D), Color.HSBtoRGB((((blah + 20) % 360) / 360.0f), 1, 1)).endVertex(); - color(worldrenderer.pos(left, top, 0.0D), Color.HSBtoRGB(blah / 360.0f, 1, 1)).endVertex(); - } - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - - - public static void drawUnfilledBox(int left, int top, int right, int bottom, AColor color) - { - if (left < right) - { - int i = left; - left = right; - right = i; - } - - if (top < bottom) - { - int j = top; - top = bottom; - bottom = j; - } - - float f3 = (float)(color.getRGB() >> 24 & 255) / 255.0F; - float f = (float)(color.getRGB() >> 16 & 255) / 255.0F; - float f1 = (float)(color.getRGB() >> 8 & 255) / 255.0F; - float f2 = (float)(color.getRGB() & 255) / 255.0F; - if (!color.isChroma() && f3 == 0) return; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - if (!color.isChroma()) { - GlStateManager.color(f, f1, f2, f3); - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); - worldrenderer.pos(left, bottom, 0.0D).endVertex(); - worldrenderer.pos(right, bottom, 0.0D).endVertex(); - worldrenderer.pos(right, top, 0.0D).endVertex(); - worldrenderer.pos(left, top, 0.0D).endVertex(); - } else { - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - color(worldrenderer.pos(left, bottom, 0.0D), getColorAt(left, bottom, color)).endVertex(); - color(worldrenderer.pos(right, bottom, 0.0D), getColorAt(right, bottom, color)).endVertex(); - color(worldrenderer.pos(right, top, 0.0D), getColorAt(right, top, color)).endVertex(); - color(worldrenderer.pos(left, top, 0.0D), getColorAt(left, top, color)).endVertex(); - } - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - - public static int getChromaColorAt(int x, int y, float speed, float s, float b, float alpha) { - double blah = ((double)(speed) * (System.currentTimeMillis() / 2)) % 360; - return (Color.HSBtoRGB((float) (((blah - (x + y) / 2.0f) % 360) / 360.0f), s,b) & 0xffffff) - | (((int)(alpha * 255)<< 24) & 0xff000000); - } - public static int getColorAt(double x, double y, AColor color) { - if (!color.isChroma()) - return color.getRGB(); - - double blah = ((double)(color.getChromaSpeed()) * (System.currentTimeMillis() / 2)) % 360; - float[] hsv = new float[3]; - Color.RGBtoHSB(color.getRed(), color.getBlue(), color.getGreen(), hsv); - - - return (Color.HSBtoRGB((float) (((blah - (x + y) / 2.0f) % 360) / 360.0f), hsv[1],hsv[2]) & 0xffffff) - | ((color.getAlpha() << 24) & 0xff000000); - } - public static int getColorAt(double x, double y,double z, AColor color) { - if (!color.isChroma()) - return color.getRGB(); - - double blah = ((double)(color.getChromaSpeed()) * (System.currentTimeMillis() / 2)) % 360; - float[] hsv = new float[3]; - Color.RGBtoHSB(color.getRed(), color.getBlue(), color.getGreen(), hsv); - - - return (Color.HSBtoRGB((float) (((blah - ((x + y+z) / 2.0f) % 360)) / 360.0f), hsv[1],hsv[2]) & 0xffffff) - | ((color.getAlpha() << 24) & 0xff000000); - } - - public static WorldRenderer color(WorldRenderer worldRenderer, int color ){ - return worldRenderer.color(((color >> 16) & 0xFF) / 255.0f, ((color >> 8) & 0xFF) / 255.0f, (color &0xFF) / 255.0f, ((color >> 24) & 0xFF) / 255.0f); - } - - public static void renderDoor(DungeonDoor dungeonDoor, float partialTicks) { - Entity player = Minecraft.getMinecraft().thePlayer; - double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; - double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; - double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; - - GlStateManager.pushMatrix(); - GlStateManager.translate(-playerX, -playerY, -playerZ); - GlStateManager.disableTexture2D(); - GlStateManager.enableAlpha(); - - if (dungeonDoor.getType().isExist()) - GlStateManager.color(0,1,0,1); - else - GlStateManager.color(1,0,0,1); - - double x = dungeonDoor.getPosition().getX() + 0.5; - double y = dungeonDoor.getPosition().getY() -0.99; - double z = dungeonDoor.getPosition().getZ() + 0.5; - GL11.glBegin(GL11.GL_QUADS); - - GL11.glVertex3d(x - 2.5, y, z - 2.5); - GL11.glVertex3d(x - 2.5, y, z + 2.5); - GL11.glVertex3d(x + 2.5, y, z + 2.5); - GL11.glVertex3d(x + 2.5, y, z - 2.5); - - GL11.glEnd(); - - if (dungeonDoor.getType().isExist()) { - GL11.glBegin(GL11.GL_QUADS); - - GlStateManager.color(0,0,1,1); - if (dungeonDoor.isZDir()) { - GL11.glVertex3d(x - 0.5, y + 0.1, z - 2.5); - GL11.glVertex3d(x - 0.5, y+ 0.1, z + 2.5); - GL11.glVertex3d(x + 0.5, y+ 0.1, z + 2.5); - GL11.glVertex3d(x + 0.5, y+ 0.1, z - 2.5); - } else { - GL11.glVertex3d(x - 2.5, y+ 0.1, z - 0.5); - GL11.glVertex3d(x - 2.5, y+ 0.1, z + 0.5); - GL11.glVertex3d(x + 2.5, y+ 0.1, z + 0.5); - GL11.glVertex3d(x + 2.5, y+ 0.1, z - 0.5); - } - - GL11.glEnd(); - } else { - GL11.glLineWidth(5); - GL11.glBegin(GL11.GL_LINE_LOOP); - GL11.glVertex3d(x - 2.5, y, z - 2.5); - GL11.glVertex3d(x + 2.5, y + 5, z - 2.5); - GL11.glVertex3d(x + 2.5, y, z + 2.5); - GL11.glVertex3d(x - 2.5, y + 5, z + 2.5); - GL11.glEnd(); - GL11.glBegin(GL11.GL_LINE_LOOP); - GL11.glVertex3d(x - 2.5, y +5, z - 2.5); - GL11.glVertex3d(x + 2.5, y, z - 2.5); - GL11.glVertex3d(x + 2.5, y + 5, z + 2.5); - GL11.glVertex3d(x - 2.5, y, z + 2.5); - GL11.glEnd(); - GL11.glLineWidth(1); - } -// GlStateManager.disableAlpha(); - GlStateManager.disableBlend(); - - GlStateManager.enableTexture2D(); - - - RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - - GlStateManager.translate( dungeonDoor.getPosition().getX(), dungeonDoor.getPosition().getY(), dungeonDoor.getPosition().getZ()); - GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); - GlStateManager.rotate(renderManager.playerViewX, 1.0f, 0.0f, 0.0f); - - float lScale = 0.02f; - GlStateManager.scale(-lScale, -lScale, lScale); - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - String text = "Type: "+dungeonDoor.getType(); - int textWidth = fontRenderer.getStringWidth(text); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fontRenderer.drawString(text, -textWidth / 2, 0, 0xFF00FFFF); - - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GlStateManager.popMatrix(); - } - - public static void drawLine(Vec3 pos1, Vec3 pos2, Color colour, float partialTicks , boolean depth) { - Entity render = Minecraft.getMinecraft().getRenderViewEntity(); - WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); - - double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks; - double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks; - double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks; - - GlStateManager.pushMatrix(); - GlStateManager.translate(-realX, -realY, -realZ); - GlStateManager.disableTexture2D(); - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GL11.glLineWidth(2); - GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f); - worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - - worldRenderer.pos(pos1.xCoord, pos1.yCoord, pos1.zCoord).endVertex(); - worldRenderer.pos(pos2.xCoord, pos2.yCoord, pos2.zCoord).endVertex(); - Tessellator.getInstance().draw(); - - GlStateManager.translate(realX, realY, realZ); - GlStateManager.disableBlend(); - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.popMatrix(); - } - - public static void drawLinesVec3(List poses, AColor colour, float thickness, float partialTicks, boolean depth) { - Entity render = Minecraft.getMinecraft().getRenderViewEntity(); - WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); - - double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks; - double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks; - double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks; - - GlStateManager.pushMatrix(); - GlStateManager.translate(-realX, -realY, -realZ); - GlStateManager.disableTexture2D(); - GlStateManager.disableLighting(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GL11.glLineWidth(thickness); - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - -// GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f); - GlStateManager.color(1,1,1,1); - worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); - int num = 0; - for (Vec3 pos:poses) { - int i = getColorAt(num++ * 10,0, colour); - worldRenderer.pos(pos.xCoord, pos.yCoord, pos.zCoord).color( - ((i >> 16) &0xFF)/255.0f, - ((i >> 8) &0xFF)/255.0f, - (i &0xFF)/255.0f, - ((i >> 24) &0xFF)/255.0f - ).endVertex(); - } - Tessellator.getInstance().draw(); - - GlStateManager.translate(realX, realY, realZ); - GlStateManager.disableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.popMatrix(); - GL11.glLineWidth(1); - } - public static void drawLines(List poses, AColor colour, float thickness, float partialTicks, boolean depth) { - Entity render = Minecraft.getMinecraft().getRenderViewEntity(); - WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); - - double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks; - double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks; - double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks; - - GlStateManager.pushMatrix(); - GlStateManager.translate(-realX, -realY, -realZ); - GlStateManager.disableTexture2D(); - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GL11.glLineWidth(thickness); - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - -// GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f); - GlStateManager.color(1,1,1,1); - worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); - int num = 0; - for (BlockPos pos:poses) { - int i = getColorAt(num++ * 10,0, colour); - worldRenderer.pos(pos.getX() +0.5, pos.getY() +0.5, pos.getZ() +0.5).color( - ((i >> 16) &0xFF)/255.0f, - ((i >> 8) &0xFF)/255.0f, - (i &0xFF)/255.0f, - ((i >> 24) &0xFF)/255.0f - ).endVertex(); - } - Tessellator.getInstance().draw(); - - GlStateManager.translate(realX, realY, realZ); - GlStateManager.disableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.popMatrix(); - GL11.glLineWidth(1); - } - - public static void drawLines(List poses, Color colour, float thickness, float partialTicks, boolean depth) { - if (colour instanceof AColor) drawLines(poses, (AColor)colour, thickness, partialTicks,depth); - Entity render = Minecraft.getMinecraft().getRenderViewEntity(); - WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); - - double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks; - double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks; - double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks; - - GlStateManager.pushMatrix(); - GlStateManager.translate(-realX, -realY, -realZ); - GlStateManager.disableTexture2D(); - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GL11.glLineWidth(thickness); - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - - GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f); - worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION); - for (BlockPos pos:poses) { - worldRenderer.pos(pos.getX() +0.5, pos.getY() +0.5, pos.getZ() +0.5).endVertex(); - } - Tessellator.getInstance().draw(); - - GlStateManager.translate(realX, realY, realZ); - GlStateManager.disableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.popMatrix(); - } - - public static void highlightBlock(BlockPos blockpos, Color c, float partialTicks) { - highlightBlock(blockpos,c,partialTicks,false); - } - public static void highlightBlock(BlockPos blockpos, Color c, float partialTicks, boolean depth) { - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.disableTexture2D(); - - if (!depth) { - GlStateManager.disableDepth(); GL11.glDisable(GL11.GL_DEPTH_TEST); - GlStateManager.depthMask(false); - } - GlStateManager.color(c.getRed() /255.0f, c.getGreen() / 255.0f, c.getBlue()/ 255.0f, c.getAlpha()/ 255.0f); - - GlStateManager.translate(blockpos.getX(), blockpos.getY(), blockpos.getZ()); - - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, 0, 1); - GL11.glVertex3d(0, 1, 1); - GL11.glVertex3d(0, 1, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(1, 0, 1); - GL11.glVertex3d(1, 0, 0); - GL11.glVertex3d(1, 1, 0); - GL11.glVertex3d(1, 1, 1); - - GL11.glVertex3d(0, 1, 1); - GL11.glVertex3d(0, 0, 1); - GL11.glVertex3d(1, 0, 1); - GL11.glVertex3d(1, 1, 1); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, 1, 0); - GL11.glVertex3d(1, 1, 0); - GL11.glVertex3d(1, 0, 0); - - GL11.glVertex3d(0,1,0); - GL11.glVertex3d(0,1,1); - GL11.glVertex3d(1,1,1); - GL11.glVertex3d(1,1,0); - - GL11.glVertex3d(0,0,1); - GL11.glVertex3d(0,0,0); - GL11.glVertex3d(1,0,0); - GL11.glVertex3d(1,0,1); - - - - GL11.glEnd(); - - - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.enableTexture2D(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - - -//... - - } - - public static void highlightBox(AxisAlignedBB axisAlignedBB, Color c, float partialTicks, boolean depth) { - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.disableTexture2D(); - - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - int rgb = c.getRGB(); - GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f); - - GlStateManager.translate(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ); - - double x = axisAlignedBB.maxX - axisAlignedBB.minX; - double y = axisAlignedBB.maxY - axisAlignedBB.minY; - double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, 0, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, y, z); - - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, y, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, 0, 0); - - GL11.glVertex3d(0,y,0); - GL11.glVertex3d(0,y,z); - GL11.glVertex3d(x,y,z); - GL11.glVertex3d(x,y,0); - - GL11.glVertex3d(0,0,z); - GL11.glVertex3d(0,0,0); - GL11.glVertex3d(x,0,0); - GL11.glVertex3d(x,0,z); - - - - GL11.glEnd(); - - - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.enableTexture2D(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - } - public static void highlightBoxAColor(AxisAlignedBB axisAlignedBB, AColor c, float partialTicks, boolean depth) { - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.disableTexture2D(); - - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - int rgb = RenderUtils.getColorAt(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ, c); - GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f); - - GlStateManager.translate(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ); - - double x = axisAlignedBB.maxX - axisAlignedBB.minX; - double y = axisAlignedBB.maxY - axisAlignedBB.minY; - double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, 0, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, y, z); - - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, y, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, 0, 0); - - GL11.glVertex3d(0,y,0); - GL11.glVertex3d(0,y,z); - GL11.glVertex3d(x,y,z); - GL11.glVertex3d(x,y,0); - - GL11.glVertex3d(0,0,z); - GL11.glVertex3d(0,0,0); - GL11.glVertex3d(x,0,0); - GL11.glVertex3d(x,0,z); - - - - GL11.glEnd(); - - - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.enableTexture2D(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - } - public static void highlightBox(Entity entity, AxisAlignedBB axisAlignedBB, AColor c, float partialTicks, boolean depth) { - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.disableTexture2D(); - - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - int rgb = RenderUtils.getColorAt(entity.posX * 10,entity.posY * 10,c); - GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f); - if (axisAlignedBB == null) { - if (entity instanceof EntityArmorStand) { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); - } else if (entity instanceof EntityBat) { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.4, -0.4, 0.4, 0.4, 0.4); - } else { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); - } - } - - Vec3 renderPos = new Vec3( - (float) (entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks), - (float) (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks), - (float) (entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks) - ); - GlStateManager.translate(axisAlignedBB.minX + renderPos.xCoord, axisAlignedBB.minY + renderPos.yCoord, axisAlignedBB.minZ + renderPos.zCoord); - - double x = axisAlignedBB.maxX - axisAlignedBB.minX; - double y = axisAlignedBB.maxY - axisAlignedBB.minY; - double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, 0, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, y, z); - - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, y, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, 0, 0); - - GL11.glVertex3d(0,y,0); - GL11.glVertex3d(0,y,z); - GL11.glVertex3d(x,y,z); - GL11.glVertex3d(x,y,0); - - GL11.glVertex3d(0,0,z); - GL11.glVertex3d(0,0,0); - GL11.glVertex3d(x,0,0); - GL11.glVertex3d(x,0,z); - - - - GL11.glEnd(); - - - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.enableTexture2D(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - } - - public static void highlightBox(Entity entity, AxisAlignedBB axisAlignedBB, Color c, float partialTicks, boolean depth) { - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.disableTexture2D(); - - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - GlStateManager.color(c.getRed()/ 255.0f, c.getGreen()/ 255.0f, c.getBlue()/ 255.0f, c.getAlpha()/ 255.0f); - if (axisAlignedBB == null) { - if (entity instanceof EntityArmorStand) { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); - } else if (entity instanceof EntityBat) { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.4, -0.4, 0.4, 0.4, 0.4); - } else { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); - } - } - - Vec3 renderPos = new Vec3( - (float) (entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks), - (float) (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks), - (float) (entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks) - ); - GlStateManager.translate(axisAlignedBB.minX + renderPos.xCoord, axisAlignedBB.minY + renderPos.yCoord, axisAlignedBB.minZ + renderPos.zCoord); - - double x = axisAlignedBB.maxX - axisAlignedBB.minX; - double y = axisAlignedBB.maxY - axisAlignedBB.minY; - double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, 0, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, y, z); - - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, y, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, 0, 0); - - GL11.glVertex3d(0,y,0); - GL11.glVertex3d(0,y,z); - GL11.glVertex3d(x,y,z); - GL11.glVertex3d(x,y,0); - - GL11.glVertex3d(0,0,z); - GlStateManager.disableDepth(); - GL11.glVertex3d(0,0,0); - GL11.glVertex3d(x,0,0); - GL11.glVertex3d(x,0,z); - - - - GL11.glEnd(); - - - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - } - public static void highlightBox(Entity entity, Color c, float partialTicks, boolean depth) { - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.disableTexture2D(); - - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - GlStateManager.color(c.getRed()/ 255.0f, c.getGreen()/ 255.0f, c.getBlue()/ 255.0f, c.getAlpha()/ 255.0f); - AxisAlignedBB axisAlignedBB; - if (entity instanceof EntityArmorStand) { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); - } else if (entity instanceof EntityBat) { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.4, -0.4, 0.4, 0.4, 0.4); - } else { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); - } - - Vec3 renderPos = new Vec3( - (float) (entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks), - (float) (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks), - (float) (entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks) - ); - GlStateManager.translate(axisAlignedBB.minX + renderPos.xCoord, axisAlignedBB.minY + renderPos.yCoord, axisAlignedBB.minZ + renderPos.zCoord); - - double x = axisAlignedBB.maxX - axisAlignedBB.minX; - double y = axisAlignedBB.maxY - axisAlignedBB.minY; - double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, 0, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, y, z); - - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, y, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, 0, 0); - - GL11.glVertex3d(0,y,0); - GL11.glVertex3d(0,y,z); - GL11.glVertex3d(x,y,z); - GL11.glVertex3d(x,y,0); - - GL11.glVertex3d(0,0,z); - GL11.glVertex3d(0,0,0); - GL11.glVertex3d(x,0,0); - GL11.glVertex3d(x,0,z); - - - - GL11.glEnd(); - - - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - - -//... - - } - - public static void highlightBox(Entity entity, AColor c, float partialTicks, boolean depth) { - Entity viewing_from = Minecraft.getMinecraft().getRenderViewEntity(); - - double x_fix = viewing_from.lastTickPosX + ((viewing_from.posX - viewing_from.lastTickPosX) * partialTicks); - double y_fix = viewing_from.lastTickPosY + ((viewing_from.posY - viewing_from.lastTickPosY) * partialTicks); - double z_fix = viewing_from.lastTickPosZ + ((viewing_from.posZ - viewing_from.lastTickPosZ) * partialTicks); - - GlStateManager.pushMatrix(); - - GlStateManager.translate(-x_fix, -y_fix, -z_fix); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.disableTexture2D(); - - if (!depth) { - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); - } - - int rgb = RenderUtils.getColorAt(entity.posX % 20,entity.posY % 20,c); - GlStateManager.color(((rgb >> 16) &0XFF)/ 255.0f, ((rgb>>8) &0XFF)/ 255.0f, (rgb & 0xff)/ 255.0f, ((rgb >> 24) & 0xFF) / 255.0f); - - AxisAlignedBB axisAlignedBB; - if (entity instanceof EntityArmorStand) { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); - } else if (entity instanceof EntityBat) { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.4, -0.4, 0.4, 0.4, 0.4); - } else { - axisAlignedBB = AxisAlignedBB.fromBounds(-0.4, -1.5, -0.4, 0.4, 0, 0.4); - } - - Vec3 renderPos = new Vec3( - (float) (entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks), - (float) (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks), - (float) (entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks) - ); - GlStateManager.translate(axisAlignedBB.minX + renderPos.xCoord, axisAlignedBB.minY + renderPos.yCoord, axisAlignedBB.minZ + renderPos.zCoord); - - double x = axisAlignedBB.maxX - axisAlignedBB.minX; - double y = axisAlignedBB.maxY - axisAlignedBB.minY; - double z = axisAlignedBB.maxZ - axisAlignedBB.minZ; - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, y, 0); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, 0, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, y, z); - - GL11.glVertex3d(0, y, z); - GL11.glVertex3d(0, 0, z); - GL11.glVertex3d(x, 0, z); - GL11.glVertex3d(x, y, z); // TOP LEFT / BOTTOM LEFT / TOP RIGHT/ BOTTOM RIGHT - - GL11.glVertex3d(0, 0, 0); - GL11.glVertex3d(0, y, 0); - GL11.glVertex3d(x, y, 0); - GL11.glVertex3d(x, 0, 0); - - GL11.glVertex3d(0,y,0); - GL11.glVertex3d(0,y,z); - GL11.glVertex3d(x,y,z); - GL11.glVertex3d(x,y,0); - - GL11.glVertex3d(0,0,z); - GL11.glVertex3d(0,0,0); - GL11.glVertex3d(x,0,0); - GL11.glVertex3d(x,0,z); - - - - GL11.glEnd(); - - - if (!depth) { - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - } - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - - - -//... - - } - public static void drawTextAtWorld(String text, float x, float y, float z, int color, float scale, boolean increase, boolean renderBlackBox, float partialTicks) { - float lScale = scale; - - RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - - Vector3f renderPos = getRenderPos(x, y, z, partialTicks); - - if (increase) { - double distance = Math.sqrt(renderPos.x * renderPos.x + renderPos.y * renderPos.y + renderPos.z * renderPos.z); - double multiplier = distance / 120f; //mobs only render ~120 blocks away - lScale *= 0.45f * multiplier; - } - - GlStateManager.color(1f, 1f, 1f, 0.5f); - GlStateManager.pushMatrix(); - GlStateManager.translate(renderPos.x, renderPos.y, renderPos.z); - GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); - GlStateManager.rotate(renderManager.playerViewX, 1.0f, 0.0f, 0.0f); - GlStateManager.scale(-lScale, -lScale, lScale); - GlStateManager.disableLighting(); - GlStateManager.depthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); - GlStateManager.disableDepth(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - int textWidth = fontRenderer.getStringWidth(text); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - if (renderBlackBox) { - double j = textWidth / 2; - GlStateManager.disableTexture2D(); - worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldRenderer.pos(-j - 1, -1, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); - worldRenderer.pos(-j - 1, 8, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); - worldRenderer.pos(j + 1, 8, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); - worldRenderer.pos(j + 1, -1, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex(); - tessellator.draw(); - GlStateManager.enableTexture2D(); - } - - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - fontRenderer.drawString(text, -textWidth / 2, 0, color); - - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GlStateManager.depthMask(true); - GlStateManager.enableDepth(); - GlStateManager.popMatrix(); - } - - public static Vector3f getRenderPos(float x, float y, float z, float partialTicks) { - EntityPlayerSP sp = Minecraft.getMinecraft().thePlayer; - return new Vector3f( - x - (float) (sp.lastTickPosX + (sp.posX - sp.lastTickPosX) * partialTicks), - y - (float) (sp.lastTickPosY + (sp.posY - sp.lastTickPosY) * partialTicks), - z - (float) (sp.lastTickPosZ + (sp.posZ - sp.lastTickPosZ) * partialTicks) - ); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java deleted file mode 100755 index b3bc3cd4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -public class ShortUtils { - public static short rotateCounterClockwise(short integer) { - int res = 0; - for(int i=0; i<16; i++){ - int x = i % 4; - int y = i / 4; - res |= (integer >> i & 0x1) << ((4-x-1)*4 + y); - } - return (short) (res & 0xFFFF); - } - public static short rotateClockwise(short integer) { - int res = 0; - for(int i=0; i<16; i++){ - int x = i % 4; - int y = i / 4; - res |= (integer >> i & 0x1) << (x *4 +(4 - y - 1)); - } - return (short) (res & 0xFFFF); - } - - public static short topLeftifyInt(short integer) { - int it = integer & 0xFFFF; - while ((it & (0x1111)) == 0) it >>= 1; - while ((it & (0xF)) == 0) it >>= 4; - return (short) (it & 0xFFFF); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/SkyblockUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/SkyblockUtils.java deleted file mode 100755 index a480415e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/SkyblockUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import net.minecraft.util.ChatComponentText; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; - -public class SkyblockUtils { - public static long getSkyblockYear() throws IOException { - URL url = new URL("https://hypixel-api.inventivetalent.org/api/skyblock/calendar"); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("GET"); - connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); - InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream()); - JsonObject object = (JsonObject) new JsonParser().parse(inputStreamReader); - if (!object.get("success").getAsBoolean()) { - return -1; - } - long now = System.currentTimeMillis() / 1000; - - JsonObject real = object.getAsJsonObject("real"); - long secondsPerYear = real.get("SECONDS_PER_MONTH").getAsLong() * 12; - JsonObject lastLog = object.getAsJsonObject("lastLog"); - long lastTime = lastLog.get("time").getAsLong(); - long year = lastLog.get("year").getAsLong(); - - long passedTime = now - lastTime; - year += passedTime / secondsPerYear; - return year; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java deleted file mode 100755 index 1f3548a6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -import java.text.DecimalFormat; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.regex.Pattern; - -public class TextUtils { - private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)ยง[0-9A-FK-OR]"); - - private static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile("[^a-z A-Z:0-9/'.]"); - - private static final Pattern INTEGER_CHARACTERS = Pattern.compile("[^0-9]"); - - public static String stripColor(String input) { - return STRIP_COLOR_PATTERN.matcher(input).replaceAll(""); - } - - public static String keepScoreboardCharacters(String text) { - return SCOREBOARD_CHARACTERS.matcher(text).replaceAll(""); - } - - public static String keepIntegerCharactersOnly(String text) { - return INTEGER_CHARACTERS.matcher(text).replaceAll(""); - } - - public static String join(List list, String delimeter) { - if (list.isEmpty()) return ""; - StringBuilder stringBuilder = new StringBuilder(); - for (int i = 0; i < list.size() - 1; i++) { - stringBuilder.append(list.get(i).toString()).append(delimeter); - } - stringBuilder.append(list.get(list.size() - 1).toString()); - return stringBuilder.toString(); - } - - - private static final TreeMap suffixes = new TreeMap(); - - static { - suffixes.put(1000L, "k"); - suffixes.put(1000000L, "m"); - suffixes.put(1000000000L, "b"); - } - - public static String format(long value) { -// return String.valueOf(value); - if (value == Long.MIN_VALUE) - return format(-9223372036854775807L); - if (value < 0L) - return "-" + format(-value); - if (value < 1000L) - return Long.toString(value); - Map.Entry e = suffixes.floorEntry(value); - Long divideBy = e.getKey(); - String suffix = e.getValue(); - long truncated = value * 10 / divideBy ; - boolean hasDecimal = (truncated < 100L && (truncated / 10.0D) != (truncated / 10L)); - return hasDecimal ? ((truncated / 10.0D) + suffix) : ((truncated / 10L) + suffix); - } - public static long reverseFormat(String str2) { - String str = str2.toLowerCase(); - String integerPart = str.substring(0, str.length() - 1); - long multiplier = 1; - if (str.endsWith("k")) multiplier = 1000; - else if (str.endsWith("m")) multiplier = 1000000; - else if (str.endsWith("b")) multiplier = 1000000000; - else integerPart = str; - return (long) (Double.parseDouble(integerPart) * multiplier); - } - - public static String formatTime(long ms) { - long seconds = (long) Math.ceil(ms / 1000.0); - long hr = seconds / (60 * 60); seconds -= hr * 60 * 60; - long min = seconds / 60; seconds -= min * 60; - - StringBuilder stringBuilder = new StringBuilder(); - if (hr > 0) { - stringBuilder.append(hr).append("h "); - } - if (hr > 0 || min > 0) { - stringBuilder.append(min).append("m "); - } - if (hr > 0 || min > 0 || seconds > 0) { - stringBuilder.append(seconds).append("s "); - } - - return stringBuilder.toString(); - } - public static String insertDashUUID(String uuid) { - StringBuilder sb = new StringBuilder(uuid); - sb.insert(8, "-"); - sb = new StringBuilder(sb.toString()); - sb.insert(13, "-"); - sb = new StringBuilder(sb.toString()); - sb.insert(18, "-"); - sb = new StringBuilder(sb.toString()); - sb.insert(23, "-"); - - return sb.toString(); - } - -} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/TimeScoreUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/TimeScoreUtil.java deleted file mode 100644 index f43a1f17..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/TimeScoreUtil.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -import kr.syeyoung.dungeonsguide.Main; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; -import org.apache.commons.io.IOUtils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -public class TimeScoreUtil { - private static final TreeMap min8 = new TreeMap(); - private static final TreeMap min10 = new TreeMap(); - private static final TreeMap min12 = new TreeMap(); - public static void init() { - try { - load("8.csv", min8); - } catch (IOException e) { - e.printStackTrace(); - } - try { - load("10.csv", min10); - } catch (IOException e) { - e.printStackTrace(); - } - try { - load("12.csv", min12); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void load(String name, TreeMap minutes) throws IOException { - minutes.clear(); - List lines = IOUtils.readLines(Main.class.getResourceAsStream("/timescore/"+name)); - for (String line:lines) { - String[] split = line.split(","); - minutes.put(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - } - } - - public static int estimate(int mills, int drop) { - if (drop == 600) return estimate(mills, min10); - if (drop == 480) return estimate(mills, min8); - if (drop == 720) return estimate(mills, min12); - return -1; - } - - private static int estimate(int mills, TreeMap lookup_table){ - Map.Entry high = lookup_table.ceilingEntry(mills); - Map.Entry low = lookup_table.floorEntry(mills); - - - if (low == null && high == null) return 0; - if (low == null) return high.getValue(); - if (high == null) return low.getValue(); - - int distHigh = high.getKey() - mills; - int distLow = mills - low.getKey(); - - if (distHigh > distLow) return high.getValue(); - else return low.getValue(); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java deleted file mode 100755 index 59eaa866..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -import lombok.AllArgsConstructor; -import lombok.Data; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.util.Vec3; - -import javax.vecmath.Vector2d; - -public class VectorUtils { - // Ior rooms, different coordinate system is used. Y Increses as marker goes down. X is same. - - - public static Vector2d rotateCounterClockwise(Vector2d vector2d) { - return new Vector2d(vector2d.y, -vector2d.x); - } - public static Vector2d rotateClockwise(Vector2d vector2d) { - return new Vector2d(-vector2d.y, vector2d.x); - } - - @Data @AllArgsConstructor - public static class ProjectionResult { - private float x; - private float y; - private boolean back; - } - - public static double distSquared(Vec3 lookVec, Vec3 posVec, Vec3 objectVec) { - Vec3 v = objectVec.subtract(posVec); - double t = v.dotProduct(lookVec); - Vec3 p = posVec.addVector(lookVec.xCoord * t, lookVec.yCoord * t, lookVec.zCoord * t); - return p.squareDistanceTo(objectVec) / p.squareDistanceTo(posVec); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/XPUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/XPUtils.java deleted file mode 100644 index ebdd87ab..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/XPUtils.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils; - -import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.api.playerprofile.dataclasses.Skill; -import lombok.Data; - -import java.util.Map; -import java.util.TreeMap; - -public class XPUtils { - @Data - public static class XPCalcResult { - private int level; - private double remainingXp; - private double nextLvXp; - } - - private static final TreeMap catacombXp = new TreeMap<>(); - private static final TreeMap skillXp = new TreeMap<>(); - private static final TreeMap skillXp2 = new TreeMap<>(); - static { - catacombXp.put(50.0, 1); - catacombXp.put(125.0, 2); - catacombXp.put(235.0, 3); - catacombXp.put(395.0, 4); - catacombXp.put(625.0, 5); - catacombXp.put(955.0, 6); - catacombXp.put(1425.0, 7); - catacombXp.put(2095.0, 8); - catacombXp.put(3045.0, 9); - catacombXp.put(4385.0, 10); - catacombXp.put(6275.0, 11); - catacombXp.put(8940.0, 12); - catacombXp.put(12700.0, 13); - catacombXp.put(17960.0, 14); - catacombXp.put(25340.0, 15); - catacombXp.put(35640.0, 16); - catacombXp.put(50040.0, 17); - catacombXp.put(70040.0, 18); - catacombXp.put(97640.0, 19); - catacombXp.put(135640.0, 20); - catacombXp.put(188140.0, 21); - catacombXp.put(259640.0, 22); - catacombXp.put(356640.0, 23); - catacombXp.put(488640.0, 24); - catacombXp.put(668640.0, 25); - catacombXp.put(911640.0, 26); - catacombXp.put(1239640.0, 27); - catacombXp.put(1684640.0, 28); - catacombXp.put(2284640.0, 29); - catacombXp.put(3084640.0, 30); - catacombXp.put(4149640.0, 31); - catacombXp.put(5559640.0, 32); - catacombXp.put(7459640.0, 33); - catacombXp.put(9959640.0, 34); - catacombXp.put(13259640.0, 35); - catacombXp.put(17559640.0, 36); - catacombXp.put(23159640.0, 37); - catacombXp.put(30359640.0, 38); - catacombXp.put(39559640.0, 39); - catacombXp.put(51559640.0, 40); - catacombXp.put(66559640.0, 41); - catacombXp.put(85559640.0, 42); - catacombXp.put(109559640.0, 43); - catacombXp.put(139559640.0, 44); - catacombXp.put(177559640.0, 45); - catacombXp.put(225559640.0, 46); - catacombXp.put(285559640.0, 47); - catacombXp.put(360559640.0, 48); - catacombXp.put(453559640.0, 49); - catacombXp.put(569809640.0, 50); - skillXp.put(0.0, 0); - skillXp.put(50.0, 1); - skillXp.put(175.0, 2); - skillXp.put(375.0, 3); - skillXp.put(675.0, 4); - skillXp.put(1175.0, 5); - skillXp.put(1925.0, 6); - skillXp.put(2925.0, 7); - skillXp.put(4425.0, 8); - skillXp.put(6425.0, 9); - skillXp.put(9925.0, 10); - skillXp.put(14925.0, 11); - skillXp.put(22425.0, 12); - skillXp.put(32425.0, 13); - skillXp.put(47425.0, 14); - skillXp.put(67425.0, 15); - skillXp.put(97425.0, 16); - skillXp.put(147425.0, 17); - skillXp.put(222425.0, 18); - skillXp.put(322425.0, 19); - skillXp.put(522425.0, 20); - skillXp.put(822425.0, 21); - skillXp.put(1222425.0, 22); - skillXp.put(1722425.0, 23); - skillXp.put(2322425.0, 24); - skillXp.put(3022425.0, 25); - skillXp.put(3822425.0, 26); - skillXp.put(4722425.0, 27); - skillXp.put(5722425.0, 28); - skillXp.put(6822425.0, 29); - skillXp.put(8022425.0, 30); - skillXp.put(9322425.0, 31); - skillXp.put(10722425.0, 32); - skillXp.put(12222425.0, 33); - skillXp.put(13722425.0, 34); - skillXp.put(15522425.0, 35); - skillXp.put(17322425.0, 36); - skillXp.put(19222425.0, 37); - skillXp.put(21222425.0, 38); - skillXp.put(23322425.0, 39); - skillXp.put(25522425.0, 40); - skillXp.put(27822425.0, 41); - skillXp.put(30222425.0, 42); - skillXp.put(32722425.0, 43); - skillXp.put(35322425.0, 44); - skillXp.put(38072425.0, 45); - skillXp.put(40972425.0, 46); - skillXp.put(44072425.0, 47); - skillXp.put(47472425.0, 48); - skillXp.put(51172425.0, 49); - skillXp.put(55172425.0, 50); - skillXp.put(59472425.0, 51); - skillXp.put(64072425.0, 52); - skillXp.put(68972425.0, 53); - skillXp.put(74172425.0, 54); - skillXp.put(79672425.0, 55); - skillXp.put(85472425.0, 56); - skillXp.put(91572425.0, 57); - skillXp.put(97972425.0, 58); - skillXp.put(104672425.0, 59); - skillXp.put(111672425.0, 60); - skillXp2.put(0.0, 0); - skillXp2.put(50.0, 1); - skillXp2.put(150.0, 2); - skillXp2.put(275.0, 3); - skillXp2.put(435.0, 4); - skillXp2.put(635.0, 5); - skillXp2.put(885.0, 6); - skillXp2.put(1200.0, 7); - skillXp2.put(1600.0, 8); - skillXp2.put(2100.0, 9); - skillXp2.put(2725.0, 10); - skillXp2.put(3510.0, 11); - skillXp2.put(4510.0, 12); - skillXp2.put(5760.0, 13); - skillXp2.put(7324.0, 14); - skillXp2.put(9325.0, 15); - skillXp2.put(11825.0, 16); - skillXp2.put(14950.0, 17); - skillXp2.put(18950.0, 18); - skillXp2.put(23950.0, 19); - skillXp2.put(30200.0, 20); - skillXp2.put(38050.0, 21); - skillXp2.put(47850.0, 22); - skillXp2.put(60100.0, 23); - skillXp2.put(75400.0, 24); - skillXp2.put(94450.0, 25); - } - - public static XPCalcResult getCataXp(double totalXp) { - Map.Entry totalXpEn = catacombXp.floorEntry(totalXp); - XPCalcResult xpCalcResult = new XPCalcResult(); - if (totalXpEn == null) { - xpCalcResult.setLevel(0); - xpCalcResult.remainingXp = totalXp; - } else { - xpCalcResult.level = totalXpEn.getValue(); - xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); - } - Map.Entry asdasd = catacombXp.ceilingEntry(totalXp); - xpCalcResult.nextLvXp = asdasd == null ? 0 : (asdasd.getKey() - (totalXpEn != null ? totalXpEn.getKey() : 0)); - return xpCalcResult; - } - public static XPCalcResult getSkillXp(Skill skill, double totalXp) { - switch(skill) { - case RUNECRAFTING: - Map.Entry totalXpEn = skillXp2.floorEntry(totalXp); - XPCalcResult xpCalcResult = new XPCalcResult(); - if (totalXpEn == null) { - xpCalcResult.setLevel(0); - xpCalcResult.remainingXp = totalXp; - } else { - xpCalcResult.level = totalXpEn.getValue(); - xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); - } - Map.Entry asdasd = catacombXp.ceilingEntry(totalXp); - xpCalcResult.nextLvXp = asdasd == null ? 0 : (asdasd.getKey() - (totalXpEn != null ? totalXpEn.getKey() : 0)); - return xpCalcResult; - default: - totalXpEn = skillXp.floorEntry(totalXp); - xpCalcResult = new XPCalcResult(); - if (totalXpEn == null) { - xpCalcResult.setLevel(0); - xpCalcResult.remainingXp = totalXp; - } else { - xpCalcResult.level = totalXpEn.getValue(); - xpCalcResult.remainingXp = totalXp - totalXpEn.getKey(); - } - asdasd = catacombXp.ceilingEntry(totalXp); - xpCalcResult.nextLvXp = asdasd == null ? 0 : (asdasd.getKey() - (totalXpEn != null ? totalXpEn.getKey() : 0)); - return xpCalcResult; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/CursorReader.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/CursorReader.java deleted file mode 100644 index 11a9da51..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/CursorReader.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils.cursor; - -import com.google.common.io.LittleEndianDataInputStream; -import com.google.common.io.LittleEndianDataOutputStream; -import com.twelvemonkeys.imageio.plugins.bmp.CURImageReader; -import com.twelvemonkeys.imageio.plugins.bmp.CURImageReaderSpi; -import com.twelvemonkeys.imageio.plugins.bmp.ICOImageReader; -import lombok.Data; - -import javax.imageio.ImageIO; -import javax.imageio.ImageReader; -import javax.imageio.stream.ImageInputStream; -import java.awt.image.BufferedImage; -import java.io.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class CursorReader { - public static List readFromInputStream(InputStream inputStream) throws IOException { - System.out.println(inputStream); - LittleEndianDataInputStream dataInputStream = new LittleEndianDataInputStream(new BufferedInputStream(inputStream)); - dataInputStream.mark(Integer.MAX_VALUE); - - - int magicValue = dataInputStream.readUnsignedShort(); - if (magicValue != 0) throw new RuntimeException("Invalid Cursor file"); - int type = dataInputStream.readUnsignedShort(); - if (type != 2) throw new RuntimeException("not cursor"); - int size = dataInputStream.readShort(); - - List directoryList = new ArrayList<>(); - for (int i = 0; i < size; i++) { - - CursorData directory = new CursorData(); - directory.setWidth((short) dataInputStream.readUnsignedByte()); - directory.setHeight((short) dataInputStream.readUnsignedByte()); - directory.setColorCnt((short) dataInputStream.readUnsignedByte()); - directory.setMagicValue(dataInputStream.readByte()); - directory.setXHotSpot(dataInputStream.readShort()); - directory.setYHotSpot(dataInputStream.readShort()); - directory.setSizeBitmap(dataInputStream.readInt() & 0x00000000ffffffffL); - directory.setOffset(dataInputStream.readInt() & 0x00000000ffffffffL); - - directoryList.add(directory); - } - dataInputStream.reset(); - - try (ImageInputStream imageInputStream = ImageIO.createImageInputStream(dataInputStream)) { - CURImageReader imageReader = new CURImageReader(); - imageReader.setInput(imageInputStream); - - for (int i = 0; i < directoryList.size(); i++) { - directoryList.get(i).setBufferedImage(imageReader.read(i)); - } - } - inputStream.close(); - - return directoryList; - } - - private static void setIntLittleEndian(byte[] bytes, int index, int value) { - byte[] ins = new byte[] { - (byte) ((value >> 24)& 0xFF), (byte) ((value >> 16)& 0xFF), (byte) ((value >> 8)& 0xFF), (byte) (value & 0xFF) - }; - bytes[index+3] = ins[0]; - bytes[index+2] = ins[1]; - bytes[index+1] = ins[2]; - bytes[index] = ins[3]; - } - - - @Data - public static class CursorData { - private short width, height, colorCnt, magicValue; - private int xHotSpot, yHotSpot; - private long sizeBitmap; - private long offset; - private BufferedImage bufferedImage; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java deleted file mode 100644 index 20cccef7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils.cursor; - -import lombok.AllArgsConstructor; -import lombok.Getter; - - -@AllArgsConstructor -@Getter -public enum EnumCursor { - DEFAULT(32512,68,"arrowCursor","arrowCursor.cur"), - POINTING_HAND(32649,60,"pointingHandCursor", "pointingHandCursor.cur"), - OPEN_HAND(32646,58,"openHandCursor","openHandCursor.cur"), - CLOSED_HAND(32646,52,"closedHandCursor","closedHandCursor.cur"), - BEAM_CURSOR(32513, 152, "IBeamCursor", "IBeamCursor.cur"), - RESIZE_LEFT(32644, 70,"resizeLeftCursor", "resizeLeftCursor.cur"), - RESIZE_RIGHT(32644, 96,"resizeRightCursor", "resizeRightCursor.cur"), - RESIZE_LEFT_RIGHT(32644, 108, "resizeLeftRightCursor", "resizeLeftRightCursor.cur"), - RESIZE_UP(32645,138,"resizeUpCursor", "resizeUpCursor.cur"), - RESIZE_DOWN(32645,16,"resizeDownCursor", "resizeDownCursor.cur"), - RESIZE_UP_DOWN(32645,116,"resizeUpDownCursor", "resizeUpDownCursor.cur"), - RESIZE_TL(32642, 134, null, "resizeNW.cur"), - RESIZE_DR(32642, 14, null, "resizeSE.cur"), - RESIZE_TLDR(32642, 14, null, "resizeNWSE.cur"), - RESIZE_TR(32643, 136, null, "resizeNE.cur"), - RESIZE_DL(32643, 12, null, "resizeSW.cur"), - RESIZE_TRDL(32643, 12, null, "resizeNESW.cur"), - CROSS(32515, 34,"crosshairCursor", "crosshairCursor.cur"), - NOT_ALLOWED(32648, -1,"operationNotAllowedCursor", "operationNotAllowedCursor.cur"), - TEST(-1, -1, null, "testnonexistant.cur"); - - - private int windows; - private int linux; - private String macos; - private String altFileName; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java deleted file mode 100644 index b08ad378..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils.cursor; - -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; - - -public interface Foundation extends Library { - Foundation INSTANCE = (Foundation) Native.loadLibrary("Foundation", - Foundation.class); - - Pointer objc_getClass(String className); - Pointer sel_registerName(String selectorName); - Pointer objc_msgSend(Pointer receiver, Pointer selector, Object... args); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java deleted file mode 100644 index a3932955..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils.cursor; - -import com.sun.jna.Memory; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import org.apache.commons.io.IOUtils; -import org.lwjgl.BufferUtils; -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; -import org.lwjgl.input.Cursor; -import sun.misc.Unsafe; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.IntBuffer; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - - -public class GLCursors { - private static Unsafe unsafe; - private static Class cursorElement; - private static Constructor constructor; - private static Field cursorField; - - private static Map enumCursorCursorMap = new HashMap<>(); - - - static { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe) f.get(null); - cursorElement = Class.forName("org.lwjgl.input.Cursor$CursorElement"); - constructor = cursorElement.getDeclaredConstructor(Object.class, long.class, long.class); - constructor.setAccessible(true); - cursorField = Cursor.class.getDeclaredField("cursors"); - cursorField.setAccessible(true); - } catch (NoSuchFieldException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException e) { - e.printStackTrace(); - } - } - - public static void setupCursors() { - if (enumCursorCursorMap.size() != 0) return; - int platform = LWJGLUtil.getPlatform(); - for (EnumCursor value : EnumCursor.values()) { - Cursor c = null; - try { - switch(platform) { - case LWJGLUtil.PLATFORM_WINDOWS: - if (value.getWindows() != -1) - c = createCursorWindows(value.getWindows()); - break; - case LWJGLUtil.PLATFORM_LINUX: - if (value.getLinux() != -1) - c = createCursorLinux(value.getLinux()); - break; - case LWJGLUtil.PLATFORM_MACOSX: - if (value.getMacos() != null) - c = createCursorMac(value.getMacos()); - break; - } - } catch (Throwable e) { - System.out.println("Error occured while loading cursor: "+value); - e.printStackTrace(); - } - try { - if (c == null) { - int hotspotX = 0, hotspotY = 0; - BufferedImage bufferedImage = null; - int minC = Cursor.getMinCursorSize(), maxC = Cursor.getMaxCursorSize(); - try { - ResourceLocation cursorinfo = new ResourceLocation("dungeonsguide:cursors/"+value.getAltFileName()); - List cursorDataList = CursorReader.readFromInputStream(Minecraft.getMinecraft().getResourceManager().getResource(cursorinfo).getInputStream()); - List cursorDataList2 = cursorDataList.stream() - .filter(cdata -> cdata.getBufferedImage() != null) - .filter(cdata -> minC <= cdata.getHeight() && cdata.getHeight() <= maxC && minC <= cdata.getWidth() && cdata.getWidth() <= maxC) - .sorted(Comparator.comparingInt(CursorReader.CursorData::getWidth)).collect(Collectors.toList()); - - CursorReader.CursorData cursorData = - cursorDataList2.size() == 0 ? cursorDataList.get(0) : cursorDataList2.get(0); - System.out.println(cursorData); - bufferedImage = cursorData.getBufferedImage(); - hotspotX = cursorData.getXHotSpot(); - hotspotY = cursorData.getYHotSpot(); - } catch (Throwable t) {t.printStackTrace();} - - - int width = bufferedImage == null ? 16 : bufferedImage.getWidth(); - int height = bufferedImage == null ? 16 : bufferedImage.getHeight(); - int effWidth = MathHelper.clamp_int(width, Cursor.getMinCursorSize(), Cursor.getMaxCursorSize()); - int effHeight = MathHelper.clamp_int(height, Cursor.getMinCursorSize(), Cursor.getMaxCursorSize()); - int length = effHeight * effWidth; - IntBuffer intBuffer = BufferUtils.createIntBuffer(length); - for (int i = 0; i < length; i++) { - int x = i % effWidth; - int y = i / effWidth; - if (bufferedImage == null) { - intBuffer.put(RenderUtils.getChromaColorAt(x,y,1.0f, 1.0f, 1.0f, 1.0f)); - } else if (x >= width || y >= height) { - intBuffer.put(0); - } else { - intBuffer.put(bufferedImage.getRGB(x, height - y - 1)); - } - } - intBuffer.flip(); - c = new Cursor(effWidth, effHeight, hotspotX, height - hotspotY - 1,1,intBuffer, null); - } - } catch (Throwable e) { - System.out.println("Error occured while loading cursor from resource: "+value); - e.printStackTrace(); - } - if (c != null) { - try { - Object arr = cursorField.get(c); - Object cursor = Array.get(arr, 0); - for (Field declaredField : cursor.getClass().getDeclaredFields()) { - declaredField.setAccessible(true); - Object obj = declaredField.get(cursor); - System.out.println(declaredField.getName()+": "+obj+" - "+(obj instanceof ByteBuffer)); - if (obj instanceof ByteBuffer) { - ByteBuffer b = (ByteBuffer) declaredField.get(cursor); - StringBuilder sb = new StringBuilder("Contents: "); - for (int i = 0; i < b.limit(); i++) { - sb.append(Integer.toHexString(b.get(i) & 0xFF)).append(" "); - } - System.out.println(sb.toString()); - } - } - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - enumCursorCursorMap.put(value, c); - } - } - } - - public static Cursor getCursor(EnumCursor enumCursor) { - return enumCursorCursorMap.get(enumCursor); - } - - private static Cursor createCursorWindows(int cursor) throws LWJGLException, InstantiationException, InvocationTargetException, IllegalAccessException { - User32 user32 = User32.INSTANCE; - Pointer hIcon = user32 - .LoadCursorW(Pointer.NULL, cursor); - long ptrVal = Pointer.nativeValue(hIcon); - ByteBuffer handle = BufferUtils.createByteBuffer(Pointer.SIZE); // Why does it have to be direct? well it crashes without it. - if (handle.order() == ByteOrder.LITTLE_ENDIAN) { - for (int i = 0; i < Pointer.SIZE; i++) { - byte value = (byte) ((ptrVal >> i * 8) & 0xFF); - handle.put(value); - } - } else { - for (int i = Pointer.SIZE; i >= 0; i++) { - byte value = (byte) ((ptrVal >> i * 8) & 0xFF); - handle.put(value); - } - } - handle.position(0); - return createCursor(handle); - } - private static Cursor createCursorLinux(int cursor) throws LWJGLException, InstantiationException, InvocationTargetException, IllegalAccessException { - X11.Display display = X11.INSTANCE.XOpenDisplay(null); - Pointer fontCursor = X11.INSTANCE.XCreateFontCursor(display, cursor); - long iconPtr = Pointer.nativeValue(fontCursor); - - return createCursor(iconPtr); - } - private static Cursor createCursorMac(String cursor) throws LWJGLException, InstantiationException, InvocationTargetException, IllegalAccessException { - // trust me, it's horrible. - Foundation foundation = Foundation.INSTANCE; - Pointer nsCursor = foundation.objc_getClass("NSCursor"); - Pointer selector = foundation.sel_registerName(cursor); - Pointer thePointer = foundation.objc_msgSend(nsCursor, selector); - long iconPtr = Pointer.nativeValue(thePointer); - - return createCursor(iconPtr); - } - - - private static Cursor createCursor(Object handle) throws IllegalAccessException, InvocationTargetException, InstantiationException { - // Yes. I had no way. - Cursor ADANGEROUSOBJECT = (Cursor) unsafe.allocateInstance(Cursor.class); - Object cursorElement = constructor.newInstance(handle, 0, LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_LINUX ? -1 : System.currentTimeMillis()); - Object array = Array.newInstance(GLCursors.cursorElement, 1); - Array.set(array, 0, cursorElement); - cursorField.set(ADANGEROUSOBJECT, array); - return ADANGEROUSOBJECT; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java deleted file mode 100644 index 5bcd2599..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils.cursor; - -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.Pointer; -import com.sun.jna.Structure; - -public interface User32 extends Library { - - public static User32 INSTANCE = (User32) Native - .loadLibrary("User32", User32.class); - - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_ARROW = 32512; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_IBEAM = 32513; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_WAIT = 32514; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_CROSS = 32515; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_UPARROW = 32516; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_SIZENWSE = 32642; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_SIZENESW = 32643; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_SIZEWE = 32644; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_SIZENS = 32645; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_SIZEALL = 32646; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_NO = 32648; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_HAND = 32649; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_APPSTARTING = 32650; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_HELP = 32651; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_ICON = 32641; - /** @see #LoadCursorW(Pointer, int) */ - public static final int IDC_SIZE = 32640; - - /** http://msdn.microsoft.com/en-us/library/ms648391(VS.85).aspx */ - public Pointer LoadCursorW(Pointer hInstance, - int lpCursorName); - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/X11.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/X11.java deleted file mode 100644 index caf8ae10..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/X11.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.utils.cursor; - -import com.sun.jna.Library; -import com.sun.jna.Native; -import com.sun.jna.Pointer; -import com.sun.jna.PointerType; - -public interface X11 extends Library { - X11 INSTANCE = (X11) Native.loadLibrary("X11", X11.class); - public Pointer XCreateFontCursor(Display display, - int shape); - public Display XOpenDisplay(String var1); - - public static class Display extends PointerType { - public Display() { - } - } - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/wsresource/StaticResource.java b/src/main/java/kr/syeyoung/dungeonsguide/wsresource/StaticResource.java deleted file mode 100644 index 814fb8c8..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/wsresource/StaticResource.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.wsresource; - -import lombok.Data; - -import java.util.UUID; - -@Data -public class StaticResource { - private UUID resourceID; - private String value; - private boolean exists; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/wsresource/StaticResourceCache.java b/src/main/java/kr/syeyoung/dungeonsguide/wsresource/StaticResourceCache.java deleted file mode 100644 index db781844..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/wsresource/StaticResourceCache.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package kr.syeyoung.dungeonsguide.wsresource; - -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; -import kr.syeyoung.dungeonsguide.stomp.StompInterface; -import kr.syeyoung.dungeonsguide.stomp.StompMessageHandler; -import kr.syeyoung.dungeonsguide.stomp.StompPayload; -import kr.syeyoung.dungeonsguide.stomp.StompSubscription; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.json.JSONObject; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -public class StaticResourceCache implements StompMessageHandler { - public static final StaticResourceCache INSTANCE = new StaticResourceCache(); - - private Map staticResourceMap = new HashMap<>(); - - private Map> staticResourceRequest = new HashMap<>(); - - public void purgeCache() { - staticResourceRequest.clear(); - staticResourceMap.clear(); - } - - public CompletableFuture getResource(UUID resourceID) { - if (staticResourceMap.containsKey(resourceID)) return CompletableFuture.completedFuture(staticResourceMap.get(resourceID)); - if (staticResourceRequest.containsKey(resourceID)) return staticResourceRequest.get(resourceID); - - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().header("destination", "/app/staticresource.get").payload(resourceID.toString())); - CompletableFuture comp = new CompletableFuture<>(); - staticResourceRequest.put(resourceID, comp); - return comp; - } - - @Override - public void handle(StompInterface stompInterface, StompPayload stompPayload) { - JSONObject object = new JSONObject(stompPayload.payload()); - StaticResource staticResource = new StaticResource(); - staticResource.setResourceID(UUID.fromString(object.getString("resourceID"))); - staticResource.setExists(object.getBoolean("exists")); - staticResource.setValue((!object.has("value") || object.isNull("value")) ? null : object.getString("value")); - - staticResourceMap.put(staticResource.getResourceID(), staticResource); - CompletableFuture completed = staticResourceRequest.remove(staticResource.getResourceID()); - if (completed != null) completed.complete(staticResource); - } - - @SubscribeEvent - public void stompConnect(StompConnectedEvent stompConnectedEvent) { - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/staticresource.get").build()); - - getResource(BONUS_SCORE); - getResource(TRIVIA_ANSWERS); - getResource(DATA_COLLECTION); - } - - public static final UUID BONUS_SCORE = UUID.fromString("13f10001-66b5-46e5-94f9-1a5161a23429"); - public static final UUID TRIVIA_ANSWERS = UUID.fromString("5657f2cc-2bb8-4fcd-b55c-ffc0a35b9349"); - public static final UUID DATA_COLLECTION = UUID.fromString("c11f026f-9f26-4d14-8d52-88325dd6397a"); -} diff --git a/src/main/resources/assets/dg/textures/dglogox128.png b/src/main/resources/assets/dg/textures/dglogox128.png new file mode 100644 index 00000000..3558d9da Binary files /dev/null and b/src/main/resources/assets/dg/textures/dglogox128.png differ diff --git a/src/main/resources/assets/dg/textures/dglogox32.png b/src/main/resources/assets/dg/textures/dglogox32.png new file mode 100644 index 00000000..62962d7e Binary files /dev/null and b/src/main/resources/assets/dg/textures/dglogox32.png differ diff --git a/src/main/resources/assets/skyblock_dungeons_guide/sounds.json b/src/main/resources/assets/skyblock_dungeons_guide/sounds.json new file mode 100644 index 00000000..5c28a55b --- /dev/null +++ b/src/main/resources/assets/skyblock_dungeons_guide/sounds.json @@ -0,0 +1,10 @@ +{ + "readysetgo": { + "category" : "player", + "sounds": [{ + "name": "skyblock_dungeons_guide:readysetgo", + "stream": true + } + ] + } +} diff --git a/src/main/resources/assets/skyblock_dungeons_guide/sounds/readysetgo.ogg b/src/main/resources/assets/skyblock_dungeons_guide/sounds/readysetgo.ogg new file mode 100644 index 00000000..12470b8e Binary files /dev/null and b/src/main/resources/assets/skyblock_dungeons_guide/sounds/readysetgo.ogg differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 70df65aa..2e1a5e46 100755 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -4,10 +4,10 @@ "name": "Skyblock Dungeons Guide", "description": "A mod to help dungeon players to find and solve secrets and puzzles most efficiently.", "version": "${version}", - "mcversion": "${mcversion}", - "url": "", + "mcversion": "1.8.9", + "url": "https://discord.gg/dg", "updateUrl": "", - "authorList": ["syeyoung"], + "authorList": ["syeyoung", "kokoniara"], "credits": "The guild Jerry's Crew, for nothing.", "logoFile": "", "screenshots": [], -- cgit